1 // frmContactEditor-Load.cpp - frmContactEditor load contact subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
22 #include <wx/tokenzr.h>
23 #include <wx/datetime.h>
26 #include "frmContactEditor.h"
29 #include "../version.h"
30 #include "../vcard/vcard.h"
31 #include "../common/textprocessing.h"
32 #include "../common/dirs.h"
33 #include "cdo/ContactDataObject.h"
35 bool frmContactEditor::LoadContact(wxString Filename){
37 // Load the contact into the contact editor.
40 wxString wxSContactString;
44 if (StartupEditMode == FALSE){
45 XVMData = MainPtr->GetViewMode();
48 wxSContactFilename = Filename;
50 // Check if we are using wxWidgets version 2.8 or less and
51 // execute the required command accordingly.
53 #if wxABI_VERSION < 20900
54 ContactFile.Open(Filename.c_str(), wxT("r"));
56 ContactFile.Open(Filename, wxT("r"));
59 if (ContactFile.IsOpened() == FALSE){
65 ContactEditorData.LoadFile(Filename);
67 ContactFile.ReadAll(&wxSContactString, wxConvAuto());
71 std::map<int, wxString> ContactFileLines;
72 std::map<int, wxString>::iterator striter;
74 wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
76 int ContactLineSeek = 0;
78 while (wSTContactFileLines.HasMoreTokens() == TRUE){
80 ContactLine = wSTContactFileLines.GetNextToken();
81 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
87 ContactLoadStatus LoadResult = ContactEditorData.LoadFile(Filename);
93 case CONTACTLOAD_FILEMISSING:
94 wxMessageBox(_("The file with the filename given does not exist."),
95 _("Contact not found"), wxICON_ERROR);
99 case CONTACTLOAD_FILEERROR:
100 wxMessageBox(_("The file with the filename given cannot be opened due to an error while trying open it."),
101 _("Error loading contact"), wxICON_ERROR);
105 case CONTACTLOAD_FILEINVALIDFORMAT:
106 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
107 _("Contact not supported"), wxICON_ERROR);
111 case CONTACTLOAD_FILEBASESPECFAIL:
112 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
113 _("Contact not supported"), wxICON_ERROR);
122 bool QuoteMode = FALSE;
123 bool PropertyFind = TRUE;
124 bool HasExtraNicknames = FALSE;
125 bool IgnoreGender = FALSE;
126 bool ExtraLineSeek = TRUE;
127 //bool BirthdayProcessed = FALSE;
128 //bool AnniversaryProcessed = FALSE;
129 bool FNProcessed = FALSE;
130 bool GenderProcessed = FALSE;
131 bool NameProcessed = FALSE;
132 //bool UIDProcessed = FALSE;
133 //bool KindProcessed = FALSE;
134 bool ETagFound = FALSE;
135 bool ETagOrigFound = FALSE;
136 bool VersionProcessed = FALSE;
137 int intExtraNickname = 0;
138 wxString wxSProperty;
139 wxString wxSPropertySeg1;
140 wxString wxSPropertySeg2;
141 wxString wxSPropertyNextLine;
142 size_t ContactLineLen = 0;
143 int QuoteBreakPoint = 0;
146 int NicknameCount = 0;
155 int RelatedCount = 0;
160 int CategoryCount = 0;
166 int CalReqAdrCount = 0;
167 int FreeBusyCount = 0;
171 //int intValueSeek = 1;
173 // Process the unique ID (UID)
175 // Do nothing at the moment.
177 // Process the contact type (KIND) (frmContactEditor-LoadGroup.cpp)
179 LoadKind(&ContactEditorData.ContactKind);
181 // Process the Birthday (BDAY) (frmContactEditor-LoadBADays.cpp)
183 LoadBirthday(&ContactEditorData.Birthday, &ContactEditorData.BirthdayText);
185 // Process the Anniversary (ANNIVERSARY) (frmContactEditor-LoadBADays.cpp)
187 LoadAnniversary(&ContactEditorData.Anniversary, &ContactEditorData.AnniversaryText);
189 // Process the Gender (GENDER) (frmContactEditor-LoadGender.cpp)
191 LoadGender(&ContactEditorData.Gender, &ContactEditorData.GenderDetails);
193 // Process the Name (N) (frmContactEditor-LoadName.cpp)
195 LoadName(&ContactEditorData.NameTitle, &ContactEditorData.NameForename,
196 &ContactEditorData.NameSurname, &ContactEditorData.NameOtherNames,
197 &ContactEditorData.NameSuffix);
199 // Process the group members (MEMBER) (frmContactEditor-LoadGroup.cpp)
201 LoadMember(&ContactEditorData.GroupsList);
203 // Process the addresses (ADR) (frmContactEditor-LoadAddress.cpp)
205 LoadAddress(&ContactEditorData.GeneralAddressList,
206 &ContactEditorData.GeneralAddressListTown,
207 &ContactEditorData.GeneralAddressListCounty,
208 &ContactEditorData.GeneralAddressListPostCode,
209 &ContactEditorData.GeneralAddressListPref,
210 &ContactEditorData.HomeAddressList,
211 &ContactEditorData.HomeAddressListTown,
212 &ContactEditorData.HomeAddressListCounty,
213 &ContactEditorData.HomeAddressListPostCode,
214 &ContactEditorData.HomeAddressListPref,
215 &ContactEditorData.BusinessAddressList,
216 &ContactEditorData.BusinessAddressListTown,
217 &ContactEditorData.BusinessAddressListCounty,
218 &ContactEditorData.BusinessAddressListPostCode,
219 &ContactEditorData.BusinessAddressListPref,
222 // Process the timezones (TZ).
224 LoadData(&ContactEditorData.GeneralTZList,
225 &ContactEditorData.GeneralTZListPref,
227 &ContactEditorData.HomeTZList,
228 &ContactEditorData.HomeTZListPref,
230 &ContactEditorData.BusinessTZList,
231 &ContactEditorData.BusinessTZListPref,
232 lboBusinessTimezones,
235 // Process the emails (EMAIL).
237 LoadData(&ContactEditorData.GeneralEmailList,
238 &ContactEditorData.GeneralEmailListPref,
240 &ContactEditorData.HomeEmailList,
241 &ContactEditorData.HomeEmailListPref,
243 &ContactEditorData.BusinessEmailList,
244 &ContactEditorData.BusinessEmailListPref,
248 // Process the nicknames (NICKNAME).
250 LoadData(&ContactEditorData.GeneralNicknamesList,
251 &ContactEditorData.GeneralNicknamesListPref,
253 &ContactEditorData.HomeNicknamesList,
254 &ContactEditorData.HomeNicknamesListPref,
256 &ContactEditorData.BusinessNicknamesList,
257 &ContactEditorData.BusinessNicknamesListPref,
258 lboBusinessNicknames,
261 // Process the languages (LANG).
263 LoadData(&ContactEditorData.GeneralLanguageList,
264 &ContactEditorData.GeneralLanguageListPref,
266 &ContactEditorData.HomeLanguageList,
267 &ContactEditorData.HomeLanguageListPref,
269 &ContactEditorData.BusinessLanguageList,
270 &ContactEditorData.BusinessLanguageListPref,
271 lboBusinessLanguages,
274 // Process the geopositiosn (GEO).
276 LoadData(&ContactEditorData.GeneralGeographyList,
277 &ContactEditorData.GeneralGeographyListPref,
279 &ContactEditorData.HomeGeographyList,
280 &ContactEditorData.HomeGeographyListPref,
282 &ContactEditorData.BusinessGeographyList,
283 &ContactEditorData.BusinessGeographyListPref,
284 lboBusinessGeoposition,
287 // Process the websites (URL).
289 LoadData(&ContactEditorData.GeneralWebsiteList,
290 &ContactEditorData.GeneralWebsiteListPref,
292 &ContactEditorData.HomeWebsiteList,
293 &ContactEditorData.HomeWebsiteListPref,
295 &ContactEditorData.BusinessWebsiteList,
296 &ContactEditorData.BusinessWebsiteListPref,
300 // Process the titles (TITLE).
302 LoadData(&ContactEditorData.GeneralTitleList,
303 &ContactEditorData.GeneralTitleListPref,
305 &ContactEditorData.HomeTitleList,
306 &ContactEditorData.HomeTitleListPref,
308 &ContactEditorData.BusinessTitleList,
309 &ContactEditorData.BusinessTitleListPref,
313 // Process the roles (ROLE).
315 LoadData(&ContactEditorData.GeneralRoleList,
316 &ContactEditorData.GeneralRoleListPref,
318 &ContactEditorData.HomeRoleList,
319 &ContactEditorData.HomeRoleListPref,
321 &ContactEditorData.BusinessRoleList,
322 &ContactEditorData.BusinessRoleListPref,
326 // Process the roles (ORG).
328 LoadData(&ContactEditorData.GeneralOrganisationsList,
329 &ContactEditorData.GeneralOrganisationsListPref,
331 &ContactEditorData.HomeOrganisationsList,
332 &ContactEditorData.HomeOrganisationsListPref,
333 lboHomeOrganisations,
334 &ContactEditorData.BusinessOrganisationsList,
335 &ContactEditorData.BusinessOrganisationsListPref,
336 lboBusinessOrganisations,
339 // Process the notes (NOTE).
341 LoadData(&ContactEditorData.GeneralNoteList,
342 &ContactEditorData.GeneralNoteListPref,
344 &ContactEditorData.HomeNoteList,
345 &ContactEditorData.HomeNoteListPref,
347 &ContactEditorData.BusinessNoteList,
348 &ContactEditorData.BusinessNoteListPref,
352 // Process the categories (CATEGORIES).
354 LoadData(&ContactEditorData.CategoriesList,
355 &ContactEditorData.CategoriesListPref,
359 // Process the telephone numbers (TEL).
361 LoadData(&ContactEditorData.GeneralTelephoneList,
362 &ContactEditorData.GeneralTelephoneListPref,
363 &ContactEditorData.GeneralTelephoneListTypeInfo,
365 &ContactEditorData.HomeTelephoneList,
366 &ContactEditorData.HomeTelephoneListPref,
367 &ContactEditorData.HomeTelephoneListTypeInfo,
369 &ContactEditorData.BusinessTelephoneList,
370 &ContactEditorData.BusinessTelephoneListPref,
371 &ContactEditorData.BusinessTelephoneListTypeInfo,
372 lboBusinessTelephone,
375 // Process the instant messaging (IMPP).
377 LoadData(&ContactEditorData.GeneralIMListTypeInfo,
378 &ContactEditorData.GeneralIMListPref,
379 &ContactEditorData.GeneralIMList,
381 &ContactEditorData.HomeIMListTypeInfo,
382 &ContactEditorData.HomeIMListPref,
383 &ContactEditorData.HomeIMList,
385 &ContactEditorData.BusinessIMListTypeInfo,
386 &ContactEditorData.BusinessIMListPref,
387 &ContactEditorData.BusinessIMList,
391 // Process the photos (PHOTO).
393 LoadPictureData("PHOTO",
394 &ContactEditorData.PicturesList,
395 &ContactEditorData.PicturesListPref,
396 &ContactEditorData.PicturesListType,
400 // Process the logos (LOGO).
402 LoadPictureData("LOGO",
403 &ContactEditorData.LogosList,
404 &ContactEditorData.LogosListPref,
405 &ContactEditorData.LogosListType,
409 // Process the sounds (SOUND).
411 LoadPictureData("SOUND",
412 &ContactEditorData.SoundsList,
413 &ContactEditorData.SoundsListPref,
414 &ContactEditorData.SoundsListType,
418 // Process the calendar addresses (CALURI).
421 &ContactEditorData.CalendarList,
422 &ContactEditorData.CalendarListPref,
423 &ContactEditorData.CalendarListType,
425 lboCalendarAddresses,
428 // Process the calendar request addresses (CALADRURI).
430 LoadData("CALADRURI",
431 &ContactEditorData.CalendarRequestList,
432 &ContactEditorData.CalendarRequestListPref,
433 &ContactEditorData.CalendarRequestListType,
435 lboCalendarRequestAddress,
438 // Process the free busy addresses (FBURL).
441 &ContactEditorData.FreeBusyList,
442 &ContactEditorData.FreeBusyListPref,
443 &ContactEditorData.FreeBusyListType,
445 lboFreeBusyAddresses,
448 // Process the keys. (KEY)
451 &ContactEditorData.KeyList,
452 &ContactEditorData.KeyListPref,
453 &ContactEditorData.KeyListType,
454 &ContactEditorData.KeyListDataType,
458 // Process the vendor specific information (VND-*).
460 LoadVendorData(&ContactEditorData.VendorListPEN,
461 &ContactEditorData.VendorListElement,
465 // Process the X-Tokens (X-*).
467 LoadXTokenData(&ContactEditorData.XTokenListTokens,
471 // Process the related people (RELATED).
473 LoadRelatedData(&ContactEditorData.GeneralRelatedList,
474 &ContactEditorData.GeneralRelatedListPref,
475 &ContactEditorData.GeneralRelatedListType,
479 // Process the full name (FN).
481 LoadData(&ContactEditorData.FullNamesList,
484 /*for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
485 iter != ContactFileLines.end(); ++iter){
487 // Find the colon which splits the start bit from the data part.
489 ContactLine = iter->second;
491 while (ExtraLineSeek == TRUE){
493 // Check if there is extra data on the next line
494 // (indicated by space or tab at the start) and add data.
498 if (iter == ContactFileLines.end()){
505 wxSPropertyNextLine = iter->second;
508 if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
510 wxSPropertyNextLine.Remove(0, 1);
511 //wxSPropertyNextLine.Trim(FALSE);
512 //ContactLine.Trim();
513 ContactLine.Append(wxSPropertyNextLine);
518 ExtraLineSeek = FALSE;
524 ContactLineLen = ContactLine.Len();
526 // Make sure we are not in quotation mode.
527 // Make sure colon does not have \ or \\ before it.
529 for (int i = 0; i <= ContactLineLen; i++){
531 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
533 PropertyFind = FALSE;
535 } else if (PropertyFind == TRUE){
537 wxSProperty.Append(ContactLine.Mid(i, 1));
541 if (ContactLine.Mid(i, 1) == wxT("\"")){
543 if (QuoteMode == TRUE){
555 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
564 // Split that line at the point into two variables (ignore the colon).
566 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
567 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
569 // Add the data into the contact editor depending on what it is.
571 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
573 // Check if version is 4.0, otherwise don't
576 if (wxSPropertySeg2 != wxT("4.0")){
577 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
578 _("Contact not supported"), wxICON_ERROR);
583 VersionProcessed = TRUE;
585 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
587 // See frmContactEditor-LoadGroup.cpp
589 LoadKind(wxSPropertySeg2);
591 }/* else if (wxSProperty == wxT("MEMBER")){
593 // See frmContactEditor-LoadGroup.cpp
595 LoadMember(wxSPropertySeg2, &GroupCount);
597 } else if (wxSProperty == wxT("FN")){
599 // See frmContactEditor-LoadName.cpp
601 LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
603 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
605 // See frmContactEditor-LoadName.cpp
607 LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
609 } else if (wxSProperty == wxT("NICKNAME")){
611 // See frmContactEditor-LoadNickname.cpp
613 LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
615 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
617 // See frmContactEditor-LoadGender.cpp
619 LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
621 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
623 // See frmContactEditor-LoadBADays.cpp
625 LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
627 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
629 // See frmContactEditor-LoadBADays.cpp
631 LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
633 } else if (wxSProperty == wxT("TZ")){
635 // See frmContactEditor-LoadTimeZone.cpp
637 LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);
639 } else if (wxSProperty == wxT("ADR")){
641 // See frmContactEditor-LoadAddress.cpp
643 LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
645 } else if (wxSProperty == wxT("EMAIL")){
647 // See frmContactEditor-LoadEmail.cpp
649 LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);
651 } else if (wxSProperty == wxT("IMPP")){
653 // See frmContactEditor-LoadIM.cpp
655 LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
657 }/* else if (wxSProperty == wxT("TEL")){
659 // See frmContactEditor-LoadTelephone.cpp
661 LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
663 } else if (wxSProperty == wxT("LANG")){
665 // See frmContactEditor-LoadLanguage.cpp
667 LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
669 } else if (wxSProperty == wxT("GEO")){
671 // See frmContactEditor-LoadGeo.cpp
673 LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);
675 } else if (wxSProperty == wxT("RELATED")){
677 // See fromContactEditor-LoadRelated.cpp
679 LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);
681 } else if (wxSProperty == wxT("URL")){
683 // See frmContactEditor-LoadURL.cpp
685 LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
687 } else if (wxSProperty == wxT("TITLE")) {
689 // See frmContactEditor-LoadTitle.cpp
691 LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
693 } else if (wxSProperty == wxT("ROLE")) {
695 // See frmContactEditor-LoadRole.cpp
697 LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
699 } else if (wxSProperty == wxT("ORG")) {
701 // See frmContactEditor-LoadOrg.cpp
703 LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
705 } else if (wxSProperty == wxT("NOTE")) {
707 // See frmContactEditor-LoadNote.cpp
709 LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount);
711 } else if (wxSProperty == wxT("CATEGORIES")) {
713 // See frmContactEditor-LoadCategory.cpp
715 LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount);
717 } else if (wxSProperty == wxT("PHOTO")) {
719 // See frmContactEditor-LoadPhoto.cpp
721 LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
723 } else if (wxSProperty == wxT("LOGO")) {
725 // See frmContactEditor-LoadLogo.cpp
727 LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
729 } else if (wxSProperty == wxT("SOUND")) {
731 // See frmContactEditor-LoadSound.cpp
733 LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
735 } else if (wxSProperty == wxT("CALURI")){
737 // See frmContactEditor-LoadCalendar.cpp
739 LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
741 } else if (wxSProperty == wxT("CALADRURI")){
743 // See frmContactEditor-LoadCalendar.cpp
745 LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
747 } else if (wxSProperty == wxT("FBURL")){
749 // See frmContactEditor-LoadCalendar.cpp
751 LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
753 } else if (wxSProperty == wxT("KEY")){
755 // See frmContactEditor-LoadKey.cpp
757 LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
759 } else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
761 UIDToken = wxSPropertySeg2;
764 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
766 // Split the Vendor three ways.
768 wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
771 wxString wxSVNDPropName;
774 while (wSTVendorDetails.HasMoreTokens() == TRUE){
776 wSTVendorDetails.GetNextToken();
777 wxSVNDID = wSTVendorDetails.GetNextToken();
778 wxSVNDPropName = wSTVendorDetails.GetNextToken();
783 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
785 // Setup the values for later processing.
787 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
788 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
789 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
791 // Add the data to the vendor variables.
795 coldata.SetId(intValueSeek);
796 coldata.SetData(intValueSeek);
797 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
799 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
801 VendorList.erase(intValueSeek);
802 VendorListPEN.erase(intValueSeek);
803 VendorListElement.erase(intValueSeek);
805 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
806 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
807 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
814 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
818 XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
819 XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
825 coldata.SetId(intValueSeek);
826 coldata.SetData(intValueSeek);
827 coldata.SetText(wxSPropertySeg1.Mid(2));
829 ListCtrlIndex = lboXToken->InsertItem(coldata);
837 // Reset the variables.
841 ExtraLineSeek = TRUE;
849 FMTimer.SetFilename(Filename);
850 FMTimer.Start(10000, FALSE);
857 void frmContactEditor::SplitValues(wxString *PropertyLine,
858 std::map<int,int> *SplitPoints,
859 std::map<int,int> *SplitLength,
862 size_t intPropertyLen = PropertyLine->Len();
863 int intSplitsFound = 0;
864 int intSplitSize = 0;
865 int intSplitSeek = 0;
867 for (int i = intSize; i <= intPropertyLen; i++){
871 if (PropertyLine->Mid(i, 1) == wxT(";") &&
872 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
874 if (intSplitsFound == 0){
876 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
880 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
884 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
894 if (intSplitsFound == 0){
896 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
897 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
901 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
902 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
908 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
909 std::map<int, int> *GeneralListPref,
910 wxListCtrl *GeneralListCtrl,
911 std::map<int, wxString> *HomeList,
912 std::map<int, int> *HomeListPref,
913 wxListCtrl *HomeListCtrl,
914 std::map<int, wxString> *BusinessList,
915 std::map<int, int> *BusinessListPref,
916 wxListCtrl *BusinessListCtrl,
919 long ListCtrlIndex = -1;
921 // Deal with the general items.
923 for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
924 Iter != GeneralList->end();
929 coldata.SetId(*DataCount);
930 coldata.SetData(*DataCount);
931 coldata.SetText(Iter->second);
933 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
935 if (MapDataExists(DataCount, GeneralListPref)){
937 GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
945 // Deal with the home items.
947 for (std::map<int,wxString>::iterator Iter = HomeList->begin();
948 Iter != HomeList->end();
953 coldata.SetId(*DataCount);
954 coldata.SetData(*DataCount);
955 coldata.SetText(Iter->second);
957 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
959 if (MapDataExists(DataCount, HomeListPref)){
961 HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
969 // Deal with the work items.
971 for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
972 Iter != BusinessList->end();
977 coldata.SetId(*DataCount);
978 coldata.SetData(*DataCount);
979 coldata.SetText(Iter->second);
981 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
983 if (MapDataExists(DataCount, BusinessListPref)){
985 BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
995 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
996 std::map<int, int> *GeneralListPref,
997 std::map<int, wxString> *GeneralListType,
998 wxListCtrl *GeneralListCtrl,
999 std::map<int, wxString> *HomeList,
1000 std::map<int, int> *HomeListPref,
1001 std::map<int, wxString> *HomeListType,
1002 wxListCtrl *HomeListCtrl,
1003 std::map<int, wxString> *BusinessList,
1004 std::map<int, int> *BusinessListPref,
1005 std::map<int, wxString> *BusinessListType,
1006 wxListCtrl *BusinessListCtrl,
1009 long ListCtrlIndex = -1;
1011 // Deal with the general items.
1013 for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
1014 Iter != GeneralList->end();
1019 coldata.SetId(*DataCount);
1020 coldata.SetData(*DataCount);
1021 coldata.SetText(Iter->second);
1023 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
1025 if (MapDataExists(DataCount, GeneralListPref)){
1027 GeneralListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
1031 if (MapDataExists(DataCount, GeneralListType)){
1033 GeneralListCtrl->SetItem(ListCtrlIndex, 1, GeneralListType->find(*DataCount)->second);
1041 // Deal with the home items.
1043 for (std::map<int,wxString>::iterator Iter = HomeList->begin();
1044 Iter != HomeList->end();
1049 coldata.SetId(*DataCount);
1050 coldata.SetData(*DataCount);
1051 coldata.SetText(Iter->second);
1053 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
1055 if (MapDataExists(DataCount, HomeListPref)){
1057 HomeListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
1061 if (MapDataExists(DataCount, HomeListType)){
1063 HomeListCtrl->SetItem(ListCtrlIndex, 1, HomeListType->find(*DataCount)->second);
1071 // Deal with the work items.
1073 for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
1074 Iter != BusinessList->end();
1079 coldata.SetId(*DataCount);
1080 coldata.SetData(*DataCount);
1081 coldata.SetText(Iter->second);
1083 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
1085 if (MapDataExists(DataCount, BusinessListPref)){
1087 BusinessListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
1091 if (MapDataExists(DataCount, BusinessListType)){
1093 BusinessListCtrl->SetItem(ListCtrlIndex, 1, BusinessListType->find(*DataCount)->second);
1104 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1105 std::map<int,int> *ItemListPref,
1106 wxListCtrl *ItemCtrl,
1109 long ListCtrlIndex = -1;
1111 for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1112 Iter != ItemList->end();
1117 coldata.SetId(*DataCount);
1118 coldata.SetData(*DataCount);
1119 coldata.SetText(Iter->second);
1121 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1123 if (MapDataExists(DataCount, ItemListPref)){
1125 ItemCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1135 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1136 std::map<int,int> *ItemListPref,
1137 std::map<int,wxString> *ItemListType,
1138 wxListCtrl *ItemCtrl,
1141 long ListCtrlIndex = -1;
1143 for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1144 Iter != ItemList->end();
1149 coldata.SetId(*DataCount);
1150 coldata.SetData(*DataCount);
1151 coldata.SetText(Iter->second);
1153 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1155 if (MapDataExists(DataCount, ItemListType)){
1157 ItemCtrl->SetItem(ListCtrlIndex, 1, ItemListType->find(*DataCount)->second);
1161 if (MapDataExists(DataCount, ItemListPref)){
1163 ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1173 void frmContactEditor::LoadData(wxString ItemName,
1174 std::map<int,wxString> *ItemList,
1175 std::map<int,int> *ItemListPref,
1176 std::map<int,wxString> *ItemListType,
1177 std::map<int,wxString> *ItemListDataType,
1178 wxListCtrl *ItemCtrl,
1181 long ListCtrlIndex = -1;
1183 for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1184 Iter != ItemList->end();
1189 coldata.SetId(*DataCount);
1190 coldata.SetData(*DataCount);
1191 coldata.SetText(Iter->second);
1193 if (ItemName == "KEY"){
1195 // Get the key type, if any.
1197 if (MapDataExists(DataCount, ItemListDataType)){
1199 if (ItemListDataType->find(*DataCount)->second == "application/pgp-keys"){
1201 coldata.SetText(_("PGP Key"));
1207 coldata.SetText(_("Key"));
1214 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1216 if (MapDataExists(DataCount, ItemListType)){
1218 if (ItemListType->find(*DataCount)->second == "home"){
1220 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
1222 } else if (ItemListType->find(*DataCount)->second == "work"){
1224 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
1230 if (MapDataExists(DataCount, ItemListPref)){
1232 ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1242 void frmContactEditor::LoadPictureData(wxString ItemName,
1243 std::map<int,std::string> *ItemList,
1244 std::map<int,int> *ItemListPref,
1245 std::map<int,wxString> *ItemListType,
1246 wxListCtrl *ItemCtrl,
1249 long ListCtrlIndex = -1;
1251 for (std::map<int,std::string>::iterator Iter = ItemList->begin();
1252 Iter != ItemList->end();
1257 coldata.SetId(*DataCount);
1258 coldata.SetData(*DataCount);
1260 if (ItemName == "PHOTO"){
1262 coldata.SetText("Picture");
1264 } else if (ItemName == "LOGO"){
1266 coldata.SetText("Logo");
1268 } else if (ItemName == "SOUND"){
1270 coldata.SetText("Sound");
1274 coldata.SetText("Object");
1278 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1280 if (MapDataExists(DataCount, ItemListType)){
1282 if (ItemListType->find(*DataCount)->second == "home"){
1284 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
1286 } else if (ItemListType->find(*DataCount)->second == "work"){
1288 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
1294 if (MapDataExists(DataCount, ItemListPref)){
1296 ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1306 void frmContactEditor::LoadVendorData(std::map<int,wxString> *ItemListPEN,
1307 std::map<int,wxString> *ItemListElement,
1308 wxListCtrl *ItemCtrl,
1311 long ListCtrlIndex = -1;
1314 for (std::map<int,wxString>::iterator Iter = ItemListPEN->begin();
1315 Iter != ItemListPEN->end();
1322 coldata.SetId(*DataCount);
1323 coldata.SetData(*DataCount);
1325 ItemValue.Append(ItemListPEN->find(*DataCount)->second);
1326 ItemValue.Append("-");
1327 ItemValue.Append(ItemListElement->find(*DataCount)->second);
1329 coldata.SetText(ItemValue);
1331 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1339 void frmContactEditor::LoadXTokenData(std::map<int,wxString> *ItemListTokens,
1340 wxListCtrl *ItemCtrl,
1343 long ListCtrlIndex = -1;
1346 for (std::map<int,wxString>::iterator Iter = ItemListTokens->begin();
1347 Iter != ItemListTokens->end();
1354 coldata.SetId(*DataCount);
1355 coldata.SetData(*DataCount);
1357 ItemValue.Append(ItemListTokens->find(*DataCount)->second);
1359 coldata.SetText(ItemValue);
1361 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1369 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1370 wxComboBox *ItemCtrl){
1374 if (MapDataExists(&ItemIndex, ItemList)){
1376 cmbDisplayAs->SetValue(ItemList->find(0)->second);
1382 void frmContactEditor::LoadRelatedData(std::map<int,wxString> *ItemList,
1383 std::map<int,int> *ItemListPref,
1384 std::map<int,wxString> *ItemListType,
1385 wxListCtrl *ItemCtrl,
1388 long ListCtrlIndex = -1;
1389 wxString RelatedType;
1391 for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1392 Iter != ItemList->end();
1395 RelatedType.clear();
1399 coldata.SetId(*DataCount);
1400 coldata.SetData(*DataCount);
1402 if (MapDataExists(DataCount, ItemListType)){
1404 std::map<int,wxString>::iterator TypeIter = ItemListType->find(*DataCount);
1406 if (TypeIter->second == wxT("contact")){
1408 RelatedType = _("Contact");
1410 } else if (TypeIter->second == wxT("acquaintance")){
1412 RelatedType = _("Acquaintance");
1414 } else if (TypeIter->second == wxT("friend")){
1416 RelatedType = _("Friend");
1418 } else if (TypeIter->second == wxT("met")){
1420 RelatedType = _("Met");
1422 } else if (TypeIter->second == wxT("co-worker")){
1424 RelatedType = _("Co-worker");
1426 } else if (TypeIter->second == wxT("colleague")){
1428 RelatedType = _("Colleague");
1430 } else if (TypeIter->second == wxT("co-resident")){
1432 RelatedType = _("Co-resident");
1434 } else if (TypeIter->second == wxT("neighbor")){
1436 RelatedType = _("Neighbour");
1438 } else if (TypeIter->second == wxT("child")){
1440 RelatedType = _("Child");
1442 } else if (TypeIter->second == wxT("parent")){
1444 RelatedType = _("Parent");
1446 } else if (TypeIter->second == wxT("sibling")){
1448 RelatedType = _("Sibling");
1450 } else if (TypeIter->second == wxT("spouse")){
1452 RelatedType = _("Spouse");
1454 } else if (TypeIter->second == wxT("kin")){
1456 RelatedType = _("Kin");
1458 } else if (TypeIter->second == wxT("muse")){
1460 RelatedType = _("Muse");
1462 } else if (TypeIter->second == wxT("crush")){
1464 RelatedType = _("Crush");
1466 } else if (TypeIter->second == wxT("date")){
1468 RelatedType = _("Date");
1470 } else if (TypeIter->second == wxT("sweetheart")){
1472 RelatedType = _("Sweetheart");
1474 } else if (TypeIter->second == wxT("me")){
1476 RelatedType = _("Me");
1478 } else if (TypeIter->second == wxT("agent")){
1480 RelatedType = _("Agent");
1482 } else if (TypeIter->second == wxT("emergency")){
1484 RelatedType = _("Emergency");
1488 RelatedType = TypeIter->second;
1494 coldata.SetText(RelatedType);
1496 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1498 if (MapDataExists(DataCount, ItemList)){
1500 ItemCtrl->SetItem(ListCtrlIndex, 1, ItemList->find(*DataCount)->second);
1504 if (MapDataExists(DataCount, ItemListPref)){
1506 ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1516 void frmContactEditor::LoadKind(ContactKindType *KindType){
1519 case CONTACTKIND_INDIVIDUAL:
1520 cmbType->SetSelection(1);
1522 case CONTACTKIND_GROUP:
1523 cmbType->SetSelection(2);
1525 case CONTACTKIND_ORGANISATION:
1526 cmbType->SetSelection(3);
1528 case CONTACTKIND_LOCATION:
1529 cmbType->SetSelection(4);
1531 case CONTACTKIND_NONE:
1532 cmbType->SetSelection(0);
1536 wxCommandEvent nullevent;
1538 UpdateMembersTab(nullevent);
1542 void frmContactEditor::LoadBirthday(wxString *BirthdayData, bool *BirthdayText){
1544 if (BirthdayData->IsEmpty()){
1548 if (*BirthdayText == FALSE){
1551 wxDateTime::Month DateMonth;
1552 unsigned int DateDay;
1556 if (BirthdayData->Mid(0, 2) == wxT("--")){
1562 DateYear = wxAtoi(BirthdayData->Mid(0,4));
1566 DateMonth = (wxDateTime::Month)(wxAtoi(BirthdayData->Mid(4,2)) - 1);
1567 DateDay = wxAtoi(BirthdayData->Mid(6,2));
1569 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
1571 dapBirthday->SetValue(BDayDate);
1575 txtBirthday->SetValue(*BirthdayData);
1581 void frmContactEditor::LoadAnniversary(wxString *AnniversaryData, bool *AnniversaryText){
1583 if (AnniversaryData->IsEmpty()){
1587 if (*AnniversaryText == FALSE){
1590 wxDateTime::Month DateMonth;
1595 if (AnniversaryData->Mid(0, 2) == wxT("--")){
1601 DateYear = wxAtoi(AnniversaryData->Mid(0,4));
1605 DateMonth = (wxDateTime::Month)(wxAtoi(AnniversaryData->Mid(4,2)) - 1);
1606 DateDay = wxAtoi(AnniversaryData->Mid(6,2));
1608 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
1610 dapAnniversary->SetValue(ADayDate);
1614 txtAnniversary->SetValue(*AnniversaryData);
1620 void frmContactEditor::LoadGender(wxString *GenderComponent, wxString *GenderIdentity){
1622 // Deal with the Gender Component.
1624 if (*GenderComponent == wxT("M")){
1628 cmbGender->SetSelection(1);
1630 } else if (*GenderComponent == wxT("F")){
1632 // Gender is Female.
1634 cmbGender->SetSelection(2);
1636 } else if (*GenderComponent == wxT("O")){
1640 cmbGender->SetSelection(3);
1642 } else if (*GenderComponent == wxT("N")){
1644 // Gender is None/Not Applicable.
1646 cmbGender->SetSelection(4);
1648 } else if (*GenderComponent == wxT("U")){
1650 // Gender is Unknown.
1652 cmbGender->SetSelection(5);
1656 // Deal with the Gender Identity.
1658 txtGenderDescription->SetValue(*GenderIdentity);
1662 void frmContactEditor::LoadName(wxString *NameTitle, wxString *NameForename,
1663 wxString *NameSurname, wxString *NameOtherNames,
1664 wxString *NameSuffix){
1666 txtTitle->SetValue(*NameTitle);
1667 txtForename->SetValue(*NameForename);
1668 txtSurname->SetValue(*NameSurname);
1669 txtOtherNames->SetValue(*NameOtherNames);
1670 txtSuffix->SetValue(*NameSuffix);
1674 void frmContactEditor::LoadMember(std::map<int,wxString> *GroupList){
1676 // Go through the list of contacts for the account and find the matching UID.
1677 // If contact with UID doesn't match then say (unknown contact).
1679 XABViewMode XVMData;
1680 if (StartupEditMode == FALSE){
1681 XVMData = MainPtr->GetViewMode();
1684 wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
1686 //wxString vcardfilenamewxs;
1687 wxString vCardFilename;
1688 wxString vCardFilenameFull;
1689 wxString vCardDataString;
1690 //wxStringTokenizer vcardfileline;
1692 wxString setname, setvalue;
1693 wxString MemberData;
1694 bool FoundContact = FALSE;
1695 //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
1696 std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
1697 std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
1699 wxDir vcardaccdir(AccountDirFinal);
1701 for (std::map<int,wxString>::iterator MemberIter = GroupList->begin();
1702 MemberIter != GroupList->end();
1705 MemberData = MemberIter->second;
1707 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1710 if (vCardFilename.Right(4) == wxT(".vcf") ||
1711 vCardFilename.Right(4) == wxT(".VCF") ||
1712 vCardFilename.Right(5) == wxT(".vcard") ||
1713 vCardFilename.Right(5) == wxT(".VCARD")){
1717 vCardFilenameFull.Append(AccountDirFinal);
1718 vCardFilenameFull.Append(wxT("/"));
1719 vCardFilenameFull.Append(vCardFilename);
1721 Person.LoadFile(vCardFilenameFull);
1723 if (MemberData.Left(9) == wxT("urn:uuid:")){
1725 wxString NewPropValue;
1726 NewPropValue = MemberData.Mid(9, wxString::npos);
1727 MemberData = NewPropValue;
1731 if (Person.MeetBaseSpecification()){
1733 wxString KindStatus = Person.Get(wxT("KIND"));
1735 if (KindStatus == wxT("group")){
1737 vCardFilename.Clear();
1738 vCardFilenameFull.Clear();
1739 vCardDataString.Clear();
1740 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1745 wxString PersonName = Person.Get(wxT("N"));
1746 wxString PersonUID = Person.Get(wxT("UID"));
1747 wxString PersonFilename = vCardFilenameFull;
1749 if (PersonUID != MemberData){
1751 vCardFilename.Clear();
1752 vCardFilenameFull.Clear();
1753 vCardDataString.Clear();
1754 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1758 FoundContact = TRUE;
1761 //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
1762 //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
1764 if (XVMData.SortMode == 1){
1766 // Split the name into sections.
1768 vCardDataString = Person.Get(wxT("N"));
1770 vCardName NameData = Person.GetName();
1772 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
1774 } else if (XVMData.SortMode == 2){
1776 // Split the name into sections.
1778 vCardName NameData = Person.GetName();
1780 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
1782 } else if (XVMData.SortMode == 3){
1784 // Check and make sure that the top most nickname is used.
1786 vCardDataString = Person.Get(wxT("NICKNAME"));
1788 if (vCardDataString.IsEmpty()){
1790 vCardDataString = wxT("(no nickname)");
1794 } else if (XVMData.SortMode == 4){
1796 vCardDataString = Person.Get(wxT("FN"));
1800 if (XVMData.AscendingMode == TRUE){
1801 vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
1803 vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
1814 vCardFilename.Clear();
1815 vCardFilenameFull.Clear();
1816 vCardDataString.Clear();
1817 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1821 if (FoundContact == FALSE){
1822 if (XVMData.AscendingMode == TRUE){
1823 vCardNamesAsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1825 vCardNamesDsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1829 if (XVMData.AscendingMode == TRUE){
1831 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin();
1832 iter != vCardNamesAsc.end(); ++iter){
1834 wxListItem ItemData;
1837 ItemData.SetText(iter->first);
1839 lboGroups->InsertItem(ItemData);
1846 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin();
1847 iter != vCardNamesDsc.end(); ++iter){
1849 wxListItem ItemData;
1852 ItemData.SetText(iter->first);
1854 lboGroups->InsertItem(ItemData);
1864 void frmContactEditor::LoadAddress(std::map<int, wxString> *GeneralAddressList,
1865 std::map<int, wxString> *GeneralAddressListTown,
1866 std::map<int, wxString> *GeneralAddressListCounty,
1867 std::map<int, wxString> *GeneralAddressListPostCode,
1868 std::map<int, int> *GeneralAddressListPref,
1869 std::map<int, wxString> *HomeAddressList,
1870 std::map<int, wxString> *HomeAddressListTown,
1871 std::map<int, wxString> *HomeAddressListCounty,
1872 std::map<int, wxString> *HomeAddressListPostCode,
1873 std::map<int, int> *HomeAddressListPref,
1874 std::map<int, wxString> *BusinessAddressList,
1875 std::map<int, wxString> *BusinessAddressListTown,
1876 std::map<int, wxString> *BusinessAddressListCounty,
1877 std::map<int, wxString> *BusinessAddressListPostCode,
1878 std::map<int, int> *BusinessAddressListPref,
1881 long ListCtrlIndex = -1;
1883 // Deal with the general addresses.
1885 for (std::map<int,wxString>::iterator Iter = GeneralAddressList->begin();
1886 Iter != GeneralAddressList->end();
1891 coldata.SetId(*AddressCount);
1892 coldata.SetData(*AddressCount);
1893 coldata.SetText(Iter->second);
1895 ListCtrlIndex = lboAddresses->InsertItem(coldata);
1897 if (MapDataExists(AddressCount, GeneralAddressListTown)){
1899 lboAddresses->SetItem(ListCtrlIndex, 1, GeneralAddressListTown->find(*AddressCount)->second);
1903 if (MapDataExists(AddressCount, GeneralAddressListCounty)){
1905 lboAddresses->SetItem(ListCtrlIndex, 2, GeneralAddressListCounty->find(*AddressCount)->second);
1909 if (MapDataExists(AddressCount, GeneralAddressListPostCode)){
1911 lboAddresses->SetItem(ListCtrlIndex, 3, GeneralAddressListPostCode->find(*AddressCount)->second);
1915 if (MapDataExists(AddressCount, GeneralAddressListPref)){
1917 lboAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", GeneralAddressListPref->find(*AddressCount)->second));
1925 // Deal with the home addresses.
1927 for (std::map<int,wxString>::iterator Iter = HomeAddressList->begin();
1928 Iter != HomeAddressList->end();
1933 coldata.SetId(*AddressCount);
1934 coldata.SetData(*AddressCount);
1935 coldata.SetText(Iter->second);
1937 ListCtrlIndex = lboHomeAddresses->InsertItem(coldata);
1939 if (MapDataExists(AddressCount, HomeAddressListTown)){
1941 lboHomeAddresses->SetItem(ListCtrlIndex, 1, HomeAddressListTown->find(*AddressCount)->second);
1945 if (MapDataExists(AddressCount, HomeAddressListCounty)){
1947 lboHomeAddresses->SetItem(ListCtrlIndex, 2, HomeAddressListCounty->find(*AddressCount)->second);
1951 if (MapDataExists(AddressCount, HomeAddressListPostCode)){
1953 lboHomeAddresses->SetItem(ListCtrlIndex, 3, HomeAddressListPostCode->find(*AddressCount)->second);
1957 if (MapDataExists(AddressCount, HomeAddressListPref)){
1959 lboHomeAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", HomeAddressListPref->find(*AddressCount)->second));
1967 // Deal with the work addresses.
1969 for (std::map<int,wxString>::iterator Iter = BusinessAddressList->begin();
1970 Iter != BusinessAddressList->end();
1975 coldata.SetId(*AddressCount);
1976 coldata.SetData(*AddressCount);
1977 coldata.SetText(Iter->second);
1979 ListCtrlIndex = lboBusinessAddresses->InsertItem(coldata);
1981 if (MapDataExists(AddressCount, BusinessAddressListTown)){
1983 lboBusinessAddresses->SetItem(ListCtrlIndex, 1, BusinessAddressListTown->find(*AddressCount)->second);
1987 if (MapDataExists(AddressCount, BusinessAddressListCounty)){
1989 lboBusinessAddresses->SetItem(ListCtrlIndex, 2, BusinessAddressListCounty->find(*AddressCount)->second);
1993 if (MapDataExists(AddressCount, BusinessAddressListPostCode)){
1995 lboBusinessAddresses->SetItem(ListCtrlIndex, 3, BusinessAddressListPostCode->find(*AddressCount)->second);
1999 if (MapDataExists(AddressCount, BusinessAddressListPref)){
2001 lboBusinessAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", BusinessAddressListPref->find(*AddressCount)->second));