+// frmSearch-process.cpp - Search process subroutines.
+//
+// (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 <http://www.gnu.org/licenses/>
+
+#include "frmSearch.h"
+#include "../common/preferences.h"
+#include "../common/dirs.h"
+#include "../vcard/vcard.h"
+
+void frmSearch::SearchContactsThread(){
+
+ // Go through each account and find contacts based on the
+ // matched settings.
+
+ std::map<wxString,bool>::iterator SAiter;
+ std::map<wxString,wxString>::iterator SAPiter;
+ int intResultFound = 0;
+
+ for (std::map<wxString, wxString>::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<int, void*>::iterator siter = SearchFrames.begin();
+ siter != SearchFrames.end(); siter++){
+
+ // Get the settings from the form.
+
+ XABSearchPanel *XABSPPtr = static_cast<XABSearchPanel*>(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);
+
+}
\ No newline at end of file