From 4ea07d6964c0f73c858e83513e14a28000054256 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 30 Nov 2015 12:45:45 +0000 Subject: [PATCH] Updated header location and moved parts of frmSearch into 4 smaller C++ files. --- source/Makefile.in | 4 +- source/frmMain.cpp | 2 +- source/main.cpp | 2 +- source/search/XABSearchPanel.h | 2 +- source/search/frmSearch.cpp | 1278 +---------------------------- source/search/frmSearch.h | 10 +- source/widgets/XABContactMenu.cpp | 2 +- 7 files changed, 38 insertions(+), 1262 deletions(-) diff --git a/source/Makefile.in b/source/Makefile.in index eaa76ad..da178fc 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -84,7 +84,9 @@ COMMONOBJS=common/base64.o common/preferences.o common/getcontactinfo.o \ IMEXOBJS=import/import.o import/import-vcard3.o import/import-vcard4.o \ import/frmImportContacts.o import/frmImportResults.o \ export/export.o export/export-vcard3.o export/export-vcard4.o -SEARCHOBJS=search/XABSearchPanel.o search/frmSearchAccounts.o frmSearch.o +SEARCHOBJS=search/XABSearchPanel.o search/frmSearchAccounts.o search/frmSearch.o \ + search/frmSearch-result.o search/frmSearch-contact.o \ + search/frmSearch-process.o VCARDOBJS=vcard/vcard.o vcard/vcard34conv.o vcard/vcard34conv-v3conv.o \ vcard/vcard34conv-v4conv.o ACTMGROBJS=actmgr/frmActivityMgr.o actmgr/frmActivityMgr-tasks.o diff --git a/source/frmMain.cpp b/source/frmMain.cpp index 0500383..155d500 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -43,7 +43,7 @@ #include "frmContact.h" #include "frmConflictResolution.h" #include "frmInvalidSSLCertificate.h" -#include "frmSearch.h" +#include "search/frmSearch.h" #include "frmSSLCertificate.h" #include "frmUpdate.h" #include "import/frmImportResults.h" diff --git a/source/main.cpp b/source/main.cpp index 51255f4..a5b8ae6 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -31,7 +31,7 @@ #include "bitmaps.h" #include "version.h" #include "actmgr/frmActivityMgr.h" -#include "frmSearch.h" +#include "search/frmSearch.h" #include "common/timers.h" #include "common/defaults.h" #include "common/dirs.h" diff --git a/source/search/XABSearchPanel.h b/source/search/XABSearchPanel.h index 3b030ca..6b524b2 100644 --- a/source/search/XABSearchPanel.h +++ b/source/search/XABSearchPanel.h @@ -25,7 +25,7 @@ Subclass of XABSearchPanelADT, which is generated by wxFormBuilder. */ #include "../AppXestiaAddrBk.h" -#include "../frmSearch.h" +#include "frmSearch.h" //// end generated include diff --git a/source/search/frmSearch.cpp b/source/search/frmSearch.cpp index 542b646..b4b8104 100644 --- a/source/search/frmSearch.cpp +++ b/source/search/frmSearch.cpp @@ -1,16 +1,30 @@ +// frmSearch.cpp - Search form. +// +// (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 + #include "frmSearch.h" -#include "frmMain.h" -#include "frmContact.h" -#include "search/XABSearchPanel.h" -#include "search/frmSearchAccounts.h" -#include "common/preferences.h" -#include "common/dirs.h" -#include "vcard/vcard.h" +#include "../frmMain.h" +#include "../frmContact.h" +#include "frmSearchAccounts.h" +#include "../common/preferences.h" +#include "../common/dirs.h" +#include "../vcard/vcard.h" #include -#include -#include -#include DEFINE_EVENT_TYPE(SE_ADDSEARCHSETTING); DEFINE_EVENT_TYPE(SE_REMOVESEARCHSETTING); @@ -116,894 +130,6 @@ void frmSearch::SelectAccounts( wxCommandEvent& event ) } -void frmSearch::SearchContactsThread(){ - - // Go through each account and find contacts based on the - // matched settings. - - std::map::iterator SAiter; - std::map::iterator SAPiter; - int intResultFound = 0; - - for (std::map::iterator SALiter = SearchAccountsNames.begin(); - SALiter != SearchAccountsNames.end(); - SALiter++){ - - // Double check that we are searching in this account. - // If not, skip to the next one. - - SAiter = SearchAccounts.find(SALiter->first); - SAPiter = SearchAccountsPaths.find(SAiter->first); - - - if (SAiter->second == FALSE){ - - // Not looking in this account. Go to next account. - - continue; - - } - - wxCommandEvent sbupdate (SE_SBUPDATE); - - wxString *SBData = new wxString; - *SBData = _("Searching ") + SALiter->second + _("..."); - - sbupdate.SetClientData(SBData); - wxPostEvent(this, sbupdate); - - if (StopMode == FALSE){ - - wxCommandEvent sbstop (SE_SBUPDATE); - - wxString *SBStopStr = new wxString; - *SBStopStr = _("Search stopped."); - - sbstop.SetClientData(SBStopStr); - wxPostEvent(this, sbstop); - return; - - } - - // Get the list of contact files and process each - // one of them. - - wxString AccountDir = GetAccountDir(SAPiter->second, FALSE); - - wxString vcardfilenamewxs; - wxStringTokenizer vcardfileline; - wxString lwxs; - wxString setname, setvalue; - long ContactIndex = 1; - long ContactSeekPoint = 0; - wxString vCardFilename; - wxString vCardFilenameFull; - - if (wxDirExists(AccountDir)){ - - wxDir vcardaccdir(AccountDir); - - bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES); - while(ProcFiles){ - - if (StopMode == FALSE){ - - wxCommandEvent sbstop(SE_SBUPDATE); - - wxString *SBStopStr = new wxString; - *SBStopStr = _("Search stopped."); - - sbstop.SetClientData(SBStopStr); - wxPostEvent(this, sbstop); - return; - - } - - if (vCardFilename.Right(4) == wxT(".vcf") || - vCardFilename.Right(4) == wxT(".VCF") || - vCardFilename.Right(5) == wxT(".vcard") || - vCardFilename.Right(5) == wxT(".VCARD")){ - - vCard Person; - vCardFilenameFull.Append(AccountDir); - vCardFilenameFull.Append(vCardFilename); - - Person.LoadFile(vCardFilenameFull); - - vcardfilenamewxs = vCardFilenameFull; - - // Check if file has version 4.0, first name (FN) - // begin and end vCard portions. - - // Don't search unless these conditions have been met. - - if (Person.MeetBaseSpecification()){ - - // Go through each of the search settings and check - // if they match with contact details. - - // If it matches then add to the search results. - - int SelOpt = 0; - bool chkOpt = FALSE; - wxString StrOpt; - int StrOptLen = 0; - ArrayvCardOutData ArrayData; - ArrayvCardOutData NicknameArrayData; - vCardName NameArray = Person.GetName(); - wxString ContactFinalNickname; - NicknameArrayData = Person.GetByPartial(wxT("NICKNAME")); - - if (NicknameArrayData.PropCount != 0){ - ContactFinalNickname = NicknameArrayData.PropValues[0]; - } - - for (std::map::iterator siter = SearchFrames.begin(); - siter != SearchFrames.end(); siter++){ - - // Get the settings from the form. - - XABSearchPanel *XABSPPtr = static_cast(siter->second); - - // Get Selected Option and Setting. - - SelOpt = XABSPPtr->GetSelectionOption(); - - if (SelOpt < 12){ - - StrOpt = XABSPPtr->GetStringSetting(); - StrOptLen = StrOpt.Len(); - - if (SelOpt == 0 || SelOpt == 4 || SelOpt == 8){ - - // Matching string that beings with... - - // Double check the std::map inserts for each section. - - if (SelOpt == 0){ - - // Get the forename from the first N. - - if (NameArray.Forename.Mid(0, StrOptLen) == StrOpt){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 4){ - - if (NameArray.Surname.Mid(0, StrOptLen) == StrOpt){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 8){ - - wxString NicknameData; - - for (int i = 0; i < NicknameArrayData.PropCount; i++){ - - NicknameData = NicknameArrayData.PropValues[i]; - - if (NicknameData.Mid(0, StrOptLen) == StrOpt){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - break; - - } - - } - - } - - } else if (SelOpt == 1 || SelOpt == 5 || SelOpt == 9){ - - // Matching string that ends with... - - if (SelOpt == 1){ - - // Check the forename. - - if (NameArray.Forename.Right(StrOptLen) == StrOpt){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 5){ - - if (NameArray.Surname.Right(StrOptLen) == StrOpt){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 9){ - - wxString NicknameData; - - for (int i = 0; i < NicknameArrayData.PropCount; i++){ - - NicknameData = NicknameArrayData.PropValues[i]; - NicknameData.Trim(); - - if (NicknameData.Right(StrOptLen) == StrOpt){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - break; - - } - - } - - } - - } else if (SelOpt == 2 || SelOpt == 6 || SelOpt == 10){ - - // Matching string that contains... - - if (SelOpt == 2){ - - if (NameArray.Forename.Find(StrOpt) != wxNOT_FOUND){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 6){ - - if (NameArray.Surname.Find(StrOpt) != wxNOT_FOUND){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 10){ - - wxString NicknameData; - - for (int i = 0; i < NicknameArrayData.PropCount; i++){ - - NicknameData = NicknameArrayData.PropValues[i]; - NicknameData.Trim(); - - if (NicknameData.Find(StrOpt) != wxNOT_FOUND){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - break; - - } - - } - - } - - } else if (SelOpt == 3 || SelOpt == 7 || SelOpt == 11){ - - // Matching String that doesn't contain... - - if (SelOpt == 3){ - - // Process the nickname data. - - if (NameArray.Forename.Find(StrOpt) == wxNOT_FOUND){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 7){ - - if (!NameArray.Surname.Find(StrOpt) == wxNOT_FOUND){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 11){ - - wxString NicknameData; - - for (int i = 0; i < NicknameArrayData.PropCount; i++){ - - NicknameData = NicknameArrayData.PropValues[i]; - NicknameData.Trim(); - - if (NicknameData.Find(StrOpt) == wxNOT_FOUND){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - break; - - } - - } - - } - - } - - } else { - - chkOpt = XABSPPtr->GetCheckboxSetting(); - - if (SelOpt == 12){ - - // Search should check if it has a photo or not. - - ArrayData = Person.GetByPartial(wxT("PHOTO")); - - if ((ArrayData.PropCount >= 1 && - chkOpt == TRUE) || - (ArrayData.PropCount == 0 && - chkOpt == FALSE)){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 13){ - - // Search should check if it has a logo or not. - - ArrayData = Person.GetByPartial(wxT("LOGO")); - - if ((ArrayData.PropCount >= 1 && - chkOpt == TRUE) || - (ArrayData.PropCount == 0 && - chkOpt == FALSE)){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } else if (SelOpt == 14){ - - // Search should check if it has sound or not. - - ArrayData = Person.GetByPartial(wxT("SOUND")); - - if ((ArrayData.PropCount >= 1 && - chkOpt == TRUE) || - (ArrayData.PropCount == 0 && - chkOpt == FALSE)){ - - if (CheckDuplicate(vcardfilenamewxs, - SAPiter->second, - &SearchResultAccount, - &SearchResultFilename) == TRUE){ - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - continue; - - } - - SRNotif *sradd = new SRNotif; - - sradd->ContactName = NameArray; - sradd->ContactNickname = ContactFinalNickname; - sradd->ContactAccount = SAPiter->second; - sradd->ContactAccountName = SALiter->second; - sradd->ContactFullFilename = vcardfilenamewxs; - sradd->SearchResultID = intResultFound; - - SearchResultAccount.insert(std::make_pair(sradd->SearchResultID, sradd->ContactAccount)); - SearchResultFilename.insert(std::make_pair(sradd->SearchResultID, sradd->ContactFullFilename)); - - intResultFound++; - - wxCommandEvent sraddenv(SE_ADDRESULT); - sraddenv.SetClientData(sradd); - wxPostEvent(this, sraddenv); - - } - - } - - } - - SelOpt = 0; - chkOpt = FALSE; - StrOpt.Clear(); - StrOptLen = 0; - ArrayData.PropData.Clear(); - ArrayData.PropValues.Clear(); - ArrayData.PropCount = 0; - - } - - } else { - - } - - } - - vCardFilename.Clear(); - vCardFilenameFull.Clear(); - ProcFiles = vcardaccdir.GetNext(&vCardFilename); - - } - - } else { - - } - - } - - // Finished searching... clear up. - - wxCommandEvent sbfinstr (SE_SBUPDATE); - - wxString *SBFinish = new wxString; - - if (intResultFound == 0){ - - *SBFinish = _("No contacts found."); - - } else if (intResultFound == 1){ - - *SBFinish = _("1 contact found."); - - } else { - - *SBFinish = wxString::Format(wxT("%i"), intResultFound) + _(" contacts found."); - - } - - sbfinstr.SetClientData(SBFinish); - wxPostEvent(this, sbfinstr); - - wxCommandEvent sbfinish (SE_SEARCHFINISHED); - wxPostEvent(this, sbfinish); - -} - void frmSearch::SearchContacts( wxCommandEvent& event ) { @@ -1207,68 +333,6 @@ void frmSearch::ReloadAccountList( wxCommandEvent& event ){ } -void frmSearch::AddResult( wxCommandEvent& event ){ - - SRNotif *srnotif = (SRNotif*)event.GetClientData(); - - // Process Data and add to the list of results. - - wxListItem item; - - // Setup the contact name. - - wxString ContactNameFinal; - - if (!srnotif->ContactName.Title.IsEmpty()){ - - ContactNameFinal.append(srnotif->ContactName.Title); - ContactNameFinal.Trim(); - ContactNameFinal.append(wxT(" ")); - - } - - if (!srnotif->ContactName.Forename.IsEmpty()){ - - ContactNameFinal.append(srnotif->ContactName.Forename); - ContactNameFinal.Trim(); - ContactNameFinal.append(wxT(" ")); - - } - - if (!srnotif->ContactName.Surname.IsEmpty()){ - - ContactNameFinal.append(srnotif->ContactName.Surname); - ContactNameFinal.Trim(); - ContactNameFinal.append(wxT(" ")); - - } - - if (!srnotif->ContactName.Suffix.IsEmpty()){ - - ContactNameFinal.append(srnotif->ContactName.Suffix); - ContactNameFinal.Trim(); - - } - - item.SetId(0); - item.SetText(ContactNameFinal); - item.SetData(srnotif->SearchResultID); - - long ListCtrlIndex = lstResults->InsertItem(item); - - //SearchResultAccount.insert(std::make_pair(srnotif->SearchResultID, srnotif->ContactAccount)); - //SearchResultFilename.insert(std::make_pair(srnotif->SearchResultID, srnotif->ContactFullFilename)); - - srnotif->ContactNickname.Trim(); - - lstResults->SetItem(ListCtrlIndex, 1, srnotif->ContactNickname); - lstResults->SetItem(ListCtrlIndex, 2, srnotif->ContactAccountName); - - delete srnotif; - srnotif = NULL; - -} - void frmSearch::SearchBarUpdate( wxCommandEvent& event ){ wxString *SBData = (wxString*)event.GetClientData(); @@ -1311,121 +375,6 @@ void frmSearch::DisableAllSearchSettings(bool Enable){ } -void frmSearch::OpenContact( wxCommandEvent& event ){ - - // Check if a contact has been selected. - - long intSelected = -1; - int intSelectedData = 0; - long intContactSeekNum = -1; - - intSelected = lstResults->GetNextItem(intSelected, - wxLIST_NEXT_ALL, - wxLIST_STATE_SELECTED); - - if (intSelected == -1){ - return; - } - - intContactSeekNum = lstResults->GetItemData(intSelected); - - if (SearchMode == TRUE){ - - wxMessageBox(SearchResultFilename[intContactSeekNum]); - - vCard Person; - - Person.LoadFile(SearchResultFilename[intContactSeekNum]); - - wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png)); - wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG); - wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1); - wxIcon contacticon; - contacticon.CopyFromBitmap(contacticonbmp); - - frmContact *Contact = new frmContact( this ); - - Contact->SetupPointers(&SearchModeMemoryFSPtr); - Contact->SetupContactData(&Person); - - Contact->SetIcon(contacticon); - Contact->Show(true); - - } else { - - UCNotif *uc = new UCNotif; - - uc->ContactAccount = SearchResultAccount[intContactSeekNum]; - uc->ContactFilename = SearchResultFilename[intContactSeekNum]; - - wxCommandEvent oc(CE_OPENCONTACT); - oc.SetClientData(uc); - wxPostEvent(this->GetParent(), oc); - - } - -} - -void frmSearch::EditContact( wxCommandEvent& event ){ - - // Check if a contact has been selected. - - long intSelected = -1; - int intSelectedData = 0; - long intContactSeekNum = -1; - - intSelected = lstResults->GetNextItem(intSelected, - wxLIST_NEXT_ALL, - wxLIST_STATE_SELECTED); - - if (intSelected == -1){ - return; - } - - intContactSeekNum = lstResults->GetItemData(intSelected); - - UCNotif *uc = new UCNotif; - - uc->ContactAccount = SearchResultAccount[intContactSeekNum]; - uc->ContactFilename = SearchResultFilename[intContactSeekNum]; - - wxCommandEvent ec(CE_EDITCONTACT); - ec.SetClientData(uc); - ec.SetInt(1); - wxPostEvent(this->GetParent(), ec); - -} - -void frmSearch::RevealContact( wxCommandEvent& event ){ - - // Check if a contact has been selected. - - long intSelected = -1; - int intSelectedData = 0; - long intContactSeekNum = -1; - - intSelected = lstResults->GetNextItem(intSelected, - wxLIST_NEXT_ALL, - wxLIST_STATE_SELECTED); - - if (intSelected == -1){ - return; - } - - intContactSeekNum = lstResults->GetItemData(intSelected); - - UCNotif *uc = new UCNotif; - - uc->ContactAccount = SearchResultAccount[intContactSeekNum]; - uc->ContactFilename = SearchResultFilename[intContactSeekNum]; - - wxCommandEvent rc(CE_REVEALCONTACT); - rc.SetClientData(uc); - rc.SetInt(1); - wxPostEvent(this->GetParent(), rc); - -} - void frmSearch::CloseWindow( wxCloseEvent& event ){ // Hide the window so users don't panic @@ -1479,177 +428,6 @@ void frmSearch::CloseWindow( wxCommandEvent& event ){ } -void frmSearch::UpdateResult( wxCommandEvent& event ){ - - UCNotif *uc = (UCNotif*)event.GetClientData(); - - long longSelected = -1; - int intSelectedData = 0; - - for (;;){ - - longSelected = lstResults->GetNextItem(longSelected, - wxLIST_NEXT_ALL, - wxLIST_STATE_DONTCARE); - - if (longSelected == -1){ - - break; - - } - - // Get the filename/ID information. - - intSelectedData = lstResults->GetItemData(longSelected); - - if (uc->ContactFilename == SearchResultFilename[intSelectedData]){ - - // Process the contact name - - wxString ContactNameFinal; - - if (!uc->ContactNameArray.Title.IsEmpty()){ - - ContactNameFinal.append(uc->ContactNameArray.Title); - ContactNameFinal.Trim(); - ContactNameFinal.append(wxT(" ")); - - } - - if (!uc->ContactNameArray.Forename.IsEmpty()){ - - ContactNameFinal.append(uc->ContactNameArray.Forename); - ContactNameFinal.Trim(); - ContactNameFinal.append(wxT(" ")); - - } - - if (!uc->ContactNameArray.Surname.IsEmpty()){ - - ContactNameFinal.append(uc->ContactNameArray.Surname); - ContactNameFinal.Trim(); - ContactNameFinal.append(wxT(" ")); - - } - - if (!uc->ContactNameArray.Suffix.IsEmpty()){ - - ContactNameFinal.append(uc->ContactNameArray.Suffix); - ContactNameFinal.Trim(); - - } - - lstResults->SetItem(longSelected, 0, ContactNameFinal); - lstResults->SetItem(longSelected, 1, uc->ContactNickname); - - } - - } - - delete uc; - uc = NULL; - -} - -bool frmSearch::CheckDuplicate(wxString Filename, - wxString Account, - std::map *SRAcc, - std::map *SRFN){ - - std::map::iterator fniter; - - // Check comparison code. - - for (std::map::iterator aciter = SRAcc->begin(); - aciter != SRAcc->end(); aciter++){ - - fniter = SRFN->find(aciter->first); - - if (Filename == fniter->second && - Account == aciter->second){ - - return TRUE; - - } - - } - - return FALSE; - -} - -void frmSearch::DeleteResult(wxCommandEvent &event){ - - UCNotif *uc = (UCNotif*)event.GetClientData(); - - long longSelected = -1; - int intSelectedData = 0; - - for (;;){ - - longSelected = lstResults->GetNextItem(longSelected, - wxLIST_NEXT_ALL, - wxLIST_STATE_DONTCARE); - - if (longSelected == -1){ - - break; - - } - - // Get the filename/ID information. - - intSelectedData = lstResults->GetItemData(longSelected); - - if (uc->ContactFilename == SearchResultFilename[intSelectedData]){ - - // Delete the result from the search list and - // update the total search results. - - // Remove DeleteResultEvent and find out where the uc - // data is still being used as it crashes on delete. - - lstResults->DeleteItem(longSelected); - - // Update the number of search results. - - wxCommandEvent sbu(SE_SBUPDATE); - wxString *SBUpdate = new wxString; - - // Get the number of results. - - int intResultFound = lstResults->GetItemCount(); - - // Prepare the status bar message. - - if (intResultFound == 0){ - - *SBUpdate = _("No contacts found."); - - } else if (intResultFound == 1){ - - *SBUpdate = _("1 contact found."); - - } else { - - *SBUpdate = wxString::Format(wxT("%i"), intResultFound) + _(" contacts found."); - - } - - sbu.SetClientData(SBUpdate); - wxPostEvent(this, sbu); - - break; - - } - - } - - delete uc; - uc = NULL; - -} - void frmSearch::SetUID(int UID){ SearchUID = UID; @@ -1699,12 +477,4 @@ void frmSearch::SetSearchMode(bool SearchModeIn){ } -} - -void frmSearch::ShowContactMenu( wxMouseEvent& event ){ - - ContactMenu->SetupPointers(this, lstResults); - - PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition); - } \ No newline at end of file diff --git a/source/search/frmSearch.h b/source/search/frmSearch.h index 305ccb0..63abb01 100644 --- a/source/search/frmSearch.h +++ b/source/search/frmSearch.h @@ -24,11 +24,15 @@ Subclass of frmSearchADT, which is generated by wxFormBuilder. */ -#include "AppXestiaAddrBk.h" -#include "vcard/vcard.h" -#include "widgets/XABContactMenu.h" +#include "../AppXestiaAddrBk.h" +#include "../vcard/vcard.h" +#include "../widgets/XABContactMenu.h" +#include "XABSearchPanel.h" #include +#include +#include +#include //// end generated include diff --git a/source/widgets/XABContactMenu.cpp b/source/widgets/XABContactMenu.cpp index 5e75103..fc3f59a 100644 --- a/source/widgets/XABContactMenu.cpp +++ b/source/widgets/XABContactMenu.cpp @@ -18,7 +18,7 @@ #include "XABContactMenu.h" #include "../frmMain.h" -#include "../frmSearch.h" +#include "../search/frmSearch.h" enum { ID_CONTACTMENU_OPEN, -- 2.39.5