#include "common/events.h"
#include "common/dirs.h"
#include "vcard/vcard.h"
-#include "carddav/carddav.h"
#include "contacteditor/frmContactEditor.h"
#include "import/import.h"
#include "export/export.h"
// Define the event types.
DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
-DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
DEFINE_EVENT_TYPE(CE_OPENCONTACT);
DEFINE_EVENT_TYPE(CE_OPENCONTACTLIST);
DEFINE_EVENT_TYPE(WINDOW_CLOSE);
DEFINE_EVENT_TYPE(CONNSTAT_UPDATE);
DEFINE_EVENT_TYPE(INVALIDSSLCERT);
+DEFINE_EVENT_TYPE(INVALIDSSLCERTSTRING);
DEFINE_EVENT_TYPE(GETSELECTEDLIST);
DEFINE_EVENT_TYPE(SYNCACCOUNT);
DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW);
DEFINE_EVENT_TYPE(RELOADCONTACTLIST);
DEFINE_EVENT_TYPE(REFRESHADDRESSBOOK);
+#if defined(__APPLE__)
+DEFINE_EVENT_TYPE(INVALIDSSLTRUST);
+#endif
// Setup the event table using the event types.
BEGIN_EVENT_TABLE(frmMain, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
-EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
EVT_COMMAND(wxID_ANY, CE_OPENCONTACTLIST, frmMain::OpenContactInfoList)
EVT_COMMAND(wxID_ANY, WINDOW_CLOSE, frmMain::WindowDelete)
EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus)
EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate)
+EVT_COMMAND(wxID_ANY, INVALIDSSLCERTSTRING, frmMain::InvalidSSLCertificateString)
EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList)
EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults)
EVT_COMMAND(wxID_ANY, RELOADCONTACTLIST, frmMain::ReloadContactList)
EVT_COMMAND(wxID_ANY, REFRESHADDRESSBOOK, frmMain::RefreshAddressBook)
+#if defined(__APPLE__)
+EVT_COMMAND(wxID_ANY, INVALIDSSLTRUST, frmMain::DisplayTrustPanel)
+#endif
END_EVENT_TABLE()
frmMain::frmMain( wxWindow* parent )
wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png));
wxMemoryInputStream cstream(icons_accgroup_png, sizeof(icons_accgroup_png));
wxMemoryInputStream dstream(icons_accnone_png, sizeof(icons_accnone_png));
+ wxMemoryInputStream estream(icons_accunsupported_png, sizeof(icons_accunsupported_png));
wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG);
wxBitmap AccInet(icons_accinet_png, -1);
wxBitmap AccGrp(icons_accgroup_png, -1);
wxIcon wxIAccGrp;
wxIAccGrp.CopyFromBitmap(AccGrp);
-
+
wxImage icons_accnone_png(dstream, wxBITMAP_TYPE_PNG);
wxBitmap AccNone(icons_accnone_png, -1);
wxIcon wxIAccNone;
wxIAccNone.CopyFromBitmap(AccNone);
+
+ wxImage icons_accunsupported_png(estream, wxBITMAP_TYPE_PNG);
+ wxBitmap AccUnsupported(icons_accunsupported_png, -1);
+ wxIcon wxIAccUnsupported;
+ wxIAccUnsupported.CopyFromBitmap(AccUnsupported);
AccountID = AccImgList->Add(wxIAccNIcon);
AccountNetID = AccImgList->Add(wxIAccInet);
AccountGrpID = AccImgList->Add(wxIAccGrp);
AccountNoneID = AccImgList->Add(wxIAccNone);
+ AccountUnsupportedID = AccImgList->Add(wxIAccUnsupported);
bmpIcon->SetIcon(AccImgList->GetIcon(AccountNoneID));
wxImage icons_nossl_png(nosslstream, wxBITMAP_TYPE_PNG);
imgNoSSL = new wxBitmap(icons_nossl_png, -1);
-
+
+ // Toolbar icons.
+
+ wxMemoryInputStream addaddressbook(toolbar_addaddressbook_png, sizeof(toolbar_addaddressbook_png));
+ wxMemoryInputStream preferences(toolbar_preferences_png, sizeof(toolbar_preferences_png));
+ wxMemoryInputStream searchcontacts(toolbar_searchcontacts_png, sizeof(toolbar_searchcontacts_png));
+ wxMemoryInputStream addcontact(toolbar_addcontact_png, sizeof(toolbar_addcontact_png));
+ wxMemoryInputStream editcontact(toolbar_editcontact_png, sizeof(toolbar_editcontact_png));
+ wxMemoryInputStream deletecontact(toolbar_deletecontact_png, sizeof(toolbar_deletecontact_png));
+
+ wxImage toolbar_addaddressbook_png(addaddressbook, wxBITMAP_TYPE_PNG);
+ imgAddAddressBook = new wxBitmap (toolbar_addaddressbook_png, -1);
+ tblMain->SetToolNormalBitmap(tbtNewAccount->GetId(), *imgAddAddressBook);
+
+ wxImage toolbar_preferences_png(preferences, wxBITMAP_TYPE_PNG);
+ imgPreferences = new wxBitmap (toolbar_preferences_png, -1);
+ tblMain->SetToolNormalBitmap(tbtPreferences->GetId(), *imgPreferences);
+
+ wxImage toolbar_searchcontacts_png(searchcontacts, wxBITMAP_TYPE_PNG);
+ imgSearchContacts = new wxBitmap (toolbar_searchcontacts_png, -1);
+ tblMain->SetToolNormalBitmap(tbtSearch->GetId(), *imgSearchContacts);
+
+ wxImage toolbar_addcontact_png(addcontact, wxBITMAP_TYPE_PNG);
+ imgAddContact = new wxBitmap (toolbar_addcontact_png, -1);
+ tblMain->SetToolNormalBitmap(tbtAddContact->GetId(), *imgAddContact);
+
+ wxImage toolbar_editcontact_png(editcontact, wxBITMAP_TYPE_PNG);
+ imgEditContact = new wxBitmap (toolbar_editcontact_png, -1);
+ tblMain->SetToolNormalBitmap(tbtEditContact->GetId(), *imgEditContact);
+
+ wxImage toolbar_deletecontact_png(deletecontact, wxBITMAP_TYPE_PNG);
+ imgDeleteContact = new wxBitmap (toolbar_deletecontact_png, -1);
+ tblMain->SetToolNormalBitmap(tbtDeleteContact->GetId(), *imgDeleteContact);
+
// Activity Icon.
wxMemoryInputStream act1(icons_act1_png, sizeof(icons_act1_png));
{
// Function to run when quitting.
-
- //Go through the windows and close each one (be it search
- //or contact editor). Abort if user wants to cancel.
-
- // Close the contact editor windows.
-
- // Close the contact windows.
-
- // Close the search windows.
-
+
// Write out the ETag databases.
+
+ ETagProcTimer.Stop();
+ ETagProcTimer.Notify();
// Save Preferences: Save the window position if that option is enabled.
if (SaveWindowPos == TRUE){
- wxRect frmMainPos = this->GetRect();
+ wxRect frmMainPos = GetRect();
cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
delete cfgfile;
cfgfile = NULL;
- //Everything closed... exit.
+ // Everything closed... exit.
std::exit(0);
void frmMain::OpenPreferences( wxCommandEvent& event)
{
+ // Close all windows first.
+
+ if (CloseAllWindows() == false)
+ {
+ return;
+ }
+
// Open the preferences window.
ReloadAccounts = FALSE;
// Reload the accounts as a change has been made within
// the application and clear the current contact information.
- this->LoadPreferences();
+ this->LoadPreferences(true);
this->ResetContactInfo();
}
// Reload the accounts as a change has been made within
// the application.
- this->LoadPreferences();
-
+ this->LoadPreferences(true);
+
}
}
imgSSLStatus->SetBitmap(*imgOffline);
SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
AccountTypeFinal.Append(wxT("local"));
+ } else {
+ imgSSLStatus->SetBitmap(*imgOffline);
+ SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
+ AccountTypeFinal.Append(AccountType.Lower());
}
AccountIndex = i;
} else if (AccountType == wxT("Local")){
SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
AccountTypeFinal.Append(wxT("local"));
+ } else {
+ AccountTypeFinal.Append(AccountType.Lower());
}
AccountIndex = i;
long ContactSeekPoint = 0;
wxDir vcardaccdir(AccountDirFinal);
-
+
// Get the wxTreeItemId and image icon and compare it to the list.
if (ActiveItemIcon == AccountGrpID){
if (vCardFilename.Right(4) == wxT(".vcf") ||
vCardFilename.Right(4) == wxT(".VCF") ||
- vCardFlename.Right(5) == wxT(".vcard") ||
+ vCardFilename.Right(5) == wxT(".vcard") ||
vCardFilename.Right(5) == wxT(".VCARD")){
vCard Person;
// Split the name into sections.
- vCardDataString = Person.Get(wxT("N"));
-
vCardName NameData = Person.GetName();
vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
OldSessionID = SessionID;
SessionID = wxString::Format(wxT("%i"), rand() % 32768);
- LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList);
+ LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList, ContactBackgroundColour);
ActiveFilename = ContactsFileIndex[ContactSeekNum];
}
return;
}
+
+ // Check if the account type is a valid account type, otherwise
+ // display an error message.
+
+ if (ActiveAccountType != "CardDAV" && ActiveAccountType != "carddav" &&
+ ActiveAccountType != "Local" && ActiveAccountType != "local"){
+
+ wxMessageBox(_("Cannot add a new contact as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR);
+ return;
+
+ }
// Add Pointer to SetupPointers for the ETagDB.
return;
}
-
+
wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
ContactEditor->SetupHeaders();
+
+ if (ActiveAccountType != "CardDAV" && ActiveAccountType != "carddav" &&
+ ActiveAccountType != "Local" && ActiveAccountType != "local"){
+
+ ContactEditor->SetupAccountData(true);
+
+ }
// Check if pointer is NULL (not from the search forms) or not.
if (!ActiveAccount.IsEmpty()){
- if (ActiveAccountType != wxT("Local")){
+ if (ActiveAccountType == wxT("CardDAV") || ActiveAccountType == wxT("carddav")){
// Account type is not local.
} else {
- wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported for this type of account"));
+ wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported"), wxICON_ERROR);
}
wxPostEvent(this, addevent);
Contact->SetupPointers(&MemoryFileList);
+ Contact->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
Contact->SetupContactData(&Person);
Contact->SetIcon(contacticon);
wxPostEvent(this, addevent);
Contact->SetupPointers(&MemoryFileList);
+ Contact->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
Contact->SetupContactData(&Person);
Contact->SetIcon(contacticon);
// Load the preferences.
- this->LoadPreferences();
+ this->LoadPreferences(true);
}
-void frmMain::LoadPreferences(){
+void frmMain::LoadPreferences(bool skipWindowSizeReload){
// Load the preferences.
XABPreferences preferences(preffilename);
+ // Clear the active account/filename information and account list.
+
+ ActiveAccount = "";
+ ActiveAccountType = "";
+ ActiveFilename = "";
+ lstContacts->DeleteAllItems();
+
// Setup the main window position (if needed).
bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition"));
bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks"));
+ bool UseBackgroundContactColour = preferences.GetBoolData(wxT("UseBackgroundContactColour"));
- if (SaveWindowPos == TRUE){
+ if (SaveWindowPos == true && skipWindowSizeReload == false){
this->SetSize(preferences.GetMainWindowData());
}
+ if (UseBackgroundContactColour == true){
+
+ ContactBackgroundColour = preferences.GetBackgroundContactColourData();
+
+ } else {
+
+ ContactBackgroundColour = wxTransparentColour;
+
+ }
+
treAccounts->DeleteAllItems();
wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"), AccountNoneID);
AccTmrPtr = NULL;
}
+
+#if defined(__WIN32__)
+
+ for (std::map<int, PCCERT_CONTEXT>::iterator CertificateIter = AccountCertificateData.begin();
+ CertificateIter != AccountCertificateData.end(); CertificateIter++){
+
+ CertFreeCertificateContext(CertificateIter->second);
+
+ }
+
+ AccountCertificateData.clear();
+
+#endif
AccountSyncTimers.clear();
-
+
wxString AccDir;
wxString AccDirFull;
wxString AccDirFullSfx;
wxTreeItemId AccountTreeId;
wxTreeItemId GroupTreeId;
int intGroupID = 0;
+
+ // Relaod the accounts for the ETagProcTimer.
+
+ ETagProcTimer.ReloadAccounts();
for (int i = 0; i < preferences.accounts.GetCount(); i++){
-
+
if ((preferences.accounts.GetAccountType(i) == wxT("Local") ||
- preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){
+ preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == true){
continue;
AccName = preferences.accounts.GetAccountName(i);
AccName.Trim();
AccountAccDirList.insert(std::make_pair(i, AccDirFull));
-
+
if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") ||
preferences.accounts.GetAccountType(i) == wxT("carddav")){
AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountNetID, -1);
- } else {
+ } else if (preferences.accounts.GetAccountType(i) == wxT("Local") ||
+ preferences.accounts.GetAccountType(i) == wxT("local")) {
AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountID, -1);
+ } else {
+
+ AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountUnsupportedID, -1);
+
}
// Go through the account directory and find contact files with
wxString vCardFilename;
wxString vCardDataString;
wxString vCardFilenameFull;
-
+
bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
while(ProcFiles){
vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData();
vCard *ClientDataPtr = vCardConfObj->vCardLocalData;
vCard *ServerDataPtr = vCardConfObj->vCardServerData;
- frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList);
+ frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList, ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
frameCR->ShowModal();
int FinalConflictResult = frameCR->GetResult();
// First Name, Last Name.
- lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname);
+ if (ucd->ContactNameArray.Forename == wxT("") && ucd->ContactNameArray.Surname == wxT(""))
+ {
+ lstContacts->SetItem(longSelected, 0, ucd->ContactName);
+ }
+ else
+ {
+ lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname);
+ }
} else if (SortMode == 2){
// Last Name, First Name.
-
- lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename);
+
+ if (ucd->ContactNameArray.Forename == wxT("") && ucd->ContactNameArray.Surname == wxT(""))
+ {
+ lstContacts->SetItem(longSelected, 0, wxT(", ") + ucd->ContactName);
+ }
+ else
+ {
+ lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename);
+ }
} else if (SortMode == 3){
// Nickname.
- lstContacts->SetItem(longSelected, 0, ucd->ContactNickname);
+ if (ucd->ContactNickname == wxT(""))
+ {
+ lstContacts->SetItem(longSelected, 0, _("(no nickname)"));
+ }
+ else
+ {
+ lstContacts->SetItem(longSelected, 0, ucd->ContactNickname);
+ }
} else if (SortMode == 4){
vCard UpdatedPerson;
UpdatedPerson.LoadFile(ucd->ContactFilename);
+ frmContactPtr->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
frmContactPtr->SetupContactData(&UpdatedPerson);
}
}
-void frmMain::UpdateAccountList(wxCommandEvent& event){
-
- // Update the account list (currently unimplemented).
-
-}
-
void frmMain::SetupPointers(void *ActMgrPtrInc){
// Setup the pointers for the main window.
ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
- LoadPreferences();
+ LoadPreferences(false);
}
if (uc->ContactAccount == AccountAccDirList[i]){
- treAccounts->SelectItem(nextChild, TRUE);
- AccCtrl->SetText(treAccounts->GetItemText(nextChild));
+ treAccounts->SelectItem(nextChild, TRUE);
+ AccCtrl->SetText(treAccounts->GetItemText(nextChild));
}
void frmMain::DeleteContact(wxCommandEvent& event){
// Delete a contact from the main window.
-
+
// Check if a contact is selected.
long intSelected = -1;
if (intSelected == -1){
return;
}
+
+ // Check if the account type is a valid account type, otherwise
+ // display an error message.
+
+ if (ActiveAccountType != "CardDAV" && ActiveAccountType != "carddav" &&
+ ActiveAccountType != "Local" && ActiveAccountType != "local"){
+
+ wxMessageBox(_("Cannot delete contact as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR);
+ return;
+
+ }
frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
if (nextChild == selectedChild){
wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename;
+ break;
}
}
// Add task to the activity monitor to delete the contact.
-
+
frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT(""));
}
wxString AccTypeLower;
wxString AccType;
bool AccountSSL;
- std::map<int, SSLCertCollection>::iterator SSLColIter;
+#if defined(__APPLE__)
+
+ std::map<int, SecTrustRef>::iterator SSLTrustIter;
+
+ for (int i = 0; i < prefaccounts.GetCount(); i++){
+
+ SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
+ AccType.Append(prefaccounts.GetAccountType(i));
+ AccountSSL = prefaccounts.GetAccountSSL(i);
+ AccTypeLower = AccType.MakeLower();
+ SeekAccount.Append(wxT("."));
+ SeekAccount.Append(AccTypeLower);
+
+ if (SeekAccount == ActiveAccount){
+
+ if (AccTypeLower == wxT("local")){
+
+ return;
+
+ }
+
+ if (AccountSSL == false){
+
+ return;
+
+ }
+
+ SSLTrustIter = AccountTrustData.find(i);
+
+ // Setup and display the form.
+
+ DisplayCertificate(SSLTrustIter->second);
+
+ }
+
+ SeekAccount.Clear();
+ AccTypeLower.Clear();
+ AccType.clear();
+
+ }
+
+#elif defined(__WIN32__)
+
+ std::map<int, PCCERT_CONTEXT>::iterator SSLCertificateIter;
+
+ for (int i = 0; i < prefaccounts.GetCount(); i++){
+
+ SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
+ AccType.Append(prefaccounts.GetAccountType(i));
+ AccountSSL = prefaccounts.GetAccountSSL(i);
+ AccTypeLower = AccType.MakeLower();
+ SeekAccount.Append(wxT("."));
+ SeekAccount.Append(AccTypeLower);
+
+ if (SeekAccount == ActiveAccount){
+
+ if (AccTypeLower == wxT("local")){
+
+ return;
+
+ }
+
+ if (AccountSSL == false){
+
+ return;
+
+ }
+
+ SSLCertificateIter = AccountCertificateData.find(i);
+
+ // Setup and display the form.
+
+ if (SSLCertificateIter->second->pCertInfo == NULL){
+
+ wxMessageBox("No certificate information is available due to invalid connection details, connection being in progress or invalid certificate data received.");
+
+ } else {
+
+ BOOL ModifiedCertificateData;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(SSLCertificateIter->second, (HWND)this->GetHandle());
+
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
+
+ }
+
+ //DisplayCertificate(SSLTrustIter->second);
+
+ }
+
+ SeekAccount.Clear();
+ AccTypeLower.Clear();
+ AccType.clear();
+
+ }
+
+#else
+
+ std::map<int, SSLCertCollectionString>::iterator SSLColIter;
+
for (int i = 0; i < prefaccounts.GetCount(); i++){
SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
SSLColIter = AccountSSLData.find(i);
- SSLCertCollection SSLCertInfo = SSLColIter->second;
-
+ SSLCertCollectionString SSLCertInfo = SSLColIter->second;
+
frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
frameSSLCert->StartCertFrom(0);
- frameSSLCert->SetupCerts(SSLCertInfo);
+ frameSSLCert->SetupCertsString(SSLCertInfo);
frameSSLCert->ShowModal();
delete frameSSLCert;
AccType.clear();
}
+
+#endif
}
}
-void frmMain::SetupSSLStatus( int AccountID ){
-
- // Check if account ID given is
- // the active account and if not, do nothing.
-
- wxString AccType;
- wxString AccTypeLower;
+void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
- AccType = prefaccounts.GetAccountType(AccountID);
- AccTypeLower = AccType.MakeLower();
+ // Display the form for showing an invalid SSL certificate.
- wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
- AccTypeLower;
+ frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this );
+ SSLInvalidCertNotifObj *SSLICNObj = (SSLInvalidCertNotifObj*)event.GetClientData();
+ SSLCertCollection SSLCCData = SSLICNObj->CertCollection;
+ wxString AccountName = SSLICNObj->AccountName;
+ frameISC->LoadData(SSLCCData, AccountName);
+ frameISC->ShowModal();
- if (AccountIDName != ActiveAccount){
-
- return;
-
- }
+ int FinalConflictResult = frameISC->GetResult();
- // Check if the account has SSL enabled.
+ wxCommandEvent event2(ACTMGR_RESUMEPROC);
+ event2.SetClientData(SSLICNObj->QRNotifData);
+ event2.SetInt(FinalConflictResult);
- bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
+ delete frameISC;
+ frameISC = NULL;
- if (SSLInUse == FALSE){
-
- SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
- imgSSLStatus->SetBitmap(*imgNoSSL);
-
- } else {
-
- // Get the SSL Collection Data.
-
- std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
-
- if (SSLResultIter->second == 1){
-
- imgSSLStatus->SetBitmap(*imgSSLWarning);
- SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") +
- prefaccounts.GetAccountName(AccountID) +
- wxT("' (Connection denied by user)\n\nDouble click for more information."));
-
- } else if (SSLResultIter->second == 0){
-
- imgSSLStatus->SetBitmap(*imgSSL);
- SSLToolTip->SetTip(wxT("Account '") +
- prefaccounts.GetAccountName(AccountID) +
- wxT("' secured using SSL\n\nDouble click for more information."));
-
- }
+ frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
+ wxPostEvent(frameActMgr, event2);
- }
-
}
-void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
+void frmMain::InvalidSSLCertificateString( wxCommandEvent &event ){
// Display the form for showing an invalid SSL certificate.
frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this );
- SSLInvalidCertNotifObj *SSLICNObj = (SSLInvalidCertNotifObj*)event.GetClientData();
- SSLCertCollection SSLCCData = SSLICNObj->CertCollection;
+ SSLInvalidCertNotifObjString *SSLICNObj = (SSLInvalidCertNotifObjString*)event.GetClientData();
+ SSLCertCollectionString SSLCCData = SSLICNObj->CertCollection;
wxString AccountName = SSLICNObj->AccountName;
frameISC->LoadData(SSLCCData, AccountName);
frameISC->ShowModal();
frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
wxPostEvent(frameActMgr, event2);
+
}
void frmMain::PauseAllTimers(){
}
-void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
+#if defined(__APPLE__)
+
+#elif defined(__WIN32__)
+
+void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, PCCERT_CONTEXT CertificateContext){
+
+ // Delete existing data.
+
+ std::map<int, PCCERT_CONTEXT>::iterator CertificateIter = AccountCertificateData.find(AccountID);
+
+ if (CertificateIter != AccountCertificateData.end()){
+ CertFreeCertificateContext(CertificateIter->second);
+ }
+
+ AccountCertificateData.erase(AccountID);
+ AccountSSLResult.erase(AccountID);
+
+ // Insert new data.
+
+ AccountCertificateData.insert(std::make_pair(AccountID, CertificateContext));
+ AccountSSLResult.insert(std::make_pair(AccountID, SSLStatus));
+
+}
+
+#else
+
+void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollectionString SSLCertInc){
// Delete existing data.
}
+#endif
+
+void frmMain::SetupSSLStatus( int AccountID ){
+
+ // Check if account ID given is
+ // the active account and if not, do nothing.
+
+ wxString AccType;
+ wxString AccTypeLower;
+
+ AccType = prefaccounts.GetAccountType(AccountID);
+ AccTypeLower = AccType.MakeLower();
+
+ wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
+ AccTypeLower;
+
+ if (AccountIDName != ActiveAccount){
+
+ return;
+
+ }
+
+ // Check the account type is a supported account type.
+
+ if (AccType != "CardDAV" && AccType != "carddav" &&
+ AccType != "Local" && AccType != "local"){
+
+ SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
+ imgSSLStatus->SetBitmap(*imgNoSSL);
+ return;
+
+ }
+
+ // Check if the account has SSL enabled.
+
+ bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
+
+ if (SSLInUse == FALSE){
+
+ SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
+ imgSSLStatus->SetBitmap(*imgNoSSL);
+
+ } else {
+
+ // Get the SSL Collection Data.
+
+ std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
+
+ // Check if a result value has been set.
+
+ if (SSLResultIter == AccountSSLResult.end()){
+
+ imgSSLStatus->SetBitmap(*imgSSLWarning);
+ SSLToolTip->SetTip(wxT("Unable to determine SSL information for the '") + prefaccounts.GetAccountName(AccountID) + wxT("' account."));
+ return;
+
+ }
+
+ if (SSLResultIter->second == 1){
+
+ imgSSLStatus->SetBitmap(*imgSSLWarning);
+ SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") +
+ prefaccounts.GetAccountName(AccountID) +
+ wxT("' (Connection denied by user)\n\nDouble click for more information."));
+
+ } else if (SSLResultIter->second == 0){
+
+ imgSSLStatus->SetBitmap(*imgSSL);
+ SSLToolTip->SetTip(wxT("Account '") +
+ prefaccounts.GetAccountName(AccountID) +
+ wxT("' secured using SSL\n\nDouble click for more information."));
+
+ }
+
+ }
+
+}
+
void frmMain::CheckUpdates( wxCommandEvent& event ){
// Check for updates to Xestia Address Book.
bool EnableRefresh = FALSE;
- if (!ActiveAccount.IsEmpty()){
+ if (!ActiveAccount.IsEmpty() && (ActiveAccountType == "CardDAV" ||
+ ActiveAccountType == "carddav" ||
+ ActiveAccountType == "Local" ||
+ ActiveAccountType == "local")){
EnableRefresh = TRUE;
htmContactData->SetPage(EmptyPage);
AccCtrl->SetValue("");
-}
\ No newline at end of file
+}
+
+bool frmMain::CloseAllWindows()
+{
+ // Attempt to close all windows.
+
+ if (WindowListPointersMenu.size() == 0)
+ {
+ return true;
+ }
+
+ if (wxMessageBox(_("Before preforming the action, all windows that are open will need to close. Do you wish to continue?"), _("Close All Windowss"), wxYES_NO) == wxYES)
+ {
+ for(std::map<int, void*>::iterator windowIter = WindowListPointers.begin();
+ windowIter != WindowListPointers.end(); windowIter++)
+ {
+ wxWindow *windowPointer = static_cast<wxWindow*>(windowIter->second);
+ windowPointer->Close();
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}