From 6ad74138800e7c553e3058d5de9ba4f4976c92b1 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 12 Apr 2016 22:11:40 +0100 Subject: [PATCH] Added OS X support to frmEditAccount --- source/frmEditAccount.cpp | 15 +++++++++++---- source/frmEditAccount.h | 4 ++++ source/frmEditAccount.mm | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 source/frmEditAccount.mm diff --git a/source/frmEditAccount.cpp b/source/frmEditAccount.cpp index 4883625..e6bff81 100644 --- a/source/frmEditAccount.cpp +++ b/source/frmEditAccount.cpp @@ -105,6 +105,12 @@ void frmEditAccount::DetectAddressBook( wxCommandEvent& event ) int SSLResult; +#if defined(__APPLE__) + + SSLResult = DisplayTrustPanel(&CDavObj); + +#else + frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this); frmICPtr->LoadDataNew(CDavObj.GetSSLVerifyResults(), txtAddress->GetValue()); @@ -116,7 +122,9 @@ void frmEditAccount::DetectAddressBook( wxCommandEvent& event ) delete frmICPtr; frmICPtr = NULL; - + +#endif + // Process the response from the user. if (SSLResult == 1){ @@ -133,7 +141,6 @@ void frmEditAccount::DetectAddressBook( wxCommandEvent& event ) return; } - } else { @@ -173,9 +180,9 @@ void frmEditAccount::LoadSettings( wxString AccNameIn ){ bool ContinueAcc = TRUE; wxString AccountName; wxString AccountData; - + ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex); - + while (ContinueAcc){ if (AccountName == AccName){ diff --git a/source/frmEditAccount.h b/source/frmEditAccount.h index 8448c16..ba24bca 100644 --- a/source/frmEditAccount.h +++ b/source/frmEditAccount.h @@ -26,6 +26,7 @@ Subclass of frmEditAccountADT, which is generated by wxFormBuilder. #include "AppXestiaAddrBk.h" #include +#include "carddav/carddav.h" //// end generated include @@ -47,6 +48,9 @@ class frmEditAccount : public frmEditAccountADT wxFileConfig *cfgfile; wxString AccName; bool DialogResult = false; +#if defined(__APPLE__) + int DisplayTrustPanel(CardDAV *Connection); +#endif //// end generated class members }; diff --git a/source/frmEditAccount.mm b/source/frmEditAccount.mm new file mode 100644 index 0000000..1db02ab --- /dev/null +++ b/source/frmEditAccount.mm @@ -0,0 +1,40 @@ +// frmMain.mm - OS X specific functions for frmEditAccount +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see +#import +#import + +#include "frmEditAccount.h" + +int frmEditAccount::DisplayTrustPanel(CardDAV *Connection){ + + NSInteger ResultValue; + + SFCertificateTrustPanel *secpanel = [SFCertificateTrustPanel sharedCertificateTrustPanel]; + + [secpanel setDefaultButtonTitle:@"Accept"]; + [secpanel setAlternateButtonTitle:@"Cancel"]; + [secpanel setInformativeText: @"This certificate is not trusted. Someone could be trying to eavesdrop on your connection. Do you want to accept this certificate anyway?\n\nAccept and trusting the certificate will fetch and process information as required.\nCancel will close the connection."]; + [secpanel setShowsHelp:YES]; + + [secpanel setParentWindow:(NSWindow*)this->GetHandle()]; + + ResultValue = [secpanel runModalForTrust:Connection->GetTrustObject() message:@"Certificate not trusted"]; + + return (int)ResultValue; + +} \ No newline at end of file -- 2.39.5