1 // ContactDataObject.cpp - Client Data Object.
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/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 int ContactLineLen = 0;
82 int QuoteBreakPoint = 0;
85 int NicknameCount = 0;
86 int TimeZoneCount = 0;
90 int TelephoneCount = 0;
91 int LanguageCount = 0;
92 int GeographicCount = 0;
97 int OrganisationCount = 0;
100 wxString PropertyLine;
101 wxString PropertySeg1;
102 wxString PropertySeg2;
103 wxString PropertyNextLine;
106 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
107 iter != ContactFileLines.end(); ++iter){
109 ExtraLineSeek = TRUE;
115 PropertyLine.Clear();
116 PropertySeg1.Clear();
117 PropertySeg2.Clear();
120 ContactLine = iter->second;
122 while (ExtraLineSeek == TRUE){
124 // Check if there is extra data on the next line
125 // (indicated by space or tab at the start) and add data.
129 if (iter == ContactFileLines.end()){
136 PropertyNextLine = iter->second;
138 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
140 PropertyNextLine.Remove(0, 1);
141 ContactLine.Append(PropertyNextLine);
146 ExtraLineSeek = FALSE;
152 ContactLineLen = ContactLine.Len();
154 // Make sure we are not in quotation mode.
155 // Make sure colon does not have \ or \\ before it.
157 for (int i = 0; i <= ContactLineLen; i++){
159 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
161 PropertyFind = FALSE;
163 } else if (PropertyFind == TRUE){
165 Property.Append(ContactLine.Mid(i, 1));
169 if (ContactLine.Mid(i, 1) == wxT("\"")){
171 if (QuoteMode == TRUE){
183 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
192 // Split that line at the point into two variables (ignore the colon).
194 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
195 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
197 if (Property == wxT("KIND") && KindProcessed == FALSE){
199 ProcessKind(PropertySeg2);
201 } else if (Property == wxT("MEMBER")){
203 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
206 } else if (Property == wxT("FN")){
208 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
211 } else if (Property == wxT("N") && NameProcessed == FALSE){
213 ProcessN(PropertySeg1, PropertySeg2);
214 NameProcessed = TRUE;
216 } else if (Property == wxT("NICKNAME")){
218 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
221 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
223 ProcessGender(PropertySeg1, PropertySeg2);
224 GenderProcessed = TRUE;
226 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
228 ProcessBirthday(PropertySeg1, PropertySeg2);
229 BirthdayProcessed = TRUE;
231 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
233 ProcessAnniversary(PropertySeg1, PropertySeg2);
234 AnniversaryProcessed = TRUE;
236 } else if (Property == wxT("TZ")){
238 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
241 } else if (Property == wxT("ADR")){
243 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
246 } else if (Property == wxT("EMAIL")){
248 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
251 } else if (Property == wxT("IMPP")){
253 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
256 } else if (Property == wxT("TEL")){
258 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
261 } else if (Property == wxT("LANG")){
263 // See frmContactEditor-LoadLanguage.cpp
265 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
268 } else if (Property == wxT("GEO")){
270 // See frmContactEditor-LoadGeo.cpp
272 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
275 } else if (Property == wxT("RELATED")){
277 // See fromContactEditor-LoadRelated.cpp
279 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
282 } else if (Property == wxT("URL")){
284 // See frmContactEditor-LoadURL.cpp
286 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
289 } else if (Property == wxT("TITLE")) {
291 // See frmContactEditor-LoadTitle.cpp
293 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
296 } else if (Property == wxT("ROLE")) {
298 // See frmContactEditor-LoadTitle.cpp
300 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
303 } else if (Property == wxT("ORG")) {
305 // See frmContactEditor-LoadOrg.cpp
307 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
310 } else if (Property == wxT("NOTE")) {
312 // See frmContactEditor-LoadNote.cpp
314 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
321 return CONTACTLOAD_OK;
325 void ContactDataObject::ProcessKind(wxString KindType){
327 if (KindType == wxT("individual")){
329 ContactKind = CONTACTKIND_INDIVIDUAL;
331 } else if (KindType == wxT("group")){
333 ContactKind = CONTACTKIND_GROUP;
335 } else if (KindType == wxT("org")){
337 ContactKind = CONTACTKIND_ORGANISATION;
339 } else if (KindType == wxT("location")){
341 ContactKind = CONTACTKIND_LOCATION;
345 ContactKind = CONTACTKIND_NONE;
350 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
352 std::map<int, int> SplitPoints;
353 std::map<int, int> SplitLength;
355 int intPrevValue = 8;
359 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
363 wxString PropertyName;
364 wxString PropertyValue;
365 wxString PropertyData;
366 wxString PropertyTokens;
367 std::map<int,int>::iterator SLiter;
368 bool FirstToken = TRUE;
370 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
371 intiter != SplitPoints.end(); ++intiter){
373 SLiter = SplitLength.find(intiter->first);
375 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
377 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
378 PropertyName = PropertyElement.GetNextToken();
379 PropertyValue = PropertyElement.GetNextToken();
381 intPrevValue = intiter->second;
383 CaptureString(&PropertyValue, FALSE);
385 if (PropertyName == wxT("ALTID")){
387 GroupsListAltID.erase(*GroupCount);
388 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
390 } else if (PropertyName == wxT("PID")){
392 GroupsListPID.erase(*GroupCount);
393 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
395 } else if (PropertyName == wxT("PREF")){
397 int PriorityNumber = 0;
398 bool ValidNumber = TRUE;
401 PriorityNumber = std::stoi(PropertyValue.ToStdString());
404 catch(std::invalid_argument &e){
408 if (ValidNumber == TRUE){
410 GroupsListPref.erase(*GroupCount);
411 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
415 } else if (PropertyName == wxT("MEDIATYPE")){
417 GroupsListMediaType.erase(*GroupCount);
418 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
420 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
422 if (FirstToken == TRUE){
424 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
429 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
437 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
439 if (!PropertyTokens.IsEmpty()){
441 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
448 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
450 std::map<int, int> SplitPoints;
451 std::map<int, int> SplitLength;
453 int intPrevValue = 4;
457 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
461 wxString PropertyName;
462 wxString PropertyValue;
463 wxString PropertyData;
464 wxString PropertyTokens;
465 std::map<int,int>::iterator SLiter;
466 bool FirstToken = TRUE;
468 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
469 intiter != SplitPoints.end(); ++intiter){
471 SLiter = SplitLength.find(intiter->first);
473 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
475 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
476 PropertyName = PropertyElement.GetNextToken();
477 PropertyValue = PropertyElement.GetNextToken();
479 intPrevValue = intiter->second;
481 CaptureString(&PropertyValue, FALSE);
483 if (PropertyName == wxT("TYPE")){
485 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
486 PropertyValue == wxT("work") ){
488 FullNamesListType.erase(*FNCount);
489 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
493 } else if (PropertyName == wxT("LANGUAGE")){
495 FullNamesListLanguage.erase(*FNCount);
496 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
498 } else if (PropertyName == wxT("ALTID")){
500 FullNamesListAltID.erase(*FNCount);
501 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
503 } else if (PropertyName == wxT("PID")){
505 FullNamesListPID.erase(*FNCount);
506 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
508 } else if (PropertyName == wxT("PREF")){
510 int PriorityNumber = 0;
511 bool ValidNumber = TRUE;
514 PriorityNumber = std::stoi(PropertyValue.ToStdString());
517 catch(std::invalid_argument &e){
521 if (ValidNumber == TRUE){
523 FullNamesListPref.erase(*FNCount);
524 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
528 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
530 if (FirstToken == TRUE){
532 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
537 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
545 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
547 if (!PropertyTokens.IsEmpty()){
549 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
555 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
557 std::map<int, int> SplitPoints;
558 std::map<int, int> SplitLength;
560 int intPrevValue = 3;
564 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
568 wxString PropertyName;
569 wxString PropertyValue;
570 wxString PropertyData;
571 wxString PropertyTokens;
572 std::map<int,int>::iterator SLiter;
573 bool FirstToken = TRUE;
575 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
576 intiter != SplitPoints.end(); ++intiter){
578 SLiter = SplitLength.find(intiter->first);
580 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
582 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
583 PropertyName = PropertyElement.GetNextToken();
584 PropertyValue = PropertyElement.GetNextToken();
586 intPrevValue = intiter->second;
588 CaptureString(&PropertyValue, FALSE);
590 if (PropertyName == wxT("ALTID")){
592 NameAltID = PropertyValue;
594 } else if (PropertyName == wxT("LANGUAGE")){
596 NameLanguage = PropertyValue;
598 } else if (PropertyName == wxT("SORT-AS")){
600 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
601 PropertyValue.Len() >= 3){
602 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
605 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
607 if (FirstToken == TRUE){
609 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
614 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
622 // Split the name data.
624 int intSplitSeek = 0;
625 int intSplitsFound = 0;
626 int intSplitSize = 0;
627 int intPropertyLen = PropertySeg2.Len();
629 std::map<int,wxString> NameValues;
632 for (int i = 0; i <= intPropertyLen; i++){
634 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
636 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
641 if (intSplitsFound == 4){
643 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
657 // Split the data into several parts.
659 for (std::map<int, wxString>::iterator iter = NameValues.begin();
660 iter != NameValues.end(); ++iter){
662 if (iter->first == 1){
664 // Deal with family name.
666 NameSurname = iter->second;
668 } else if (iter->first == 2){
670 // Deal with given names.
672 NameForename = iter->second;
674 } else if (iter->first == 3){
676 // Deal with additional names.
678 NameOtherNames = iter->second;
680 } else if (iter->first == 4){
682 // Deal with honorifix prefixes and suffixes.
684 NameTitle = iter->second;
688 if (iter == NameValues.end()){
694 NameSuffix = iter->second;
700 // Add the name token data.
702 if (!PropertyTokens.IsEmpty()){
704 NameTokens = PropertyTokens;
710 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
712 std::map<int, int> SplitPoints;
713 std::map<int, int> SplitLength;
715 int intPrevValue = 10;
718 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
722 PropertyType PropType = PROPERTY_NONE;
724 // Look for type before continuing.
726 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
730 std::map<int, wxString> *NicknamesList = NULL;
731 std::map<int, wxString> *NicknamesListType = NULL;
732 std::map<int, wxString> *NicknamesListLanguage = NULL;
733 std::map<int, wxString> *NicknamesListAltID = NULL;
734 std::map<int, wxString> *NicknamesListPID = NULL;
735 std::map<int, wxString> *NicknamesListTokens = NULL;
736 std::map<int, int> *NicknamesListPref = NULL;
740 NicknamesList = &GeneralNicknamesList;
741 NicknamesListType = &GeneralNicknamesListType;
742 NicknamesListLanguage = &GeneralNicknamesListLanguage;
743 NicknamesListAltID = &GeneralNicknamesListAltID;
744 NicknamesListPID = &GeneralNicknamesListPID;
745 NicknamesListTokens = &GeneralNicknamesListTokens;
746 NicknamesListPref = &GeneralNicknamesListPref;
749 NicknamesList = &HomeNicknamesList;
750 NicknamesListType = &HomeNicknamesListType;
751 NicknamesListLanguage = &HomeNicknamesListLanguage;
752 NicknamesListAltID = &HomeNicknamesListAltID;
753 NicknamesListPID = &HomeNicknamesListPID;
754 NicknamesListTokens = &HomeNicknamesListTokens;
755 NicknamesListPref = &HomeNicknamesListPref;
758 NicknamesList = &BusinessNicknamesList;
759 NicknamesListType = &BusinessNicknamesListType;
760 NicknamesListLanguage = &BusinessNicknamesListLanguage;
761 NicknamesListAltID = &BusinessNicknamesListAltID;
762 NicknamesListPID = &BusinessNicknamesListPID;
763 NicknamesListTokens = &BusinessNicknamesListTokens;
764 NicknamesListPref = &BusinessNicknamesListPref;
768 std::map<int, int>::iterator SLiter;
769 wxString PropertyData;
770 wxString PropertyName;
771 wxString PropertyValue;
772 wxString PropertyTokens;
773 bool FirstToken = TRUE;
775 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
776 intiter != SplitPoints.end(); ++intiter){
778 SLiter = SplitLength.find(intiter->first);
780 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
782 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
783 PropertyName = PropertyElement.GetNextToken();
784 PropertyValue = PropertyElement.GetNextToken();
786 intPrevValue = intiter->second;
788 CaptureString(&PropertyValue, FALSE);
790 if (PropertyName == wxT("ALTID")){
792 NicknamesListAltID->erase(*NicknameCount);
793 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
795 } else if (PropertyName == wxT("PID")){
797 NicknamesListPID->erase(*NicknameCount);
798 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
800 } else if (PropertyName == wxT("PREF")){
802 int PriorityNumber = 0;
803 bool ValidNumber = TRUE;
806 PriorityNumber = std::stoi(PropertyValue.ToStdString());
809 catch(std::invalid_argument &e){
813 if (ValidNumber == TRUE){
815 NicknamesListPref->erase(*NicknameCount);
816 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
820 } else if (PropertyName == wxT("LANGUAGE")){
822 NicknamesListLanguage->erase(*NicknameCount);
823 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
827 // Something else we don't know about so append
828 // to the tokens variable.
830 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
832 if (FirstToken == TRUE){
834 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
839 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
849 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
851 // Add the name token data.
853 if (!PropertyTokens.IsEmpty()){
855 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
861 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
863 std::map<int, int> SplitPoints;
864 std::map<int, int> SplitLength;
865 std::map<int, int>::iterator SLiter;
866 wxString PropertyData;
867 wxString PropertyName;
868 wxString PropertyValue;
869 wxString PropertyTokens;
870 bool FirstToken = TRUE;
871 int intPrevValue = 8;
873 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
877 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
878 intiter != SplitPoints.end(); ++intiter){
880 SLiter = SplitLength.find(intiter->first);
882 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
884 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
885 PropertyName = PropertyElement.GetNextToken();
886 PropertyValue = PropertyElement.GetNextToken();
888 intPrevValue = intiter->second;
890 // Process properties.
892 size_t intPropertyValueLen = PropertyValue.Len();
894 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
896 PropertyValue.Trim();
897 PropertyValue.RemoveLast();
901 if (PropertyValue.Mid(0, 1) == wxT("\"")){
903 PropertyValue.Remove(0, 1);
907 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
909 if (FirstToken == TRUE){
911 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
916 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
924 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
926 wxString GenderComponent;
928 if (GenderData.CountTokens() >= 2){
930 Gender = GenderData.GetNextToken();
931 GenderDetails = GenderData.GetString();
933 CaptureString(&GenderDetails, FALSE);
937 Gender = GenderData.GetNextToken();
941 if (!PropertyTokens.IsEmpty()){
943 GenderTokens = PropertyTokens;
949 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
951 // Process date. Preserve the remainder in the string.
953 std::map<int, int> SplitPoints;
954 std::map<int, int> SplitLength;
955 std::map<int, int>::iterator SLiter;
956 wxString PropertyData;
957 wxString PropertyName;
958 wxString PropertyValue;
959 wxString PropertyTokens;
960 bool BirthdayText = FALSE;
961 int intPrevValue = 6;
963 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
967 // Look for type before continuing.
969 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
970 intiter != SplitPoints.end(); ++intiter){
972 SLiter = SplitLength.find(intiter->first);
974 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
976 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
977 PropertyName = PropertyElement.GetNextToken();
978 PropertyValue = PropertyElement.GetNextToken();
980 intPrevValue = intiter->second;
982 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
984 CaptureString(&PropertySeg2, FALSE);
985 Birthday = PropertySeg2;
992 // Setup blank lines for later on.
995 bool FirstToken = TRUE;
997 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
998 intiter != SplitPoints.end(); ++intiter){
1000 SLiter = SplitLength.find(intiter->first);
1002 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1004 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1005 PropertyName = PropertyElement.GetNextToken();
1006 PropertyValue = PropertyElement.GetNextToken();
1008 intPrevValue = intiter->second;
1010 // Process properties.
1012 CaptureString(&PropertyValue, FALSE);
1014 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1016 PropertyValue.Trim();
1017 PropertyValue.RemoveLast();
1021 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1023 PropertyValue.Remove(0, 1);
1027 if (PropertyName == wxT("ALTID")){
1029 BirthdayAltID = PropertyValue;
1031 } else if (PropertyName == wxT("CALSCALE")){
1033 BirthdayCalScale = PropertyValue;
1035 } else if (PropertyName != wxT("VALUE")) {
1037 // Something else we don't know about so append
1038 // to the tokens variable.
1040 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1042 if (FirstToken == TRUE){
1044 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1049 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1059 // Add the data to the variables and form.
1061 if (BirthdayText == FALSE){
1063 Birthday = PropertySeg2;
1067 if (!PropertyTokens.IsEmpty()){
1069 BirthdayTokens = PropertyTokens;
1075 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1077 // Process date. Preserve the remainder in the string.
1079 std::map<int, int> SplitPoints;
1080 std::map<int, int> SplitLength;
1081 std::map<int, int>::iterator SLiter;
1082 wxString PropertyData;
1083 wxString PropertyName;
1084 wxString PropertyValue;
1085 wxString PropertyTokens;
1086 bool AnniversaryText = FALSE;
1087 int intPrevValue = 13;
1089 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1093 // Look for type before continuing.
1095 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1096 intiter != SplitPoints.end(); ++intiter){
1098 SLiter = SplitLength.find(intiter->first);
1100 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1102 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1103 PropertyName = PropertyElement.GetNextToken();
1104 PropertyValue = PropertyElement.GetNextToken();
1106 intPrevValue = intiter->second;
1108 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1110 CaptureString(&PropertySeg2, FALSE);
1111 Anniversary = PropertySeg2;
1112 AnniversaryText = TRUE;
1118 // Setup blank lines for later on.
1121 bool FirstToken = TRUE;
1123 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1124 intiter != SplitPoints.end(); ++intiter){
1126 SLiter = SplitLength.find(intiter->first);
1128 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1130 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1131 PropertyName = PropertyElement.GetNextToken();
1132 PropertyValue = PropertyElement.GetNextToken();
1134 intPrevValue = intiter->second;
1136 // Process properties.
1138 CaptureString(&PropertyValue, FALSE);
1140 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1142 PropertyValue.Trim();
1143 PropertyValue.RemoveLast();
1147 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1149 PropertyValue.Remove(0, 1);
1153 if (PropertyName == wxT("ALTID")){
1155 AnniversaryAltID = PropertyValue;
1157 } else if (PropertyName == wxT("CALSCALE")){
1159 AnniversaryCalScale = PropertyValue;
1161 } else if (PropertyName != wxT("VALUE")) {
1163 // Something else we don't know about so append
1164 // to the tokens variable.
1166 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1168 if (FirstToken == TRUE){
1170 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1175 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1185 // Add the data to the variables and form.
1187 if (AnniversaryText == FALSE){
1189 Anniversary = PropertySeg2;
1193 if (!PropertyTokens.IsEmpty()){
1195 AnniversaryTokens = PropertyTokens;
1201 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1203 std::map<int, int> SplitPoints;
1204 std::map<int, int> SplitLength;
1206 int intPrevValue = 4;
1209 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1213 PropertyType PropType = PROPERTY_NONE;
1215 // Look for type before continuing.
1217 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1221 std::map<int, wxString> *TZList = NULL;
1222 std::map<int, wxString> *TZListType = NULL;
1223 std::map<int, wxString> *TZListMediatype = NULL;
1224 std::map<int, wxString> *TZListAltID = NULL;
1225 std::map<int, wxString> *TZListPID = NULL;
1226 std::map<int, wxString> *TZListTokens = NULL;
1227 std::map<int, int> *TZListPref = NULL;
1231 TZList = &GeneralTZList;
1232 TZListType = &GeneralTZListType;
1233 TZListMediatype = &GeneralTZListMediatype;
1234 TZListAltID = &GeneralTZListAltID;
1235 TZListPID = &GeneralTZListPID;
1236 TZListTokens = &GeneralTZListTokens;
1237 TZListPref = &GeneralTZListPref;
1240 TZList = &HomeTZList;
1241 TZListType = &HomeTZListType;
1242 TZListMediatype = &HomeTZListMediatype;
1243 TZListAltID = &HomeTZListAltID;
1244 TZListPID = &HomeTZListPID;
1245 TZListTokens = &HomeTZListTokens;
1246 TZListPref = &HomeTZListPref;
1249 TZList = &BusinessTZList;
1250 TZListType = &BusinessTZListType;
1251 TZListMediatype = &BusinessTZListMediatype;
1252 TZListAltID = &BusinessTZListAltID;
1253 TZListPID = &BusinessTZListPID;
1254 TZListTokens = &BusinessTZListTokens;
1255 TZListPref = &BusinessTZListPref;
1259 std::map<int, int>::iterator SLiter;
1260 wxString PropertyData;
1261 wxString PropertyName;
1262 wxString PropertyValue;
1263 wxString PropertyTokens;
1264 bool FirstToken = TRUE;
1266 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1267 intiter != SplitPoints.end(); ++intiter){
1269 SLiter = SplitLength.find(intiter->first);
1271 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1273 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1274 PropertyName = PropertyElement.GetNextToken();
1275 PropertyValue = PropertyElement.GetNextToken();
1277 intPrevValue = intiter->second;
1279 CaptureString(&PropertyValue, FALSE);
1281 if (PropertyName == wxT("ALTID")){
1283 TZListAltID->erase(*TimeZoneCount);
1284 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1286 } else if (PropertyName == wxT("PID")){
1288 TZListPID->erase(*TimeZoneCount);
1289 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1291 } else if (PropertyName == wxT("PREF")){
1293 int PriorityNumber = 0;
1294 bool ValidNumber = TRUE;
1297 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1300 catch(std::invalid_argument &e){
1301 ValidNumber = FALSE;
1304 if (ValidNumber == TRUE){
1306 TZListPref->erase(*TimeZoneCount);
1307 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1311 } else if (PropertyName == wxT("MEDIATYPE")){
1313 TZListMediatype->erase(*TimeZoneCount);
1314 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1318 // Something else we don't know about so append
1319 // to the tokens variable.
1321 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1323 if (FirstToken == TRUE){
1325 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1330 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1340 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1342 // Add the name token data.
1344 if (!PropertyTokens.IsEmpty()){
1346 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1353 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1355 size_t intPropertyLen = PropertySeg1.Len();
1356 std::map<int, int> SplitPoints;
1357 std::map<int, int> SplitLength;
1358 std::map<int, int>::iterator SLiter;
1359 wxString PropertyData;
1360 wxString PropertyName;
1361 wxString PropertyValue;
1362 wxString PropertyTokens;
1363 wxString AddressLabel;
1364 wxString AddressLang;
1365 wxString AddressAltID;
1366 wxString AddressPID;
1367 wxString AddressTokens;
1368 wxString AddressGeo;
1369 wxString AddressTimezone;
1370 wxString AddressType;
1371 wxString AddressMediatype;
1372 wxString AddressPOBox;
1373 wxString AddressExtended;
1374 wxString AddressStreet;
1375 wxString AddressLocality;
1376 wxString AddressCity;
1377 wxString AddressRegion;
1378 wxString AddressPostalCode;
1379 wxString AddressCountry;
1380 bool FirstToken = TRUE;
1381 int intSplitsFound = 0;
1382 int intSplitSize = 0;
1383 int intPrevValue = 5;
1388 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1392 PropertyType PropType = PROPERTY_NONE;
1394 // Look for type before continuing.
1396 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1400 std::map<int, wxString> *AddressList = NULL;
1401 std::map<int, wxString> *AddressListTown = NULL;
1402 std::map<int, wxString> *AddressListCounty = NULL;
1403 std::map<int, wxString> *AddressListPostCode = NULL;
1404 std::map<int, wxString> *AddressListCountry = NULL;
1405 std::map<int, wxString> *AddressListLabel = NULL;
1406 std::map<int, wxString> *AddressListLang = NULL;
1407 std::map<int, wxString> *AddressListAltID = NULL;
1408 std::map<int, wxString> *AddressListPID = NULL;
1409 std::map<int, wxString> *AddressListTokens = NULL;
1410 std::map<int, wxString> *AddressListGeo = NULL;
1411 std::map<int, wxString> *AddressListTimezone = NULL;
1412 std::map<int, wxString> *AddressListType = NULL;
1413 std::map<int, wxString> *AddressListMediatype = NULL;
1414 std::map<int, int> *AddressListPref = NULL;
1418 AddressList = &GeneralAddressList;
1419 AddressListTown = &GeneralAddressListTown;
1420 AddressListCounty = &GeneralAddressListCounty;
1421 AddressListPostCode = &GeneralAddressListPostCode;
1422 AddressListCountry = &GeneralAddressListCountry;
1423 AddressListLabel = &GeneralAddressListLabel;
1424 AddressListLang = &GeneralAddressListLang;
1425 AddressListAltID = &GeneralAddressListAltID;
1426 AddressListPID = &GeneralAddressListPID;
1427 AddressListTokens = &GeneralAddressListTokens;
1428 AddressListGeo = &GeneralAddressListGeo;
1429 AddressListTimezone = &GeneralAddressListTimezone;
1430 AddressListType = &GeneralAddressListType;
1431 AddressListMediatype = &GeneralAddressListMediatype;
1432 AddressListPref = &GeneralAddressListPref;
1435 AddressList = &HomeAddressList;
1436 AddressListTown = &HomeAddressListTown;
1437 AddressListCounty = &HomeAddressListCounty;
1438 AddressListPostCode = &HomeAddressListPostCode;
1439 AddressListCountry = &HomeAddressListCountry;
1440 AddressListLabel = &HomeAddressListLabel;
1441 AddressListLang = &HomeAddressListLang;
1442 AddressListAltID = &HomeAddressListAltID;
1443 AddressListPID = &HomeAddressListPID;
1444 AddressListTokens = &HomeAddressListTokens;
1445 AddressListGeo = &HomeAddressListGeo;
1446 AddressListTimezone = &HomeAddressListTimezone;
1447 AddressListType = &HomeAddressListType;
1448 AddressListMediatype = &HomeAddressListMediatype;
1449 AddressListPref = &HomeAddressListPref;
1452 AddressList = &BusinessAddressList;
1453 AddressListTown = &BusinessAddressListTown;
1454 AddressListCounty = &BusinessAddressListCounty;
1455 AddressListPostCode = &BusinessAddressListPostCode;
1456 AddressListCountry = &BusinessAddressListCountry;
1457 AddressListLabel = &BusinessAddressListLabel;
1458 AddressListLang = &BusinessAddressListLang;
1459 AddressListAltID = &BusinessAddressListAltID;
1460 AddressListPID = &BusinessAddressListPID;
1461 AddressListTokens = &BusinessAddressListTokens;
1462 AddressListGeo = &BusinessAddressListGeo;
1463 AddressListTimezone = &BusinessAddressListTimezone;
1464 AddressListType = &BusinessAddressListType;
1465 AddressListMediatype = &BusinessAddressListMediatype;
1466 AddressListPref = &BusinessAddressListPref;
1472 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1473 intiter != SplitPoints.end(); ++intiter){
1475 SLiter = SplitLength.find(intiter->first);
1477 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1479 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1480 PropertyName = PropertyElement.GetNextToken();
1481 PropertyValue = PropertyElement.GetNextToken();
1483 intPrevValue = intiter->second;
1485 CaptureString(&PropertyValue, FALSE);
1487 // Process properties.
1489 if (PropertyName == wxT("LABEL")){
1491 AddressListLabel->erase(*AddressCount);
1492 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1494 } else if (PropertyName == wxT("LANGUAGE")){
1496 AddressListLang->erase(*AddressCount);
1497 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1499 } else if (PropertyName == wxT("ALTID")){
1501 AddressListAltID->erase(*AddressCount);
1502 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1504 } else if (PropertyName == wxT("PID")){
1506 AddressListPID->erase(*AddressCount);
1507 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1509 } else if (PropertyName == wxT("GEO")){
1511 AddressListGeo->erase(*AddressCount);
1512 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1514 } else if (PropertyName == wxT("TZ")){
1516 AddressListTimezone->erase(*AddressCount);
1517 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1519 } else if (PropertyName == wxT("MEDIATYPE")){
1521 AddressListMediatype->erase(*AddressCount);
1522 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1524 } else if (PropertyName == wxT("PREF")){
1526 int PriorityNumber = 0;
1527 bool ValidNumber = TRUE;
1530 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1533 catch(std::invalid_argument &e){
1534 ValidNumber = FALSE;
1537 if (ValidNumber == TRUE){
1539 AddressListPref->erase(*AddressCount);
1540 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1546 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1548 if (FirstToken == TRUE){
1550 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1555 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1565 // Split the address.
1567 //std::map<int, int>::iterator SLiter;
1568 intPropertyLen = PropertySeg2.Len();
1569 SplitPoints.clear();
1570 SplitLength.clear();
1575 for (int i = 0; i <= intPropertyLen; i++){
1579 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1582 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1584 if (intSplitsFound == 6){
1586 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1591 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1601 // Split the data into several parts.
1603 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1604 intiter != SplitPoints.end(); ++intiter){
1606 if (intiter->first == 1){
1608 // Deal with PO Box.
1610 SLiter = SplitLength.find(1);
1612 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1613 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1614 intPrevValue = intiter->second;
1616 } else if (intiter->first == 2){
1618 // Deal with extended address.
1620 SLiter = SplitLength.find(2);
1622 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1623 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1624 intPrevValue = intiter->second;
1626 } else if (intiter->first == 3){
1628 // Deal with street address.
1630 SLiter = SplitLength.find(3);
1632 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1633 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1634 intPrevValue = intiter->second;
1636 } else if (intiter->first == 4){
1638 // Deal with locality
1640 SLiter = SplitLength.find(4);
1642 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1643 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1644 intPrevValue = intiter->second;
1646 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1648 } else if (intiter->first == 5){
1650 // Deal with region.
1652 SLiter = SplitLength.find(5);
1654 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1655 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1656 intPrevValue = intiter->second;
1658 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1660 } else if (intiter->first == 6){
1662 // Deal with post code.
1664 SLiter = SplitLength.find(6);
1666 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1667 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1668 intPrevValue = intiter->second;
1670 // Deal with country.
1672 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1673 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1681 // Add the data to the General/Home/Work address variables.
1683 CaptureString(&AddressStreet, FALSE);
1684 CaptureString(&AddressLocality, FALSE);
1685 CaptureString(&AddressRegion, FALSE);
1686 CaptureString(&AddressPostalCode, FALSE);
1687 CaptureString(&AddressCountry, FALSE);
1689 if (!PropertyTokens.IsEmpty()){
1691 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1695 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1696 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1697 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1698 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1699 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1703 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1706 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1709 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1713 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1717 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1719 std::map<int, int> SplitPoints;
1720 std::map<int, int> SplitLength;
1722 int intPrevValue = 7;
1725 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1729 PropertyType PropType = PROPERTY_NONE;
1731 // Look for type before continuing.
1733 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1735 std::map<int, wxString> *EmailList = NULL;
1736 std::map<int, wxString> *EmailListType = NULL;
1737 std::map<int, wxString> *EmailListAltID = NULL;
1738 std::map<int, wxString> *EmailListPID = NULL;
1739 std::map<int, wxString> *EmailListTokens = NULL;
1740 std::map<int, int> *EmailListPref = NULL;
1744 EmailList = &GeneralEmailList;
1745 EmailListType = &GeneralEmailListType;
1746 EmailListAltID = &GeneralEmailListAltID;
1747 EmailListPID = &GeneralEmailListPID;
1748 EmailListTokens = &GeneralEmailListTokens;
1749 EmailListPref = &GeneralEmailListPref;
1752 EmailList = &HomeEmailList;
1753 EmailListType = &HomeEmailListType;
1754 EmailListAltID = &HomeEmailListAltID;
1755 EmailListPID = &HomeEmailListPID;
1756 EmailListTokens = &HomeEmailListTokens;
1757 EmailListPref = &HomeEmailListPref;
1760 EmailList = &BusinessEmailList;
1761 EmailListType = &BusinessEmailListType;
1762 EmailListAltID = &BusinessEmailListAltID;
1763 EmailListPID = &BusinessEmailListPID;
1764 EmailListTokens = &BusinessEmailListTokens;
1765 EmailListPref = &BusinessEmailListPref;
1771 std::map<int,int>::iterator SLiter;
1772 wxString PropertyData;
1773 wxString PropertyName;
1774 wxString PropertyValue;
1775 wxString PropertyTokens;
1776 bool FirstToken = TRUE;
1778 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1779 intiter != SplitPoints.end(); ++intiter){
1781 SLiter = SplitLength.find(intiter->first);
1783 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1785 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1786 PropertyName = PropertyElement.GetNextToken();
1787 PropertyValue = PropertyElement.GetNextToken();
1789 intPrevValue = intiter->second;
1791 CaptureString(&PropertyValue, FALSE);
1793 // Process properties.
1795 if (PropertyName == wxT("ALTID")){
1797 EmailListAltID->erase(*EmailCount);
1798 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1800 } else if (PropertyName == wxT("PID")){
1802 EmailListPID->erase(*EmailCount);
1803 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1805 } else if (PropertyName == wxT("PREF")){
1807 int PriorityNumber = 0;
1808 bool ValidNumber = TRUE;
1811 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1814 catch(std::invalid_argument &e){
1815 ValidNumber = FALSE;
1818 if (ValidNumber == TRUE){
1820 EmailListPref->erase(*EmailCount);
1821 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1827 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1829 if (FirstToken == TRUE){
1831 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1836 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1846 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1848 // Add the name token data.
1850 if (!PropertyTokens.IsEmpty()){
1852 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1859 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1861 std::map<int, int> SplitPoints;
1862 std::map<int, int> SplitLength;
1864 int intPrevValue = 6;
1867 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1871 PropertyType PropType = PROPERTY_NONE;
1873 // Look for type before continuing.
1875 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1877 std::map<int, wxString> *IMList = NULL;
1878 std::map<int, wxString> *IMListType = NULL;
1879 std::map<int, wxString> *IMListAltID = NULL;
1880 std::map<int, wxString> *IMListPID = NULL;
1881 std::map<int, wxString> *IMListTokens = NULL;
1882 std::map<int, wxString> *IMListMediatype = NULL;
1883 std::map<int, int> *IMListPref = NULL;
1887 IMList = &GeneralIMList;
1888 IMListType = &GeneralIMListType;
1889 IMListAltID = &GeneralIMListAltID;
1890 IMListPID = &GeneralIMListPID;
1891 IMListTokens = &GeneralIMListTokens;
1892 IMListMediatype = &GeneralIMListMediatype;
1893 IMListPref = &GeneralIMListPref;
1896 IMList = &HomeIMList;
1897 IMListType = &HomeIMListType;
1898 IMListAltID = &HomeIMListAltID;
1899 IMListPID = &HomeIMListPID;
1900 IMListTokens = &HomeIMListTokens;
1901 IMListMediatype = &HomeIMListMediatype;
1902 IMListPref = &HomeIMListPref;
1905 IMList = &BusinessIMList;
1906 IMListType = &BusinessIMListType;
1907 IMListAltID = &BusinessIMListAltID;
1908 IMListPID = &BusinessIMListPID;
1909 IMListTokens = &BusinessIMListTokens;
1910 IMListMediatype = &BusinessIMListMediatype;
1911 IMListPref = &BusinessIMListPref;
1917 std::map<int,int>::iterator SLiter;
1918 wxString PropertyData;
1919 wxString PropertyName;
1920 wxString PropertyValue;
1921 wxString PropertyTokens;
1922 bool FirstToken = TRUE;
1924 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1925 intiter != SplitPoints.end(); ++intiter){
1927 SLiter = SplitLength.find(intiter->first);
1929 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1931 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1932 PropertyName = PropertyElement.GetNextToken();
1933 PropertyValue = PropertyElement.GetNextToken();
1935 intPrevValue = intiter->second;
1937 CaptureString(&PropertyValue, FALSE);
1939 // Process properties.
1941 if (PropertyName == wxT("ALTID")){
1943 IMListAltID->erase(*IMCount);
1944 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1946 } else if (PropertyName == wxT("PID")){
1948 IMListPID->erase(*IMCount);
1949 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1951 } else if (PropertyName == wxT("MEDIATYPE")){
1953 IMListMediatype->erase(*IMCount);
1954 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1956 } else if (PropertyName == wxT("PREF")){
1958 int PriorityNumber = 0;
1959 bool ValidNumber = TRUE;
1962 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1965 catch(std::invalid_argument &e){
1966 ValidNumber = FALSE;
1969 if (ValidNumber == TRUE){
1971 IMListPref->erase(*IMCount);
1972 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1978 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1980 if (FirstToken == TRUE){
1982 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1987 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1997 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1999 // Add the name token data.
2001 if (!PropertyTokens.IsEmpty()){
2003 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2009 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2011 std::map<int, int> SplitPoints;
2012 std::map<int, int> SplitLength;
2013 std::map<int, int>::iterator SLiter;
2017 PropertyType PropType = PROPERTY_NONE;
2019 // Look for type before continuing.
2022 wxString TelTypeDetail;
2023 wxString PropertyData;
2024 wxString PropertyName;
2025 wxString PropertyValue;
2026 wxString PropertyTokens;
2028 std::map<int,int> TypeSplitPoints;
2029 std::map<int,int> TypeSplitLength;
2030 std::map<int,int>::iterator TSLiter;
2032 int intSplitSize = 0;
2033 int intSplitsFound = 0;
2034 int intSplitPoint = 0;
2036 int intPrevValue = 5;
2038 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2042 // Look for type before continuing.
2044 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2045 intiter != SplitPoints.end(); ++intiter){
2047 SLiter = SplitLength.find(intiter->first);
2049 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2051 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2052 PropertyName = PropertyElement.GetNextToken();
2053 PropertyValue = PropertyElement.GetNextToken();
2055 intPrevValue = intiter->second;
2057 if (PropertyName == wxT("TYPE")){
2059 // Process each value in type and translate each
2062 // Strip out the quotes if they are there.
2064 size_t intPropertyValueLen = PropertyValue.Len();
2066 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2068 PropertyValue.Trim();
2069 PropertyValue.RemoveLast();
2073 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2075 PropertyValue.Remove(0, 1);
2079 TelTypeDetail = PropertyValue;
2085 for (int i = 0; i <= intPropertyValueLen; i++){
2089 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2091 if (intSplitsFound == 0){
2093 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2094 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2098 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2099 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2112 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2113 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2115 int intTypeSeek = 0;
2117 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2118 typeiter != TypeSplitPoints.end(); ++typeiter){
2120 wxString TypePropertyName;
2122 TSLiter = TypeSplitLength.find(typeiter->first);
2124 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2126 if (intTypeSeek == 0){
2131 TelTypeUI.Append(wxT(","));
2135 if (TypePropertyName == wxT("home")){
2137 PropType = PROPERTY_HOME;
2139 } else if (TypePropertyName == wxT("work")){
2141 PropType = PROPERTY_WORK;
2146 if (TypePropertyName == wxT("text")){
2148 TelTypeUI.Append(_("text"));
2151 } else if (TypePropertyName == wxT("voice")){
2153 TelTypeUI.Append(_("voice"));
2156 } else if (TypePropertyName == wxT("fax")){
2158 TelTypeUI.Append(_("fax"));
2161 } else if (TypePropertyName == wxT("cell")){
2163 TelTypeUI.Append(_("mobile"));
2166 } else if (TypePropertyName == wxT("video")){
2168 TelTypeUI.Append(_("video"));
2171 } else if (TypePropertyName == wxT("pager")){
2173 TelTypeUI.Append(_("pager"));
2176 } else if (TypePropertyName == wxT("textphone")){
2178 TelTypeUI.Append(_("textphone"));
2189 std::map<int, wxString> *TelephoneList = NULL;
2190 std::map<int, wxString> *TelephoneListType = NULL;
2191 std::map<int, wxString> *TelephoneListAltID = NULL;
2192 std::map<int, wxString> *TelephoneListPID = NULL;
2193 std::map<int, wxString> *TelephoneListTokens = NULL;
2194 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2195 std::map<int, int> *TelephoneListPref = NULL;
2199 TelephoneList = &GeneralTelephoneList;
2200 TelephoneListType = &GeneralTelephoneListType;
2201 TelephoneListAltID = &GeneralTelephoneListAltID;
2202 TelephoneListPID = &GeneralTelephoneListPID;
2203 TelephoneListTokens = &GeneralTelephoneListTokens;
2204 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2205 TelephoneListPref = &GeneralTelephoneListPref;
2208 TelephoneList = &HomeTelephoneList;
2209 TelephoneListType = &HomeTelephoneListType;
2210 TelephoneListAltID = &HomeTelephoneListAltID;
2211 TelephoneListPID = &HomeTelephoneListPID;
2212 TelephoneListTokens = &HomeTelephoneListTokens;
2213 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2214 TelephoneListPref = &HomeTelephoneListPref;
2217 TelephoneList = &BusinessTelephoneList;
2218 TelephoneListType = &BusinessTelephoneListType;
2219 TelephoneListAltID = &BusinessTelephoneListAltID;
2220 TelephoneListPID = &BusinessTelephoneListPID;
2221 TelephoneListTokens = &BusinessTelephoneListTokens;
2222 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2223 TelephoneListPref = &BusinessTelephoneListPref;
2227 // Process the properties.
2229 bool FirstToken = TRUE;
2232 SplitPoints.clear();
2233 SplitLength.clear();
2235 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2239 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2240 intiter != SplitPoints.end(); ++intiter){
2242 SLiter = SplitLength.find(intiter->first);
2244 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2246 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2247 PropertyName = PropertyElement.GetNextToken();
2248 PropertyValue = PropertyElement.GetNextToken();
2250 intPrevValue = intiter->second;
2252 CaptureString(&PropertyValue, FALSE);
2254 // Process properties.
2256 if (PropertyName == wxT("ALTID")){
2258 TelephoneListAltID->erase(*TelephoneCount);
2259 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2261 } else if (PropertyName == wxT("PID")){
2263 TelephoneListPID->erase(*TelephoneCount);
2264 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2266 } else if (PropertyName == wxT("PREF")){
2268 int PriorityNumber = 0;
2269 bool ValidNumber = TRUE;
2272 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2275 catch(std::invalid_argument &e){
2276 ValidNumber = FALSE;
2279 if (ValidNumber == TRUE){
2281 TelephoneListPref->erase(*TelephoneCount);
2282 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2288 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2290 if (FirstToken == TRUE){
2292 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2297 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2307 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2308 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2310 // Add the name token data.
2312 if (!PropertyTokens.IsEmpty()){
2314 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2320 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2322 std::map<int, int> SplitPoints;
2323 std::map<int, int> SplitLength;
2325 int intPrevValue = 6;
2328 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2332 PropertyType PropType = PROPERTY_NONE;
2334 // Look for type before continuing.
2336 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2338 std::map<int, wxString> *LanguageList = NULL;
2339 std::map<int, wxString> *LanguageListType = NULL;
2340 std::map<int, wxString> *LanguageListAltID = NULL;
2341 std::map<int, wxString> *LanguageListPID = NULL;
2342 std::map<int, wxString> *LanguageListTokens = NULL;
2343 std::map<int, int> *LanguageListPref = NULL;
2347 LanguageList = &GeneralLanguageList;
2348 LanguageListType = &GeneralLanguageListType;
2349 LanguageListAltID = &GeneralLanguageListAltID;
2350 LanguageListPID = &GeneralLanguageListPID;
2351 LanguageListTokens = &GeneralLanguageListTokens;
2352 LanguageListPref = &GeneralLanguageListPref;
2355 LanguageList = &HomeLanguageList;
2356 LanguageListType = &HomeLanguageListType;
2357 LanguageListAltID = &HomeLanguageListAltID;
2358 LanguageListPID = &HomeLanguageListPID;
2359 LanguageListTokens = &HomeLanguageListTokens;
2360 LanguageListPref = &HomeLanguageListPref;
2363 LanguageList = &BusinessLanguageList;
2364 LanguageListType = &BusinessLanguageListType;
2365 LanguageListAltID = &BusinessLanguageListAltID;
2366 LanguageListPID = &BusinessLanguageListPID;
2367 LanguageListTokens = &BusinessLanguageListTokens;
2368 LanguageListPref = &BusinessLanguageListPref;
2374 std::map<int,int>::iterator SLiter;
2375 wxString PropertyData;
2376 wxString PropertyName;
2377 wxString PropertyValue;
2378 wxString PropertyTokens;
2379 bool FirstToken = TRUE;
2381 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2382 intiter != SplitPoints.end(); ++intiter){
2384 SLiter = SplitLength.find(intiter->first);
2386 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2388 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2389 PropertyName = PropertyElement.GetNextToken();
2390 PropertyValue = PropertyElement.GetNextToken();
2392 intPrevValue = intiter->second;
2394 CaptureString(&PropertyValue, FALSE);
2396 // Process properties.
2398 if (PropertyName == wxT("ALTID")){
2400 LanguageListAltID->erase(*LanguageCount);
2401 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2403 } else if (PropertyName == wxT("PID")){
2405 LanguageListPID->erase(*LanguageCount);
2406 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2408 } else if (PropertyName == wxT("PREF")){
2410 int PriorityNumber = 0;
2411 bool ValidNumber = TRUE;
2414 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2417 catch(std::invalid_argument &e){
2418 ValidNumber = FALSE;
2421 if (ValidNumber == TRUE){
2423 LanguageListPref->erase(*LanguageCount);
2424 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2430 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2432 if (FirstToken == TRUE){
2434 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2439 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2449 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2451 // Add the name token data.
2453 if (!PropertyTokens.IsEmpty()){
2455 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2461 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2463 std::map<int, int> SplitPoints;
2464 std::map<int, int> SplitLength;
2466 int intPrevValue = 5;
2469 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2473 PropertyType PropType = PROPERTY_NONE;
2475 // Look for type before continuing.
2477 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2479 std::map<int, wxString> *GeopositionList = NULL;
2480 std::map<int, wxString> *GeopositionListType = NULL;
2481 std::map<int, wxString> *GeopositionListAltID = NULL;
2482 std::map<int, wxString> *GeopositionListPID = NULL;
2483 std::map<int, wxString> *GeopositionListTokens = NULL;
2484 std::map<int, wxString> *GeopositionListMediatype = NULL;
2485 std::map<int, int> *GeopositionListPref = NULL;
2489 GeopositionList = &GeneralGeographyList;
2490 GeopositionListType = &GeneralGeographyListType;
2491 GeopositionListAltID = &GeneralGeographyListAltID;
2492 GeopositionListPID = &GeneralGeographyListPID;
2493 GeopositionListTokens = &GeneralGeographyListTokens;
2494 GeopositionListMediatype = &GeneralGeographyListMediatype;
2495 GeopositionListPref = &GeneralGeographyListPref;
2498 GeopositionList = &HomeGeographyList;
2499 GeopositionListType = &HomeGeographyListType;
2500 GeopositionListAltID = &HomeGeographyListAltID;
2501 GeopositionListPID = &HomeGeographyListPID;
2502 GeopositionListTokens = &HomeGeographyListTokens;
2503 GeopositionListMediatype = &HomeGeographyListMediatype;
2504 GeopositionListPref = &HomeGeographyListPref;
2507 GeopositionList = &BusinessGeographyList;
2508 GeopositionListType = &BusinessGeographyListType;
2509 GeopositionListAltID = &BusinessGeographyListAltID;
2510 GeopositionListPID = &BusinessGeographyListPID;
2511 GeopositionListTokens = &BusinessGeographyListTokens;
2512 GeopositionListMediatype = &BusinessGeographyListMediatype;
2513 GeopositionListPref = &BusinessGeographyListPref;
2519 std::map<int,int>::iterator SLiter;
2520 wxString PropertyData;
2521 wxString PropertyName;
2522 wxString PropertyValue;
2523 wxString PropertyTokens;
2524 bool FirstToken = TRUE;
2526 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2527 intiter != SplitPoints.end(); ++intiter){
2529 SLiter = SplitLength.find(intiter->first);
2531 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2533 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2534 PropertyName = PropertyElement.GetNextToken();
2535 PropertyValue = PropertyElement.GetNextToken();
2537 intPrevValue = intiter->second;
2539 CaptureString(&PropertyValue, FALSE);
2541 // Process properties.
2543 if (PropertyName == wxT("ALTID")){
2545 GeopositionListAltID->erase(*GeographicCount);
2546 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2548 } else if (PropertyName == wxT("PID")){
2550 GeopositionListPID->erase(*GeographicCount);
2551 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2553 } else if (PropertyName == wxT("MEDIATYPE")){
2555 GeopositionListMediatype->erase(*GeographicCount);
2556 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2558 } else if (PropertyName == wxT("PREF")){
2560 int PriorityNumber = 0;
2561 bool ValidNumber = TRUE;
2564 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2567 catch(std::invalid_argument &e){
2568 ValidNumber = FALSE;
2571 if (ValidNumber == TRUE){
2573 GeopositionListPref->erase(*GeographicCount);
2574 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2580 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2582 if (FirstToken == TRUE){
2584 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2589 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2599 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2601 // Add the name token data.
2603 if (!PropertyTokens.IsEmpty()){
2605 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2611 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2613 size_t intPropertyLen = PropertySeg1.Len();
2614 std::map<int, int> SplitPoints;
2615 std::map<int, int> SplitLength;
2616 std::map<int, int>::iterator SLiter;
2617 wxString PropertyData;
2618 wxString PropertyName;
2619 wxString PropertyValue;
2620 wxString PropertyTokens;
2621 wxString RelatedType;
2622 wxString RelatedTypeOriginal;
2623 wxString RelatedName;
2624 bool FirstToken = TRUE;
2625 int intSplitsFound = 0;
2626 int intSplitSize = 0;
2627 int intPrevValue = 9;
2631 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2635 // Look for type before continuing.
2637 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2638 intiter != SplitPoints.end(); ++intiter){
2640 SLiter = SplitLength.find(intiter->first);
2642 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2644 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2645 PropertyName = PropertyElement.GetNextToken();
2646 PropertyValue = PropertyElement.GetNextToken();
2648 intPrevValue = intiter->second;
2652 RelatedTypeOriginal = PropertyValue;
2654 if (PropertyName == wxT("TYPE")){
2656 if (PropertyValue == wxT("contact")){
2658 RelatedType = _("Contact");
2660 } else if (PropertyValue == wxT("acquaintance")){
2662 RelatedType = _("Acquaintance");
2664 } else if (PropertyValue == wxT("friend")){
2666 RelatedType = _("Friend");
2668 } else if (PropertyValue == wxT("met")){
2670 RelatedType = _("Met");
2672 } else if (PropertyValue == wxT("co-worker")){
2674 RelatedType = _("Co-worker");
2676 } else if (PropertyValue == wxT("colleague")){
2678 RelatedType = _("Colleague");
2680 } else if (PropertyValue == wxT("co-resident")){
2682 RelatedType = _("Co-resident");
2684 } else if (PropertyValue == wxT("neighbor")){
2686 RelatedType = _("Neighbour");
2688 } else if (PropertyValue == wxT("child")){
2690 RelatedType = _("Child");
2692 } else if (PropertyValue == wxT("parent")){
2694 RelatedType = _("Parent");
2696 } else if (PropertyValue == wxT("sibling")){
2698 RelatedType = _("Sibling");
2700 } else if (PropertyValue == wxT("spouse")){
2702 RelatedType = _("Spouse");
2704 } else if (PropertyValue == wxT("kin")){
2706 RelatedType = _("Kin");
2708 } else if (PropertyValue == wxT("muse")){
2710 RelatedType = _("Muse");
2712 } else if (PropertyValue == wxT("crush")){
2714 RelatedType = _("Crush");
2716 } else if (PropertyValue == wxT("date")){
2718 RelatedType = _("Date");
2720 } else if (PropertyValue == wxT("sweetheart")){
2722 RelatedType = _("Sweetheart");
2724 } else if (PropertyValue == wxT("me")){
2726 RelatedType = _("Me");
2728 } else if (PropertyValue == wxT("agent")){
2730 RelatedType = _("Agent");
2732 } else if (PropertyValue == wxT("emergency")){
2734 RelatedType = _("Emergency");
2738 RelatedType = PropertyValue;
2748 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2749 intiter != SplitPoints.end(); ++intiter){
2751 SLiter = SplitLength.find(intiter->first);
2753 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2755 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2756 PropertyName = PropertyElement.GetNextToken();
2757 PropertyValue = PropertyElement.GetNextToken();
2759 intPrevValue = intiter->second;
2761 // Process properties.
2763 size_t intPropertyValueLen = PropertyValue.Len();
2765 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2767 PropertyValue.Trim();
2768 PropertyValue.RemoveLast();
2772 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2774 PropertyValue.Remove(0, 1);
2778 CaptureString(&PropertyValue, FALSE);
2780 if (PropertyName == wxT("ALTID")){
2782 GeneralRelatedListAltID.erase(*RelatedCount);
2783 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2785 } else if (PropertyName == wxT("PID")){
2787 GeneralRelatedListPID.erase(*RelatedCount);
2788 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2790 } else if (PropertyName == wxT("PREF")){
2792 int PriorityNumber = 0;
2793 bool ValidNumber = TRUE;
2796 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2799 catch(std::invalid_argument &e){
2800 ValidNumber = FALSE;
2803 if (ValidNumber == TRUE){
2805 GeneralRelatedListPref.erase(*RelatedCount);
2806 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2810 } else if (PropertyName == wxT("LANGUAGE")){
2812 GeneralRelatedListLanguage.erase(*RelatedCount);
2813 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2815 } else if (PropertyName != wxT("TYPE")) {
2817 // Something else we don't know about so append
2818 // to the tokens variable.
2820 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2822 if (FirstToken == TRUE){
2824 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2829 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2839 // Add the data to the General/Home/Work address variables.
2841 GeneralRelatedList.erase(*RelatedCount);
2842 GeneralRelatedListRelType.erase(*RelatedCount);
2843 GeneralRelatedListType.erase(*RelatedCount);
2844 GeneralRelatedListTokens.erase(*RelatedCount);
2845 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2846 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2847 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2848 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2852 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2854 std::map<int, int> SplitPoints;
2855 std::map<int, int> SplitLength;
2856 std::map<int, int>::iterator SLiter;
2857 wxString PropertyData;
2858 wxString PropertyName;
2859 wxString PropertyValue;
2860 wxString PropertyTokens;
2861 bool FirstToken = TRUE;
2862 int intPrevValue = 5;
2867 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2871 PropertyType PropType = PROPERTY_NONE;
2873 // Look for type before continuing.
2875 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2877 // Setup the pointers.
2879 std::map<int, wxString> *WebsiteList = NULL;
2880 std::map<int, wxString> *WebsiteListAltID = NULL;
2881 std::map<int, wxString> *WebsiteListPID = NULL;
2882 std::map<int, wxString> *WebsiteListType = NULL;
2883 std::map<int, wxString> *WebsiteListTokens = NULL;
2884 std::map<int, wxString> *WebsiteListMediatype = NULL;
2885 std::map<int, int> *WebsiteListPref = NULL;
2887 // Setup blank lines for later on.
2891 WebsiteList = &GeneralWebsiteList;
2892 WebsiteListType = &GeneralWebsiteListType;
2893 WebsiteListAltID = &GeneralWebsiteListAltID;
2894 WebsiteListPID = &GeneralWebsiteListPID;
2895 WebsiteListTokens = &GeneralWebsiteListTokens;
2896 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2897 WebsiteListPref = &GeneralWebsiteListPref;
2900 WebsiteList = &HomeWebsiteList;
2901 WebsiteListType = &HomeWebsiteListType;
2902 WebsiteListAltID = &HomeWebsiteListAltID;
2903 WebsiteListPID = &HomeWebsiteListPID;
2904 WebsiteListTokens = &HomeWebsiteListTokens;
2905 WebsiteListMediatype = &HomeWebsiteListMediatype;
2906 WebsiteListPref = &HomeWebsiteListPref;
2909 WebsiteList = &BusinessWebsiteList;
2910 WebsiteListType = &BusinessWebsiteListType;
2911 WebsiteListAltID = &BusinessWebsiteListAltID;
2912 WebsiteListPID = &BusinessWebsiteListPID;
2913 WebsiteListTokens = &BusinessWebsiteListTokens;
2914 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2915 WebsiteListPref = &BusinessWebsiteListPref;
2921 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2922 intiter != SplitPoints.end(); ++intiter){
2924 SLiter = SplitLength.find(intiter->first);
2926 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2928 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2929 PropertyName = PropertyElement.GetNextToken();
2930 PropertyValue = PropertyElement.GetNextToken();
2932 intPrevValue = intiter->second;
2934 // Process properties.
2936 size_t intPropertyValueLen = PropertyValue.Len();
2938 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2940 PropertyValue.Trim();
2941 PropertyValue.RemoveLast();
2945 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2947 PropertyValue.Remove(0, 1);
2951 CaptureString(&PropertyValue, FALSE);
2953 if (PropertyName == wxT("ALTID")){
2955 WebsiteListAltID->erase(*URLCount);
2956 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2958 } else if (PropertyName == wxT("PID")){
2960 WebsiteListPID->erase(*URLCount);
2961 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2963 } else if (PropertyName == wxT("PREF")){
2965 int PriorityNumber = 0;
2966 bool ValidNumber = TRUE;
2969 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2972 catch(std::invalid_argument &e){
2973 ValidNumber = FALSE;
2976 if (ValidNumber == TRUE){
2978 WebsiteListPref->erase(*URLCount);
2979 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2983 } else if (PropertyName == wxT("MEDIATYPE")){
2985 WebsiteListMediatype->erase(*URLCount);
2986 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2990 // Something else we don't know about so append
2991 // to the tokens variable.
2993 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2995 if (FirstToken == TRUE){
2997 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3002 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3012 // Add the data to the General/Home/Work address variables.
3014 CaptureString(&PropertySeg2, FALSE);
3016 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3018 if (!PropertyTokens.IsEmpty()){
3020 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3026 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3028 std::map<int, int> SplitPoints;
3029 std::map<int, int> SplitLength;
3030 std::map<int, int>::iterator SLiter;
3031 wxString PropertyData;
3032 wxString PropertyName;
3033 wxString PropertyValue;
3034 wxString PropertyTokens;
3035 bool FirstToken = TRUE;
3036 int intPrevValue = 7;
3041 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3045 PropertyType PropType = PROPERTY_NONE;
3047 // Look for type before continuing.
3049 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3051 // Setup the pointers.
3053 std::map<int, wxString> *TitleList = NULL;
3054 std::map<int, wxString> *TitleListAltID = NULL;
3055 std::map<int, wxString> *TitleListPID = NULL;
3056 std::map<int, wxString> *TitleListType = NULL;
3057 std::map<int, wxString> *TitleListTokens = NULL;
3058 std::map<int, wxString> *TitleListLanguage = NULL;
3059 std::map<int, int> *TitleListPref = NULL;
3061 // Setup blank lines for later on.
3065 TitleList = &GeneralTitleList;
3066 TitleListType = &GeneralTitleListType;
3067 TitleListAltID = &GeneralTitleListAltID;
3068 TitleListPID = &GeneralTitleListPID;
3069 TitleListTokens = &GeneralTitleListTokens;
3070 TitleListLanguage = &GeneralTitleListLanguage;
3071 TitleListPref = &GeneralTitleListPref;
3074 TitleList = &HomeTitleList;
3075 TitleListType = &HomeTitleListType;
3076 TitleListAltID = &HomeTitleListAltID;
3077 TitleListPID = &HomeTitleListPID;
3078 TitleListTokens = &HomeTitleListTokens;
3079 TitleListLanguage = &HomeTitleListLanguage;
3080 TitleListPref = &HomeTitleListPref;
3083 TitleList = &BusinessTitleList;
3084 TitleListType = &BusinessTitleListType;
3085 TitleListAltID = &BusinessTitleListAltID;
3086 TitleListPID = &BusinessTitleListPID;
3087 TitleListTokens = &BusinessTitleListTokens;
3088 TitleListLanguage = &BusinessTitleListLanguage;
3089 TitleListPref = &BusinessTitleListPref;
3095 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3096 intiter != SplitPoints.end(); ++intiter){
3098 SLiter = SplitLength.find(intiter->first);
3100 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3102 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3103 PropertyName = PropertyElement.GetNextToken();
3104 PropertyValue = PropertyElement.GetNextToken();
3106 intPrevValue = intiter->second;
3108 // Process properties.
3110 size_t intPropertyValueLen = PropertyValue.Len();
3112 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3114 PropertyValue.Trim();
3115 PropertyValue.RemoveLast();
3119 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3121 PropertyValue.Remove(0, 1);
3125 CaptureString(&PropertyValue, FALSE);
3127 if (PropertyName == wxT("ALTID")){
3129 TitleListAltID->erase(*TitleCount);
3130 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3132 } else if (PropertyName == wxT("PID")){
3134 TitleListPID->erase(*TitleCount);
3135 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3137 } else if (PropertyName == wxT("PREF")){
3139 int PriorityNumber = 0;
3140 bool ValidNumber = TRUE;
3143 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3146 catch(std::invalid_argument &e){
3147 ValidNumber = FALSE;
3150 if (ValidNumber == TRUE){
3152 TitleListPref->erase(*TitleCount);
3153 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3157 } else if (PropertyName == wxT("LANGUAGE")){
3159 TitleListLanguage->erase(*TitleCount);
3160 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3164 // Something else we don't know about so append
3165 // to the tokens variable.
3167 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3169 if (FirstToken == TRUE){
3171 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3176 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3186 // Add the data to the General/Home/Work address variables.
3188 CaptureString(&PropertySeg2, FALSE);
3190 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3192 if (!PropertyTokens.IsEmpty()){
3194 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3200 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3202 std::map<int, int> SplitPoints;
3203 std::map<int, int> SplitLength;
3204 std::map<int, int>::iterator SLiter;
3205 wxString PropertyData;
3206 wxString PropertyName;
3207 wxString PropertyValue;
3208 wxString PropertyTokens;
3209 bool FirstToken = TRUE;
3210 int intPrevValue = 6;
3215 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3219 PropertyType PropType = PROPERTY_NONE;
3221 // Look for type before continuing.
3223 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3225 // Setup the pointers.
3227 std::map<int, wxString> *RoleList = NULL;
3228 std::map<int, wxString> *RoleListAltID = NULL;
3229 std::map<int, wxString> *RoleListPID = NULL;
3230 std::map<int, wxString> *RoleListType = NULL;
3231 std::map<int, wxString> *RoleListTokens = NULL;
3232 std::map<int, wxString> *RoleListLanguage = NULL;
3233 std::map<int, int> *RoleListPref = NULL;
3235 // Setup blank lines for later on.
3239 RoleList = &GeneralRoleList;
3240 RoleListType = &GeneralRoleListType;
3241 RoleListAltID = &GeneralRoleListAltID;
3242 RoleListPID = &GeneralRoleListPID;
3243 RoleListTokens = &GeneralRoleListTokens;
3244 RoleListLanguage = &GeneralRoleListLanguage;
3245 RoleListPref = &GeneralRoleListPref;
3248 RoleList = &HomeRoleList;
3249 RoleListType = &HomeRoleListType;
3250 RoleListAltID = &HomeRoleListAltID;
3251 RoleListPID = &HomeRoleListPID;
3252 RoleListTokens = &HomeRoleListTokens;
3253 RoleListLanguage = &HomeRoleListLanguage;
3254 RoleListPref = &HomeRoleListPref;
3257 RoleList = &BusinessRoleList;
3258 RoleListType = &BusinessRoleListType;
3259 RoleListAltID = &BusinessRoleListAltID;
3260 RoleListPID = &BusinessRoleListPID;
3261 RoleListTokens = &BusinessRoleListTokens;
3262 RoleListLanguage = &BusinessRoleListLanguage;
3263 RoleListPref = &BusinessRoleListPref;
3269 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3270 intiter != SplitPoints.end(); ++intiter){
3272 SLiter = SplitLength.find(intiter->first);
3274 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3276 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3277 PropertyName = PropertyElement.GetNextToken();
3278 PropertyValue = PropertyElement.GetNextToken();
3280 intPrevValue = intiter->second;
3282 // Process properties.
3284 size_t intPropertyValueLen = PropertyValue.Len();
3286 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3288 PropertyValue.Trim();
3289 PropertyValue.RemoveLast();
3293 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3295 PropertyValue.Remove(0, 1);
3299 CaptureString(&PropertyValue, FALSE);
3301 if (PropertyName == wxT("ALTID")){
3303 RoleListAltID->erase(*RoleCount);
3304 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3306 } else if (PropertyName == wxT("PID")){
3308 RoleListPID->erase(*RoleCount);
3309 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3311 } else if (PropertyName == wxT("PREF")){
3313 int PriorityNumber = 0;
3314 bool ValidNumber = TRUE;
3317 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3320 catch(std::invalid_argument &e){
3321 ValidNumber = FALSE;
3324 if (ValidNumber == TRUE){
3326 RoleListPref->erase(*RoleCount);
3327 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3331 } else if (PropertyName == wxT("LANGUAGE")){
3333 RoleListLanguage->erase(*RoleCount);
3334 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3338 // Something else we don't know about so append
3339 // to the tokens variable.
3341 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3343 if (FirstToken == TRUE){
3345 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3350 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3360 // Add the data to the General/Home/Work address variables.
3362 CaptureString(&PropertySeg2, FALSE);
3364 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3366 if (!PropertyTokens.IsEmpty()){
3368 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3374 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3376 std::map<int, int> SplitPoints;
3377 std::map<int, int> SplitLength;
3378 std::map<int, int>::iterator SLiter;
3379 wxString PropertyData;
3380 wxString PropertyName;
3381 wxString PropertyValue;
3382 wxString PropertyTokens;
3383 bool FirstToken = TRUE;
3384 int intPrevValue = 5;
3389 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3393 PropertyType PropType = PROPERTY_NONE;
3395 // Look for type before continuing.
3397 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3399 // Setup the pointers.
3401 std::map<int, wxString> *OrganisationsList = NULL;
3402 std::map<int, wxString> *OrganisationsListAltID = NULL;
3403 std::map<int, wxString> *OrganisationsListPID = NULL;
3404 std::map<int, wxString> *OrganisationsListType = NULL;
3405 std::map<int, wxString> *OrganisationsListTokens = NULL;
3406 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3407 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3408 std::map<int, int> *OrganisationsListPref = NULL;
3410 // Setup blank lines for later on.
3414 OrganisationsList = &GeneralOrganisationsList;
3415 OrganisationsListType = &GeneralOrganisationsListType;
3416 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3417 OrganisationsListPID = &GeneralOrganisationsListPID;
3418 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3419 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3420 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3421 OrganisationsListPref = &GeneralOrganisationsListPref;
3424 OrganisationsList = &HomeOrganisationsList;
3425 OrganisationsListType = &HomeOrganisationsListType;
3426 OrganisationsListAltID = &HomeOrganisationsListAltID;
3427 OrganisationsListPID = &HomeOrganisationsListPID;
3428 OrganisationsListTokens = &HomeOrganisationsListTokens;
3429 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3430 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3431 OrganisationsListPref = &HomeOrganisationsListPref;
3434 OrganisationsList = &BusinessOrganisationsList;
3435 OrganisationsListType = &BusinessOrganisationsListType;
3436 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3437 OrganisationsListPID = &BusinessOrganisationsListPID;
3438 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3439 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3440 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3441 OrganisationsListPref = &BusinessOrganisationsListPref;
3447 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3448 intiter != SplitPoints.end(); ++intiter){
3450 SLiter = SplitLength.find(intiter->first);
3452 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3454 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3455 PropertyName = PropertyElement.GetNextToken();
3456 PropertyValue = PropertyElement.GetNextToken();
3458 intPrevValue = intiter->second;
3460 // Process properties.
3462 size_t intPropertyValueLen = PropertyValue.Len();
3464 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3466 PropertyValue.Trim();
3467 PropertyValue.RemoveLast();
3471 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3473 PropertyValue.Remove(0, 1);
3477 CaptureString(&PropertyValue, FALSE);
3479 if (PropertyName == wxT("ALTID")){
3481 OrganisationsListAltID->erase(*OrganisationCount);
3482 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3484 } else if (PropertyName == wxT("PID")){
3486 OrganisationsListPID->erase(*OrganisationCount);
3487 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3489 } else if (PropertyName == wxT("SORT-AS")){
3491 OrganisationsListSortAs->erase(*OrganisationCount);
3492 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3494 } else if (PropertyName == wxT("PREF")){
3496 int PriorityNumber = 0;
3497 bool ValidNumber = TRUE;
3500 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3503 catch(std::invalid_argument &e){
3504 ValidNumber = FALSE;
3507 if (ValidNumber == TRUE){
3509 OrganisationsListPref->erase(*OrganisationCount);
3510 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3514 } else if (PropertyName == wxT("LANGUAGE")){
3516 OrganisationsListLanguage->erase(*OrganisationCount);
3517 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3521 // Something else we don't know about so append
3522 // to the tokens variable.
3524 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3526 if (FirstToken == TRUE){
3528 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3533 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3543 // Add the data to the General/Home/Work address variables.
3545 CaptureString(&PropertySeg2, FALSE);
3547 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3549 if (!PropertyTokens.IsEmpty()){
3551 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3557 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3559 std::map<int, int> SplitPoints;
3560 std::map<int, int> SplitLength;
3561 std::map<int, int>::iterator SLiter;
3562 wxString PropertyData;
3563 wxString PropertyName;
3564 wxString PropertyValue;
3565 wxString PropertyTokens;
3566 bool FirstToken = TRUE;
3567 int intPrevValue = 6;
3572 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3576 PropertyType PropType = PROPERTY_NONE;
3578 // Look for type before continuing.
3580 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3582 // Setup the pointers.
3584 std::map<int, wxString> *NoteList = NULL;
3585 std::map<int, wxString> *NoteListAltID = NULL;
3586 std::map<int, wxString> *NoteListPID = NULL;
3587 std::map<int, wxString> *NoteListType = NULL;
3588 std::map<int, wxString> *NoteListTokens = NULL;
3589 std::map<int, wxString> *NoteListLanguage = NULL;
3590 std::map<int, wxString> *NoteListSortAs = NULL;
3591 std::map<int, int> *NoteListPref = NULL;
3593 // Setup blank lines for later on.
3597 NoteList = &GeneralNoteList;
3598 NoteListType = &GeneralNoteListType;
3599 NoteListAltID = &GeneralNoteListAltID;
3600 NoteListPID = &GeneralNoteListPID;
3601 NoteListTokens = &GeneralNoteListTokens;
3602 NoteListLanguage = &GeneralNoteListLanguage;
3603 NoteListPref = &GeneralNoteListPref;
3606 NoteList = &HomeNoteList;
3607 NoteListType = &HomeNoteListType;
3608 NoteListAltID = &HomeNoteListAltID;
3609 NoteListPID = &HomeNoteListPID;
3610 NoteListTokens = &HomeNoteListTokens;
3611 NoteListLanguage = &HomeNoteListLanguage;
3612 NoteListPref = &HomeNoteListPref;
3615 NoteList = &BusinessNoteList;
3616 NoteListType = &BusinessNoteListType;
3617 NoteListAltID = &BusinessNoteListAltID;
3618 NoteListPID = &BusinessNoteListPID;
3619 NoteListTokens = &BusinessNoteListTokens;
3620 NoteListLanguage = &BusinessNoteListLanguage;
3621 NoteListPref = &BusinessNoteListPref;
3627 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3628 intiter != SplitPoints.end(); ++intiter){
3630 SLiter = SplitLength.find(intiter->first);
3632 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3634 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3635 PropertyName = PropertyElement.GetNextToken();
3636 PropertyValue = PropertyElement.GetNextToken();
3638 intPrevValue = intiter->second;
3640 // Process properties.
3642 size_t intPropertyValueLen = PropertyValue.Len();
3644 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3646 PropertyValue.Trim();
3647 PropertyValue.RemoveLast();
3651 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3653 PropertyValue.Remove(0, 1);
3657 CaptureString(&PropertyValue, FALSE);
3659 if (PropertyName == wxT("ALTID")){
3661 NoteListAltID->erase(*NoteCount);
3662 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3664 } else if (PropertyName == wxT("PID")){
3666 NoteListPID->erase(*NoteCount);
3667 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3669 } else if (PropertyName == wxT("SORT-AS")){
3671 NoteListSortAs->erase(*NoteCount);
3672 NoteListSortAs->insert(std::make_pair(*NoteCount, PropertyValue));
3674 } else if (PropertyName == wxT("PREF")){
3676 int PriorityNumber = 0;
3677 bool ValidNumber = TRUE;
3680 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3683 catch(std::invalid_argument &e){
3684 ValidNumber = FALSE;
3687 if (ValidNumber == TRUE){
3689 NoteListPref->erase(*NoteCount);
3690 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3694 } else if (PropertyName == wxT("LANGUAGE")){
3696 NoteListLanguage->erase(*NoteCount);
3697 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3701 // Something else we don't know about so append
3702 // to the tokens variable.
3704 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3706 if (FirstToken == TRUE){
3708 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3713 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3723 // Add the data to the General/Home/Work address variables.
3725 CaptureString(&PropertySeg2, FALSE);
3727 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3729 if (!PropertyTokens.IsEmpty()){
3731 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3737 void SplitValues(wxString *PropertyLine,
3738 std::map<int,int> *SplitPoints,
3739 std::map<int,int> *SplitLength,
3742 size_t intPropertyLen = PropertyLine->Len();
3743 int intSplitsFound = 0;
3744 int intSplitSize = 0;
3745 int intSplitSeek = 0;
3747 for (int i = intSize; i <= intPropertyLen; i++){
3751 if (PropertyLine->Mid(i, 1) == wxT(";") &&
3752 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
3754 if (intSplitsFound == 0){
3756 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
3760 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3764 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
3774 if (intSplitsFound == 0){
3776 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
3777 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3781 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3782 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3788 void CheckType(wxString *PropertySeg1,
3789 std::map<int,int> *SplitPoints,
3790 std::map<int,int> *SplitLength,
3792 PropertyType *PropType){
3794 wxString PropertyData;
3795 wxString PropertyName;
3796 wxString PropertyValue;
3797 std::map<int,int>::iterator SLiter;
3799 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
3800 intiter != SplitPoints->end(); ++intiter){
3802 SLiter = SplitLength->find(intiter->first);
3804 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
3806 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3807 PropertyName = PropertyElement.GetNextToken();
3808 PropertyValue = PropertyElement.GetNextToken();
3810 *intPrevValue = intiter->second;
3812 if (PropertyName == wxT("TYPE")){
3814 if (PropertyValue == wxT("work")){
3816 *PropType = PROPERTY_WORK;
3818 } else if (PropertyValue == wxT("home")){
3820 *PropType = PROPERTY_HOME;
3824 *PropType = PROPERTY_NONE;