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 bool UIDProcessed = FALSE;
82 bool RevisionProcessed = FALSE;
83 int ContactLineLen = 0;
84 int QuoteBreakPoint = 0;
88 int NicknameCount = 0;
89 int TimeZoneCount = 0;
93 int TelephoneCount = 0;
94 int LanguageCount = 0;
95 int GeographicCount = 0;
100 int OrganisationCount = 0;
102 int CategoryCount = 0;
106 int CalendarCount = 0;
107 int CalendarAddressCount = 0;
108 int FreeBusyAddressCount = 0;
113 wxString ContactLine;
114 wxString PropertyLine;
115 wxString PropertySeg1;
116 wxString PropertySeg2;
117 wxString PropertyNextLine;
120 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
121 iter != ContactFileLines.end(); ++iter){
123 ExtraLineSeek = TRUE;
129 PropertyLine.Clear();
130 PropertySeg1.Clear();
131 PropertySeg2.Clear();
134 ContactLine = iter->second;
136 while (ExtraLineSeek == TRUE){
138 // Check if there is extra data on the next line
139 // (indicated by space or tab at the start) and add data.
143 if (iter == ContactFileLines.end()){
150 PropertyNextLine = iter->second;
152 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
154 PropertyNextLine.Remove(0, 1);
155 ContactLine.Append(PropertyNextLine);
160 ExtraLineSeek = FALSE;
166 ContactLineLen = ContactLine.Len();
168 // Make sure we are not in quotation mode.
169 // Make sure colon does not have \ or \\ before it.
171 for (int i = 0; i <= ContactLineLen; i++){
173 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
175 PropertyFind = FALSE;
177 } else if (PropertyFind == TRUE){
179 Property.Append(ContactLine.Mid(i, 1));
183 if (ContactLine.Mid(i, 1) == wxT("\"")){
185 if (QuoteMode == TRUE){
197 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
206 // Split that line at the point into two variables (ignore the colon).
208 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
209 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
211 if (Property == wxT("KIND") && KindProcessed == FALSE){
213 ProcessKind(PropertySeg2);
215 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
217 UIDToken = PropertySeg2;
220 } else if (Property == wxT("SOURCE")){
222 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
225 } else if (Property == wxT("XML")){
227 ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
230 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
232 ProcessRevision(PropertySeg1, PropertySeg2);
233 RevisionProcessed = TRUE;
235 } else if (Property == wxT("MEMBER")){
237 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
240 } else if (Property == wxT("FN")){
242 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
245 } else if (Property == wxT("N") && NameProcessed == FALSE){
247 ProcessN(PropertySeg1, PropertySeg2);
248 NameProcessed = TRUE;
250 } else if (Property == wxT("NICKNAME")){
252 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
255 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
257 ProcessGender(PropertySeg1, PropertySeg2);
258 GenderProcessed = TRUE;
260 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
262 ProcessBirthday(PropertySeg1, PropertySeg2);
263 BirthdayProcessed = TRUE;
265 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
267 ProcessAnniversary(PropertySeg1, PropertySeg2);
268 AnniversaryProcessed = TRUE;
270 } else if (Property == wxT("TZ")){
272 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
275 } else if (Property == wxT("ADR")){
277 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
280 } else if (Property == wxT("EMAIL")){
282 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
285 } else if (Property == wxT("IMPP")){
287 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
290 } else if (Property == wxT("TEL")){
292 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
295 } else if (Property == wxT("LANG")){
297 // See frmContactEditor-LoadLanguage.cpp
299 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
302 } else if (Property == wxT("GEO")){
304 // See frmContactEditor-LoadGeo.cpp
306 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
309 } else if (Property == wxT("RELATED")){
311 // See fromContactEditor-LoadRelated.cpp
313 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
316 } else if (Property == wxT("URL")){
318 // See frmContactEditor-LoadURL.cpp
320 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
323 } else if (Property == wxT("TITLE")) {
325 // See frmContactEditor-LoadTitle.cpp
327 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
330 } else if (Property == wxT("ROLE")) {
332 // See frmContactEditor-LoadTitle.cpp
334 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
337 } else if (Property == wxT("ORG")) {
339 // See frmContactEditor-LoadOrg.cpp
341 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
344 } else if (Property == wxT("NOTE")) {
346 // See frmContactEditor-LoadNote.cpp
348 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
351 } else if (Property == wxT("CATEGORIES")) {
353 // See frmContactEditor-LoadCategory.cpp
355 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
358 } else if (Property == wxT("PHOTO")) {
360 // See frmContactEditor-LoadPhoto.cpp
362 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
365 } else if (Property == wxT("LOGO")) {
367 // See frmContactEditor-LoadPhoto.cpp
369 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
372 } else if (Property == wxT("LOGO")) {
374 // See frmContactEditor-LoadPhoto.cpp
376 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
379 } else if (Property == wxT("SOUND")) {
381 // See frmContactEditor-LoadSound.cpp
383 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
386 } else if (Property == wxT("CALURI")){
388 // See frmContactEditor-LoadCalendar.cpp
390 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
393 } else if (Property == wxT("CALADRURI")){
395 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
396 CalendarAddressCount++;
398 } else if (Property == wxT("FBURL")){
400 // See frmContactEditor-LoadCalendar.cpp
402 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
403 FreeBusyAddressCount++;
405 } else if (Property == wxT("KEY")){
407 // See frmContactEditor-LoadKey.cpp
409 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
412 } else if (Property.Mid(0, 3) == wxT("VND")){
414 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
417 } else if (Property.Mid(0, 2) == wxT("X-")){
419 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
420 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
427 return CONTACTLOAD_OK;
431 void ContactDataObject::ProcessKind(wxString KindType){
433 if (KindType == wxT("individual")){
435 ContactKind = CONTACTKIND_INDIVIDUAL;
437 } else if (KindType == wxT("group")){
439 ContactKind = CONTACTKIND_GROUP;
441 } else if (KindType == wxT("org")){
443 ContactKind = CONTACTKIND_ORGANISATION;
445 } else if (KindType == wxT("location")){
447 ContactKind = CONTACTKIND_LOCATION;
451 ContactKind = CONTACTKIND_NONE;
456 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
458 size_t intPropertyLen = PropertySeg1.Len();
459 std::map<int, int> SplitPoints;
460 std::map<int, int> SplitLength;
461 std::map<int, int>::iterator SLiter;
462 wxString PropertyData;
463 wxString PropertyName;
464 wxString PropertyValue;
465 wxString PropertyTokens;
466 bool FirstToken = TRUE;
467 int intSplitsFound = 0;
468 int intSplitSize = 0;
469 int intPrevValue = 5;
473 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
477 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
478 intiter != SplitPoints.end(); ++intiter){
480 SLiter = SplitLength.find(intiter->first);
482 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
484 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
485 PropertyName = PropertyElement.GetNextToken();
486 PropertyValue = PropertyElement.GetNextToken();
488 intPrevValue = intiter->second;
490 // Process properties.
492 size_t intPropertyValueLen = PropertyValue.Len();
494 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
496 PropertyValue.Trim();
497 PropertyValue.RemoveLast();
501 if (PropertyValue.Mid(0, 1) == wxT("\"")){
503 PropertyValue.Remove(0, 1);
507 CaptureString(&PropertyValue, FALSE);
509 if (FirstToken == TRUE){
511 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
516 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
522 CaptureString(&PropertySeg2, FALSE);
524 Revision = PropertySeg2;
526 if (!PropertyTokens.IsEmpty()){
528 RevisionTokens = PropertyTokens;
535 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
537 size_t intPropertyLen = PropertySeg1.Len();
538 std::map<int, int> SplitPoints;
539 std::map<int, int> SplitLength;
540 std::map<int, int>::iterator SLiter;
541 wxString PropertyData;
542 wxString PropertyName;
543 wxString PropertyValue;
544 wxString PropertyTokens;
545 bool FirstToken = TRUE;
546 int intSplitsFound = 0;
547 int intSplitSize = 0;
548 int intPrevValue = 8;
552 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
556 PropertyType PropType = PROPERTY_NONE;
558 // Look for type before continuing.
560 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
564 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
565 intiter != SplitPoints.end(); ++intiter){
567 SLiter = SplitLength.find(intiter->first);
569 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
571 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
572 PropertyName = PropertyElement.GetNextToken();
573 PropertyValue = PropertyElement.GetNextToken();
575 intPrevValue = intiter->second;
577 // Process properties.
579 size_t intPropertyValueLen = PropertyValue.Len();
581 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
583 PropertyValue.Trim();
584 PropertyValue.RemoveLast();
588 if (PropertyValue.Mid(0, 1) == wxT("\"")){
590 PropertyValue.Remove(0, 1);
594 CaptureString(&PropertyValue, FALSE);
596 if (PropertyName == wxT("ALTID")){
598 SourceListAltID.erase(*SourceCount);
599 SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
601 } else if (PropertyName == wxT("PID")){
603 SourceListPID.erase(*SourceCount);
604 SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
606 } else if (PropertyName == wxT("PREF")){
608 int PriorityNumber = 0;
609 bool ValidNumber = TRUE;
612 PriorityNumber = std::stoi(PropertyValue.ToStdString());
615 catch(std::invalid_argument &e){
619 if (ValidNumber == TRUE){
621 SourceListPref.erase(*SourceCount);
622 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
626 } else if (PropertyName == wxT("MEDIATYPE")){
628 SourceListMediatype.erase(*SourceCount);
629 SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
633 // Something else we don't know about so append
634 // to the tokens variable.
636 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
638 if (FirstToken == TRUE){
640 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
645 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
655 intPropertyLen = PropertySeg2.Len();
662 CaptureString(&PropertySeg2, FALSE);
664 // Add the data to the General/Home/Work address variables.
670 SourceListType.insert(std::make_pair(*SourceCount, "home"));
673 SourceListType.insert(std::make_pair(*SourceCount, "work"));
677 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
679 if (!PropertyTokens.IsEmpty()){
681 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
687 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
689 std::map<int, int> SplitPoints;
690 std::map<int, int> SplitLength;
692 int intPrevValue = 5;
696 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
700 wxString PropertyName;
701 wxString PropertyValue;
702 wxString PropertyData;
703 wxString PropertyTokens;
704 std::map<int,int>::iterator SLiter;
705 bool FirstToken = TRUE;
707 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
708 intiter != SplitPoints.end(); ++intiter){
710 SLiter = SplitLength.find(intiter->first);
712 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
714 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
715 PropertyName = PropertyElement.GetNextToken();
716 PropertyValue = PropertyElement.GetNextToken();
718 intPrevValue = intiter->second;
720 CaptureString(&PropertyValue, FALSE);
722 if (PropertyName == wxT("ALTID")){
724 XMLListAltID.erase(*XMLCount);
725 XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
731 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
735 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
737 std::map<int, int> SplitPoints;
738 std::map<int, int> SplitLength;
740 int intPrevValue = 8;
744 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
748 wxString PropertyName;
749 wxString PropertyValue;
750 wxString PropertyData;
751 wxString PropertyTokens;
752 std::map<int,int>::iterator SLiter;
753 bool FirstToken = TRUE;
755 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
756 intiter != SplitPoints.end(); ++intiter){
758 SLiter = SplitLength.find(intiter->first);
760 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
762 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
763 PropertyName = PropertyElement.GetNextToken();
764 PropertyValue = PropertyElement.GetNextToken();
766 intPrevValue = intiter->second;
768 CaptureString(&PropertyValue, FALSE);
770 if (PropertyName == wxT("ALTID")){
772 GroupsListAltID.erase(*GroupCount);
773 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
775 } else if (PropertyName == wxT("PID")){
777 GroupsListPID.erase(*GroupCount);
778 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
780 } else if (PropertyName == wxT("PREF")){
782 int PriorityNumber = 0;
783 bool ValidNumber = TRUE;
786 PriorityNumber = std::stoi(PropertyValue.ToStdString());
789 catch(std::invalid_argument &e){
793 if (ValidNumber == TRUE){
795 GroupsListPref.erase(*GroupCount);
796 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
800 } else if (PropertyName == wxT("MEDIATYPE")){
802 GroupsListMediaType.erase(*GroupCount);
803 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
805 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
807 if (FirstToken == TRUE){
809 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
814 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
822 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
824 if (!PropertyTokens.IsEmpty()){
826 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
833 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
835 std::map<int, int> SplitPoints;
836 std::map<int, int> SplitLength;
838 int intPrevValue = 4;
842 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
846 wxString PropertyName;
847 wxString PropertyValue;
848 wxString PropertyData;
849 wxString PropertyTokens;
850 std::map<int,int>::iterator SLiter;
851 bool FirstToken = TRUE;
853 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
854 intiter != SplitPoints.end(); ++intiter){
856 SLiter = SplitLength.find(intiter->first);
858 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
860 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
861 PropertyName = PropertyElement.GetNextToken();
862 PropertyValue = PropertyElement.GetNextToken();
864 intPrevValue = intiter->second;
866 CaptureString(&PropertyValue, FALSE);
868 if (PropertyName == wxT("TYPE")){
870 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
871 PropertyValue == wxT("work") ){
873 FullNamesListType.erase(*FNCount);
874 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
878 } else if (PropertyName == wxT("LANGUAGE")){
880 FullNamesListLanguage.erase(*FNCount);
881 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
883 } else if (PropertyName == wxT("ALTID")){
885 FullNamesListAltID.erase(*FNCount);
886 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
888 } else if (PropertyName == wxT("PID")){
890 FullNamesListPID.erase(*FNCount);
891 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
893 } else if (PropertyName == wxT("PREF")){
895 int PriorityNumber = 0;
896 bool ValidNumber = TRUE;
899 PriorityNumber = std::stoi(PropertyValue.ToStdString());
902 catch(std::invalid_argument &e){
906 if (ValidNumber == TRUE){
908 FullNamesListPref.erase(*FNCount);
909 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
913 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
915 if (FirstToken == TRUE){
917 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
922 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
930 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
932 if (!PropertyTokens.IsEmpty()){
934 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
940 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
942 std::map<int, int> SplitPoints;
943 std::map<int, int> SplitLength;
945 int intPrevValue = 3;
949 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
953 wxString PropertyName;
954 wxString PropertyValue;
955 wxString PropertyData;
956 wxString PropertyTokens;
957 std::map<int,int>::iterator SLiter;
958 bool FirstToken = TRUE;
960 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
961 intiter != SplitPoints.end(); ++intiter){
963 SLiter = SplitLength.find(intiter->first);
965 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
967 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
968 PropertyName = PropertyElement.GetNextToken();
969 PropertyValue = PropertyElement.GetNextToken();
971 intPrevValue = intiter->second;
973 CaptureString(&PropertyValue, FALSE);
975 if (PropertyName == wxT("ALTID")){
977 NameAltID = PropertyValue;
979 } else if (PropertyName == wxT("LANGUAGE")){
981 NameLanguage = PropertyValue;
983 } else if (PropertyName == wxT("SORT-AS")){
985 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
986 PropertyValue.Len() >= 3){
987 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
990 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
992 if (FirstToken == TRUE){
994 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
999 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1007 // Split the name data.
1009 int intSplitSeek = 0;
1010 int intSplitsFound = 0;
1011 int intSplitSize = 0;
1012 int intPropertyLen = PropertySeg2.Len();
1014 std::map<int,wxString> NameValues;
1017 for (int i = 0; i <= intPropertyLen; i++){
1019 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1021 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
1026 if (intSplitsFound == 4){
1028 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1042 // Split the data into several parts.
1044 for (std::map<int, wxString>::iterator iter = NameValues.begin();
1045 iter != NameValues.end(); ++iter){
1047 if (iter->first == 1){
1049 // Deal with family name.
1051 NameSurname = iter->second;
1053 } else if (iter->first == 2){
1055 // Deal with given names.
1057 NameForename = iter->second;
1059 } else if (iter->first == 3){
1061 // Deal with additional names.
1063 NameOtherNames = iter->second;
1065 } else if (iter->first == 4){
1067 // Deal with honorifix prefixes and suffixes.
1069 NameTitle = iter->second;
1073 if (iter == NameValues.end()){
1079 NameSuffix = iter->second;
1085 // Add the name token data.
1087 if (!PropertyTokens.IsEmpty()){
1089 NameTokens = PropertyTokens;
1095 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1097 std::map<int, int> SplitPoints;
1098 std::map<int, int> SplitLength;
1100 int intPrevValue = 10;
1103 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1107 PropertyType PropType = PROPERTY_NONE;
1109 // Look for type before continuing.
1111 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1115 std::map<int, wxString> *NicknamesList = NULL;
1116 std::map<int, wxString> *NicknamesListType = NULL;
1117 std::map<int, wxString> *NicknamesListLanguage = NULL;
1118 std::map<int, wxString> *NicknamesListAltID = NULL;
1119 std::map<int, wxString> *NicknamesListPID = NULL;
1120 std::map<int, wxString> *NicknamesListTokens = NULL;
1121 std::map<int, int> *NicknamesListPref = NULL;
1125 NicknamesList = &GeneralNicknamesList;
1126 NicknamesListType = &GeneralNicknamesListType;
1127 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1128 NicknamesListAltID = &GeneralNicknamesListAltID;
1129 NicknamesListPID = &GeneralNicknamesListPID;
1130 NicknamesListTokens = &GeneralNicknamesListTokens;
1131 NicknamesListPref = &GeneralNicknamesListPref;
1134 NicknamesList = &HomeNicknamesList;
1135 NicknamesListType = &HomeNicknamesListType;
1136 NicknamesListLanguage = &HomeNicknamesListLanguage;
1137 NicknamesListAltID = &HomeNicknamesListAltID;
1138 NicknamesListPID = &HomeNicknamesListPID;
1139 NicknamesListTokens = &HomeNicknamesListTokens;
1140 NicknamesListPref = &HomeNicknamesListPref;
1143 NicknamesList = &BusinessNicknamesList;
1144 NicknamesListType = &BusinessNicknamesListType;
1145 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1146 NicknamesListAltID = &BusinessNicknamesListAltID;
1147 NicknamesListPID = &BusinessNicknamesListPID;
1148 NicknamesListTokens = &BusinessNicknamesListTokens;
1149 NicknamesListPref = &BusinessNicknamesListPref;
1153 std::map<int, int>::iterator SLiter;
1154 wxString PropertyData;
1155 wxString PropertyName;
1156 wxString PropertyValue;
1157 wxString PropertyTokens;
1158 bool FirstToken = TRUE;
1160 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1161 intiter != SplitPoints.end(); ++intiter){
1163 SLiter = SplitLength.find(intiter->first);
1165 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1167 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1168 PropertyName = PropertyElement.GetNextToken();
1169 PropertyValue = PropertyElement.GetNextToken();
1171 intPrevValue = intiter->second;
1173 CaptureString(&PropertyValue, FALSE);
1175 if (PropertyName == wxT("ALTID")){
1177 NicknamesListAltID->erase(*NicknameCount);
1178 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1180 } else if (PropertyName == wxT("PID")){
1182 NicknamesListPID->erase(*NicknameCount);
1183 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1185 } else if (PropertyName == wxT("PREF")){
1187 int PriorityNumber = 0;
1188 bool ValidNumber = TRUE;
1191 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1194 catch(std::invalid_argument &e){
1195 ValidNumber = FALSE;
1198 if (ValidNumber == TRUE){
1200 NicknamesListPref->erase(*NicknameCount);
1201 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1205 } else if (PropertyName == wxT("LANGUAGE")){
1207 NicknamesListLanguage->erase(*NicknameCount);
1208 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1212 // Something else we don't know about so append
1213 // to the tokens variable.
1215 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1217 if (FirstToken == TRUE){
1219 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1224 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1234 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1236 // Add the name token data.
1238 if (!PropertyTokens.IsEmpty()){
1240 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1246 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1248 std::map<int, int> SplitPoints;
1249 std::map<int, int> SplitLength;
1250 std::map<int, int>::iterator SLiter;
1251 wxString PropertyData;
1252 wxString PropertyName;
1253 wxString PropertyValue;
1254 wxString PropertyTokens;
1255 bool FirstToken = TRUE;
1256 int intPrevValue = 8;
1258 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1262 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1263 intiter != SplitPoints.end(); ++intiter){
1265 SLiter = SplitLength.find(intiter->first);
1267 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1269 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1270 PropertyName = PropertyElement.GetNextToken();
1271 PropertyValue = PropertyElement.GetNextToken();
1273 intPrevValue = intiter->second;
1275 // Process properties.
1277 size_t intPropertyValueLen = PropertyValue.Len();
1279 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1281 PropertyValue.Trim();
1282 PropertyValue.RemoveLast();
1286 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1288 PropertyValue.Remove(0, 1);
1292 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1294 if (FirstToken == TRUE){
1296 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1301 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1309 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1311 wxString GenderComponent;
1313 if (GenderData.CountTokens() >= 2){
1315 Gender = GenderData.GetNextToken();
1316 GenderDetails = GenderData.GetString();
1318 CaptureString(&GenderDetails, FALSE);
1322 Gender = GenderData.GetNextToken();
1326 if (!PropertyTokens.IsEmpty()){
1328 GenderTokens = PropertyTokens;
1334 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1336 // Process date. Preserve the remainder in the string.
1338 std::map<int, int> SplitPoints;
1339 std::map<int, int> SplitLength;
1340 std::map<int, int>::iterator SLiter;
1341 wxString PropertyData;
1342 wxString PropertyName;
1343 wxString PropertyValue;
1344 wxString PropertyTokens;
1345 bool BirthdayText = FALSE;
1346 int intPrevValue = 6;
1348 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1352 // Look for type before continuing.
1354 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1355 intiter != SplitPoints.end(); ++intiter){
1357 SLiter = SplitLength.find(intiter->first);
1359 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1361 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1362 PropertyName = PropertyElement.GetNextToken();
1363 PropertyValue = PropertyElement.GetNextToken();
1365 intPrevValue = intiter->second;
1367 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1369 CaptureString(&PropertySeg2, FALSE);
1370 Birthday = PropertySeg2;
1371 BirthdayText = TRUE;
1377 // Setup blank lines for later on.
1380 bool FirstToken = TRUE;
1382 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1383 intiter != SplitPoints.end(); ++intiter){
1385 SLiter = SplitLength.find(intiter->first);
1387 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1389 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1390 PropertyName = PropertyElement.GetNextToken();
1391 PropertyValue = PropertyElement.GetNextToken();
1393 intPrevValue = intiter->second;
1395 // Process properties.
1397 CaptureString(&PropertyValue, FALSE);
1399 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1401 PropertyValue.Trim();
1402 PropertyValue.RemoveLast();
1406 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1408 PropertyValue.Remove(0, 1);
1412 if (PropertyName == wxT("ALTID")){
1414 BirthdayAltID = PropertyValue;
1416 } else if (PropertyName == wxT("CALSCALE")){
1418 BirthdayCalScale = PropertyValue;
1420 } else if (PropertyName != wxT("VALUE")) {
1422 // Something else we don't know about so append
1423 // to the tokens variable.
1425 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1427 if (FirstToken == TRUE){
1429 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1434 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1444 // Add the data to the variables and form.
1446 if (BirthdayText == FALSE){
1448 Birthday = PropertySeg2;
1452 if (!PropertyTokens.IsEmpty()){
1454 BirthdayTokens = PropertyTokens;
1460 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1462 // Process date. Preserve the remainder in the string.
1464 std::map<int, int> SplitPoints;
1465 std::map<int, int> SplitLength;
1466 std::map<int, int>::iterator SLiter;
1467 wxString PropertyData;
1468 wxString PropertyName;
1469 wxString PropertyValue;
1470 wxString PropertyTokens;
1471 bool AnniversaryText = FALSE;
1472 int intPrevValue = 13;
1474 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1478 // Look for type before continuing.
1480 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1481 intiter != SplitPoints.end(); ++intiter){
1483 SLiter = SplitLength.find(intiter->first);
1485 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1487 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1488 PropertyName = PropertyElement.GetNextToken();
1489 PropertyValue = PropertyElement.GetNextToken();
1491 intPrevValue = intiter->second;
1493 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1495 CaptureString(&PropertySeg2, FALSE);
1496 Anniversary = PropertySeg2;
1497 AnniversaryText = TRUE;
1503 // Setup blank lines for later on.
1506 bool FirstToken = TRUE;
1508 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1509 intiter != SplitPoints.end(); ++intiter){
1511 SLiter = SplitLength.find(intiter->first);
1513 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1515 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1516 PropertyName = PropertyElement.GetNextToken();
1517 PropertyValue = PropertyElement.GetNextToken();
1519 intPrevValue = intiter->second;
1521 // Process properties.
1523 CaptureString(&PropertyValue, FALSE);
1525 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1527 PropertyValue.Trim();
1528 PropertyValue.RemoveLast();
1532 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1534 PropertyValue.Remove(0, 1);
1538 if (PropertyName == wxT("ALTID")){
1540 AnniversaryAltID = PropertyValue;
1542 } else if (PropertyName == wxT("CALSCALE")){
1544 AnniversaryCalScale = PropertyValue;
1546 } else if (PropertyName != wxT("VALUE")) {
1548 // Something else we don't know about so append
1549 // to the tokens variable.
1551 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1553 if (FirstToken == TRUE){
1555 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1560 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1570 // Add the data to the variables and form.
1572 if (AnniversaryText == FALSE){
1574 Anniversary = PropertySeg2;
1578 if (!PropertyTokens.IsEmpty()){
1580 AnniversaryTokens = PropertyTokens;
1586 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1588 std::map<int, int> SplitPoints;
1589 std::map<int, int> SplitLength;
1591 int intPrevValue = 4;
1594 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1598 PropertyType PropType = PROPERTY_NONE;
1600 // Look for type before continuing.
1602 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1606 std::map<int, wxString> *TZList = NULL;
1607 std::map<int, wxString> *TZListType = NULL;
1608 std::map<int, wxString> *TZListMediatype = NULL;
1609 std::map<int, wxString> *TZListAltID = NULL;
1610 std::map<int, wxString> *TZListPID = NULL;
1611 std::map<int, wxString> *TZListTokens = NULL;
1612 std::map<int, int> *TZListPref = NULL;
1616 TZList = &GeneralTZList;
1617 TZListType = &GeneralTZListType;
1618 TZListMediatype = &GeneralTZListMediatype;
1619 TZListAltID = &GeneralTZListAltID;
1620 TZListPID = &GeneralTZListPID;
1621 TZListTokens = &GeneralTZListTokens;
1622 TZListPref = &GeneralTZListPref;
1625 TZList = &HomeTZList;
1626 TZListType = &HomeTZListType;
1627 TZListMediatype = &HomeTZListMediatype;
1628 TZListAltID = &HomeTZListAltID;
1629 TZListPID = &HomeTZListPID;
1630 TZListTokens = &HomeTZListTokens;
1631 TZListPref = &HomeTZListPref;
1634 TZList = &BusinessTZList;
1635 TZListType = &BusinessTZListType;
1636 TZListMediatype = &BusinessTZListMediatype;
1637 TZListAltID = &BusinessTZListAltID;
1638 TZListPID = &BusinessTZListPID;
1639 TZListTokens = &BusinessTZListTokens;
1640 TZListPref = &BusinessTZListPref;
1644 std::map<int, int>::iterator SLiter;
1645 wxString PropertyData;
1646 wxString PropertyName;
1647 wxString PropertyValue;
1648 wxString PropertyTokens;
1649 bool FirstToken = TRUE;
1651 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1652 intiter != SplitPoints.end(); ++intiter){
1654 SLiter = SplitLength.find(intiter->first);
1656 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1658 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1659 PropertyName = PropertyElement.GetNextToken();
1660 PropertyValue = PropertyElement.GetNextToken();
1662 intPrevValue = intiter->second;
1664 CaptureString(&PropertyValue, FALSE);
1666 if (PropertyName == wxT("ALTID")){
1668 TZListAltID->erase(*TimeZoneCount);
1669 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1671 } else if (PropertyName == wxT("PID")){
1673 TZListPID->erase(*TimeZoneCount);
1674 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1676 } else if (PropertyName == wxT("PREF")){
1678 int PriorityNumber = 0;
1679 bool ValidNumber = TRUE;
1682 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1685 catch(std::invalid_argument &e){
1686 ValidNumber = FALSE;
1689 if (ValidNumber == TRUE){
1691 TZListPref->erase(*TimeZoneCount);
1692 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1696 } else if (PropertyName == wxT("MEDIATYPE")){
1698 TZListMediatype->erase(*TimeZoneCount);
1699 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1703 // Something else we don't know about so append
1704 // to the tokens variable.
1706 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1708 if (FirstToken == TRUE){
1710 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1715 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1725 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1727 // Add the name token data.
1729 if (!PropertyTokens.IsEmpty()){
1731 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1738 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1740 size_t intPropertyLen = PropertySeg1.Len();
1741 std::map<int, int> SplitPoints;
1742 std::map<int, int> SplitLength;
1743 std::map<int, int>::iterator SLiter;
1744 wxString PropertyData;
1745 wxString PropertyName;
1746 wxString PropertyValue;
1747 wxString PropertyTokens;
1748 wxString AddressLabel;
1749 wxString AddressLang;
1750 wxString AddressAltID;
1751 wxString AddressPID;
1752 wxString AddressTokens;
1753 wxString AddressGeo;
1754 wxString AddressTimezone;
1755 wxString AddressType;
1756 wxString AddressMediatype;
1757 wxString AddressPOBox;
1758 wxString AddressExtended;
1759 wxString AddressStreet;
1760 wxString AddressLocality;
1761 wxString AddressCity;
1762 wxString AddressRegion;
1763 wxString AddressPostalCode;
1764 wxString AddressCountry;
1765 bool FirstToken = TRUE;
1766 int intSplitsFound = 0;
1767 int intSplitSize = 0;
1768 int intPrevValue = 5;
1773 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1777 PropertyType PropType = PROPERTY_NONE;
1779 // Look for type before continuing.
1781 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1785 std::map<int, wxString> *AddressList = NULL;
1786 std::map<int, wxString> *AddressListTown = NULL;
1787 std::map<int, wxString> *AddressListCounty = NULL;
1788 std::map<int, wxString> *AddressListPostCode = NULL;
1789 std::map<int, wxString> *AddressListCountry = NULL;
1790 std::map<int, wxString> *AddressListLabel = NULL;
1791 std::map<int, wxString> *AddressListLang = NULL;
1792 std::map<int, wxString> *AddressListAltID = NULL;
1793 std::map<int, wxString> *AddressListPID = NULL;
1794 std::map<int, wxString> *AddressListTokens = NULL;
1795 std::map<int, wxString> *AddressListGeo = NULL;
1796 std::map<int, wxString> *AddressListTimezone = NULL;
1797 std::map<int, wxString> *AddressListType = NULL;
1798 std::map<int, wxString> *AddressListMediatype = NULL;
1799 std::map<int, int> *AddressListPref = NULL;
1803 AddressList = &GeneralAddressList;
1804 AddressListTown = &GeneralAddressListTown;
1805 AddressListCounty = &GeneralAddressListCounty;
1806 AddressListPostCode = &GeneralAddressListPostCode;
1807 AddressListCountry = &GeneralAddressListCountry;
1808 AddressListLabel = &GeneralAddressListLabel;
1809 AddressListLang = &GeneralAddressListLang;
1810 AddressListAltID = &GeneralAddressListAltID;
1811 AddressListPID = &GeneralAddressListPID;
1812 AddressListTokens = &GeneralAddressListTokens;
1813 AddressListGeo = &GeneralAddressListGeo;
1814 AddressListTimezone = &GeneralAddressListTimezone;
1815 AddressListType = &GeneralAddressListType;
1816 AddressListMediatype = &GeneralAddressListMediatype;
1817 AddressListPref = &GeneralAddressListPref;
1820 AddressList = &HomeAddressList;
1821 AddressListTown = &HomeAddressListTown;
1822 AddressListCounty = &HomeAddressListCounty;
1823 AddressListPostCode = &HomeAddressListPostCode;
1824 AddressListCountry = &HomeAddressListCountry;
1825 AddressListLabel = &HomeAddressListLabel;
1826 AddressListLang = &HomeAddressListLang;
1827 AddressListAltID = &HomeAddressListAltID;
1828 AddressListPID = &HomeAddressListPID;
1829 AddressListTokens = &HomeAddressListTokens;
1830 AddressListGeo = &HomeAddressListGeo;
1831 AddressListTimezone = &HomeAddressListTimezone;
1832 AddressListType = &HomeAddressListType;
1833 AddressListMediatype = &HomeAddressListMediatype;
1834 AddressListPref = &HomeAddressListPref;
1837 AddressList = &BusinessAddressList;
1838 AddressListTown = &BusinessAddressListTown;
1839 AddressListCounty = &BusinessAddressListCounty;
1840 AddressListPostCode = &BusinessAddressListPostCode;
1841 AddressListCountry = &BusinessAddressListCountry;
1842 AddressListLabel = &BusinessAddressListLabel;
1843 AddressListLang = &BusinessAddressListLang;
1844 AddressListAltID = &BusinessAddressListAltID;
1845 AddressListPID = &BusinessAddressListPID;
1846 AddressListTokens = &BusinessAddressListTokens;
1847 AddressListGeo = &BusinessAddressListGeo;
1848 AddressListTimezone = &BusinessAddressListTimezone;
1849 AddressListType = &BusinessAddressListType;
1850 AddressListMediatype = &BusinessAddressListMediatype;
1851 AddressListPref = &BusinessAddressListPref;
1857 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1858 intiter != SplitPoints.end(); ++intiter){
1860 SLiter = SplitLength.find(intiter->first);
1862 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1864 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1865 PropertyName = PropertyElement.GetNextToken();
1866 PropertyValue = PropertyElement.GetNextToken();
1868 intPrevValue = intiter->second;
1870 CaptureString(&PropertyValue, FALSE);
1872 // Process properties.
1874 if (PropertyName == wxT("LABEL")){
1876 AddressListLabel->erase(*AddressCount);
1877 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1879 } else if (PropertyName == wxT("LANGUAGE")){
1881 AddressListLang->erase(*AddressCount);
1882 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1884 } else if (PropertyName == wxT("ALTID")){
1886 AddressListAltID->erase(*AddressCount);
1887 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1889 } else if (PropertyName == wxT("PID")){
1891 AddressListPID->erase(*AddressCount);
1892 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1894 } else if (PropertyName == wxT("GEO")){
1896 AddressListGeo->erase(*AddressCount);
1897 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1899 } else if (PropertyName == wxT("TZ")){
1901 AddressListTimezone->erase(*AddressCount);
1902 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1904 } else if (PropertyName == wxT("MEDIATYPE")){
1906 AddressListMediatype->erase(*AddressCount);
1907 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1909 } else if (PropertyName == wxT("PREF")){
1911 int PriorityNumber = 0;
1912 bool ValidNumber = TRUE;
1915 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1918 catch(std::invalid_argument &e){
1919 ValidNumber = FALSE;
1922 if (ValidNumber == TRUE){
1924 AddressListPref->erase(*AddressCount);
1925 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1931 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1933 if (FirstToken == TRUE){
1935 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1940 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1950 // Split the address.
1952 //std::map<int, int>::iterator SLiter;
1953 intPropertyLen = PropertySeg2.Len();
1954 SplitPoints.clear();
1955 SplitLength.clear();
1960 for (int i = 0; i <= intPropertyLen; i++){
1964 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1967 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1969 if (intSplitsFound == 6){
1971 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1976 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1986 // Split the data into several parts.
1988 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1989 intiter != SplitPoints.end(); ++intiter){
1991 if (intiter->first == 1){
1993 // Deal with PO Box.
1995 SLiter = SplitLength.find(1);
1997 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1998 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1999 intPrevValue = intiter->second;
2001 } else if (intiter->first == 2){
2003 // Deal with extended address.
2005 SLiter = SplitLength.find(2);
2007 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2008 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2009 intPrevValue = intiter->second;
2011 } else if (intiter->first == 3){
2013 // Deal with street address.
2015 SLiter = SplitLength.find(3);
2017 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2018 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2019 intPrevValue = intiter->second;
2021 } else if (intiter->first == 4){
2023 // Deal with locality
2025 SLiter = SplitLength.find(4);
2027 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2028 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2029 intPrevValue = intiter->second;
2031 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2033 } else if (intiter->first == 5){
2035 // Deal with region.
2037 SLiter = SplitLength.find(5);
2039 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2040 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2041 intPrevValue = intiter->second;
2043 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2045 } else if (intiter->first == 6){
2047 // Deal with post code.
2049 SLiter = SplitLength.find(6);
2051 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2052 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2053 intPrevValue = intiter->second;
2055 // Deal with country.
2057 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2058 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2066 // Add the data to the General/Home/Work address variables.
2068 CaptureString(&AddressStreet, FALSE);
2069 CaptureString(&AddressLocality, FALSE);
2070 CaptureString(&AddressRegion, FALSE);
2071 CaptureString(&AddressPostalCode, FALSE);
2072 CaptureString(&AddressCountry, FALSE);
2074 if (!PropertyTokens.IsEmpty()){
2076 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2080 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2081 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2082 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2083 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2084 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2088 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2091 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2094 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2098 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2102 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2104 std::map<int, int> SplitPoints;
2105 std::map<int, int> SplitLength;
2107 int intPrevValue = 7;
2110 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2114 PropertyType PropType = PROPERTY_NONE;
2116 // Look for type before continuing.
2118 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2120 std::map<int, wxString> *EmailList = NULL;
2121 std::map<int, wxString> *EmailListType = NULL;
2122 std::map<int, wxString> *EmailListAltID = NULL;
2123 std::map<int, wxString> *EmailListPID = NULL;
2124 std::map<int, wxString> *EmailListTokens = NULL;
2125 std::map<int, int> *EmailListPref = NULL;
2129 EmailList = &GeneralEmailList;
2130 EmailListType = &GeneralEmailListType;
2131 EmailListAltID = &GeneralEmailListAltID;
2132 EmailListPID = &GeneralEmailListPID;
2133 EmailListTokens = &GeneralEmailListTokens;
2134 EmailListPref = &GeneralEmailListPref;
2137 EmailList = &HomeEmailList;
2138 EmailListType = &HomeEmailListType;
2139 EmailListAltID = &HomeEmailListAltID;
2140 EmailListPID = &HomeEmailListPID;
2141 EmailListTokens = &HomeEmailListTokens;
2142 EmailListPref = &HomeEmailListPref;
2145 EmailList = &BusinessEmailList;
2146 EmailListType = &BusinessEmailListType;
2147 EmailListAltID = &BusinessEmailListAltID;
2148 EmailListPID = &BusinessEmailListPID;
2149 EmailListTokens = &BusinessEmailListTokens;
2150 EmailListPref = &BusinessEmailListPref;
2156 std::map<int,int>::iterator SLiter;
2157 wxString PropertyData;
2158 wxString PropertyName;
2159 wxString PropertyValue;
2160 wxString PropertyTokens;
2161 bool FirstToken = TRUE;
2163 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2164 intiter != SplitPoints.end(); ++intiter){
2166 SLiter = SplitLength.find(intiter->first);
2168 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2170 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2171 PropertyName = PropertyElement.GetNextToken();
2172 PropertyValue = PropertyElement.GetNextToken();
2174 intPrevValue = intiter->second;
2176 CaptureString(&PropertyValue, FALSE);
2178 // Process properties.
2180 if (PropertyName == wxT("ALTID")){
2182 EmailListAltID->erase(*EmailCount);
2183 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2185 } else if (PropertyName == wxT("PID")){
2187 EmailListPID->erase(*EmailCount);
2188 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2190 } else if (PropertyName == wxT("PREF")){
2192 int PriorityNumber = 0;
2193 bool ValidNumber = TRUE;
2196 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2199 catch(std::invalid_argument &e){
2200 ValidNumber = FALSE;
2203 if (ValidNumber == TRUE){
2205 EmailListPref->erase(*EmailCount);
2206 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2212 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2214 if (FirstToken == TRUE){
2216 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2221 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2231 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2233 // Add the name token data.
2235 if (!PropertyTokens.IsEmpty()){
2237 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2244 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2246 std::map<int, int> SplitPoints;
2247 std::map<int, int> SplitLength;
2249 int intPrevValue = 6;
2252 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2256 PropertyType PropType = PROPERTY_NONE;
2258 // Look for type before continuing.
2260 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2262 std::map<int, wxString> *IMList = NULL;
2263 std::map<int, wxString> *IMListType = NULL;
2264 std::map<int, wxString> *IMListAltID = NULL;
2265 std::map<int, wxString> *IMListPID = NULL;
2266 std::map<int, wxString> *IMListTokens = NULL;
2267 std::map<int, wxString> *IMListMediatype = NULL;
2268 std::map<int, int> *IMListPref = NULL;
2272 IMList = &GeneralIMList;
2273 IMListType = &GeneralIMListType;
2274 IMListAltID = &GeneralIMListAltID;
2275 IMListPID = &GeneralIMListPID;
2276 IMListTokens = &GeneralIMListTokens;
2277 IMListMediatype = &GeneralIMListMediatype;
2278 IMListPref = &GeneralIMListPref;
2281 IMList = &HomeIMList;
2282 IMListType = &HomeIMListType;
2283 IMListAltID = &HomeIMListAltID;
2284 IMListPID = &HomeIMListPID;
2285 IMListTokens = &HomeIMListTokens;
2286 IMListMediatype = &HomeIMListMediatype;
2287 IMListPref = &HomeIMListPref;
2290 IMList = &BusinessIMList;
2291 IMListType = &BusinessIMListType;
2292 IMListAltID = &BusinessIMListAltID;
2293 IMListPID = &BusinessIMListPID;
2294 IMListTokens = &BusinessIMListTokens;
2295 IMListMediatype = &BusinessIMListMediatype;
2296 IMListPref = &BusinessIMListPref;
2302 std::map<int,int>::iterator SLiter;
2303 wxString PropertyData;
2304 wxString PropertyName;
2305 wxString PropertyValue;
2306 wxString PropertyTokens;
2307 bool FirstToken = TRUE;
2309 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2310 intiter != SplitPoints.end(); ++intiter){
2312 SLiter = SplitLength.find(intiter->first);
2314 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2316 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2317 PropertyName = PropertyElement.GetNextToken();
2318 PropertyValue = PropertyElement.GetNextToken();
2320 intPrevValue = intiter->second;
2322 CaptureString(&PropertyValue, FALSE);
2324 // Process properties.
2326 if (PropertyName == wxT("ALTID")){
2328 IMListAltID->erase(*IMCount);
2329 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2331 } else if (PropertyName == wxT("PID")){
2333 IMListPID->erase(*IMCount);
2334 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2336 } else if (PropertyName == wxT("MEDIATYPE")){
2338 IMListMediatype->erase(*IMCount);
2339 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2341 } else if (PropertyName == wxT("PREF")){
2343 int PriorityNumber = 0;
2344 bool ValidNumber = TRUE;
2347 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2350 catch(std::invalid_argument &e){
2351 ValidNumber = FALSE;
2354 if (ValidNumber == TRUE){
2356 IMListPref->erase(*IMCount);
2357 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2363 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2365 if (FirstToken == TRUE){
2367 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2372 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2382 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2384 // Add the name token data.
2386 if (!PropertyTokens.IsEmpty()){
2388 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2394 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2396 std::map<int, int> SplitPoints;
2397 std::map<int, int> SplitLength;
2398 std::map<int, int>::iterator SLiter;
2402 PropertyType PropType = PROPERTY_NONE;
2404 // Look for type before continuing.
2407 wxString TelTypeDetail;
2408 wxString PropertyData;
2409 wxString PropertyName;
2410 wxString PropertyValue;
2411 wxString PropertyTokens;
2413 std::map<int,int> TypeSplitPoints;
2414 std::map<int,int> TypeSplitLength;
2415 std::map<int,int>::iterator TSLiter;
2417 int intSplitSize = 0;
2418 int intSplitsFound = 0;
2419 int intSplitPoint = 0;
2421 int intPrevValue = 5;
2423 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2427 // Look for type before continuing.
2429 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2430 intiter != SplitPoints.end(); ++intiter){
2432 SLiter = SplitLength.find(intiter->first);
2434 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2436 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2437 PropertyName = PropertyElement.GetNextToken();
2438 PropertyValue = PropertyElement.GetNextToken();
2440 intPrevValue = intiter->second;
2442 if (PropertyName == wxT("TYPE")){
2444 // Process each value in type and translate each
2447 // Strip out the quotes if they are there.
2449 size_t intPropertyValueLen = PropertyValue.Len();
2451 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2453 PropertyValue.Trim();
2454 PropertyValue.RemoveLast();
2458 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2460 PropertyValue.Remove(0, 1);
2464 TelTypeDetail = PropertyValue;
2470 for (int i = 0; i <= intPropertyValueLen; i++){
2474 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2476 if (intSplitsFound == 0){
2478 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2479 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2483 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2484 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2497 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2498 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2500 int intTypeSeek = 0;
2502 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2503 typeiter != TypeSplitPoints.end(); ++typeiter){
2505 wxString TypePropertyName;
2507 TSLiter = TypeSplitLength.find(typeiter->first);
2509 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2511 if (intTypeSeek == 0){
2516 TelTypeUI.Append(wxT(","));
2520 if (TypePropertyName == wxT("home")){
2522 PropType = PROPERTY_HOME;
2524 } else if (TypePropertyName == wxT("work")){
2526 PropType = PROPERTY_WORK;
2531 if (TypePropertyName == wxT("text")){
2533 TelTypeUI.Append(_("text"));
2536 } else if (TypePropertyName == wxT("voice")){
2538 TelTypeUI.Append(_("voice"));
2541 } else if (TypePropertyName == wxT("fax")){
2543 TelTypeUI.Append(_("fax"));
2546 } else if (TypePropertyName == wxT("cell")){
2548 TelTypeUI.Append(_("mobile"));
2551 } else if (TypePropertyName == wxT("video")){
2553 TelTypeUI.Append(_("video"));
2556 } else if (TypePropertyName == wxT("pager")){
2558 TelTypeUI.Append(_("pager"));
2561 } else if (TypePropertyName == wxT("textphone")){
2563 TelTypeUI.Append(_("textphone"));
2574 std::map<int, wxString> *TelephoneList = NULL;
2575 std::map<int, wxString> *TelephoneListType = NULL;
2576 std::map<int, wxString> *TelephoneListAltID = NULL;
2577 std::map<int, wxString> *TelephoneListPID = NULL;
2578 std::map<int, wxString> *TelephoneListTokens = NULL;
2579 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2580 std::map<int, int> *TelephoneListPref = NULL;
2584 TelephoneList = &GeneralTelephoneList;
2585 TelephoneListType = &GeneralTelephoneListType;
2586 TelephoneListAltID = &GeneralTelephoneListAltID;
2587 TelephoneListPID = &GeneralTelephoneListPID;
2588 TelephoneListTokens = &GeneralTelephoneListTokens;
2589 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2590 TelephoneListPref = &GeneralTelephoneListPref;
2593 TelephoneList = &HomeTelephoneList;
2594 TelephoneListType = &HomeTelephoneListType;
2595 TelephoneListAltID = &HomeTelephoneListAltID;
2596 TelephoneListPID = &HomeTelephoneListPID;
2597 TelephoneListTokens = &HomeTelephoneListTokens;
2598 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2599 TelephoneListPref = &HomeTelephoneListPref;
2602 TelephoneList = &BusinessTelephoneList;
2603 TelephoneListType = &BusinessTelephoneListType;
2604 TelephoneListAltID = &BusinessTelephoneListAltID;
2605 TelephoneListPID = &BusinessTelephoneListPID;
2606 TelephoneListTokens = &BusinessTelephoneListTokens;
2607 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2608 TelephoneListPref = &BusinessTelephoneListPref;
2612 // Process the properties.
2614 bool FirstToken = TRUE;
2617 SplitPoints.clear();
2618 SplitLength.clear();
2620 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2624 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2625 intiter != SplitPoints.end(); ++intiter){
2627 SLiter = SplitLength.find(intiter->first);
2629 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2631 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2632 PropertyName = PropertyElement.GetNextToken();
2633 PropertyValue = PropertyElement.GetNextToken();
2635 intPrevValue = intiter->second;
2637 CaptureString(&PropertyValue, FALSE);
2639 // Process properties.
2641 if (PropertyName == wxT("ALTID")){
2643 TelephoneListAltID->erase(*TelephoneCount);
2644 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2646 } else if (PropertyName == wxT("PID")){
2648 TelephoneListPID->erase(*TelephoneCount);
2649 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2651 } else if (PropertyName == wxT("PREF")){
2653 int PriorityNumber = 0;
2654 bool ValidNumber = TRUE;
2657 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2660 catch(std::invalid_argument &e){
2661 ValidNumber = FALSE;
2664 if (ValidNumber == TRUE){
2666 TelephoneListPref->erase(*TelephoneCount);
2667 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2673 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2675 if (FirstToken == TRUE){
2677 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2682 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2692 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2693 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2695 // Add the name token data.
2697 if (!PropertyTokens.IsEmpty()){
2699 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2705 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2707 std::map<int, int> SplitPoints;
2708 std::map<int, int> SplitLength;
2710 int intPrevValue = 6;
2713 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2717 PropertyType PropType = PROPERTY_NONE;
2719 // Look for type before continuing.
2721 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2723 std::map<int, wxString> *LanguageList = NULL;
2724 std::map<int, wxString> *LanguageListType = NULL;
2725 std::map<int, wxString> *LanguageListAltID = NULL;
2726 std::map<int, wxString> *LanguageListPID = NULL;
2727 std::map<int, wxString> *LanguageListTokens = NULL;
2728 std::map<int, int> *LanguageListPref = NULL;
2732 LanguageList = &GeneralLanguageList;
2733 LanguageListType = &GeneralLanguageListType;
2734 LanguageListAltID = &GeneralLanguageListAltID;
2735 LanguageListPID = &GeneralLanguageListPID;
2736 LanguageListTokens = &GeneralLanguageListTokens;
2737 LanguageListPref = &GeneralLanguageListPref;
2740 LanguageList = &HomeLanguageList;
2741 LanguageListType = &HomeLanguageListType;
2742 LanguageListAltID = &HomeLanguageListAltID;
2743 LanguageListPID = &HomeLanguageListPID;
2744 LanguageListTokens = &HomeLanguageListTokens;
2745 LanguageListPref = &HomeLanguageListPref;
2748 LanguageList = &BusinessLanguageList;
2749 LanguageListType = &BusinessLanguageListType;
2750 LanguageListAltID = &BusinessLanguageListAltID;
2751 LanguageListPID = &BusinessLanguageListPID;
2752 LanguageListTokens = &BusinessLanguageListTokens;
2753 LanguageListPref = &BusinessLanguageListPref;
2759 std::map<int,int>::iterator SLiter;
2760 wxString PropertyData;
2761 wxString PropertyName;
2762 wxString PropertyValue;
2763 wxString PropertyTokens;
2764 bool FirstToken = TRUE;
2766 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2767 intiter != SplitPoints.end(); ++intiter){
2769 SLiter = SplitLength.find(intiter->first);
2771 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2773 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2774 PropertyName = PropertyElement.GetNextToken();
2775 PropertyValue = PropertyElement.GetNextToken();
2777 intPrevValue = intiter->second;
2779 CaptureString(&PropertyValue, FALSE);
2781 // Process properties.
2783 if (PropertyName == wxT("ALTID")){
2785 LanguageListAltID->erase(*LanguageCount);
2786 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2788 } else if (PropertyName == wxT("PID")){
2790 LanguageListPID->erase(*LanguageCount);
2791 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2793 } else if (PropertyName == wxT("PREF")){
2795 int PriorityNumber = 0;
2796 bool ValidNumber = TRUE;
2799 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2802 catch(std::invalid_argument &e){
2803 ValidNumber = FALSE;
2806 if (ValidNumber == TRUE){
2808 LanguageListPref->erase(*LanguageCount);
2809 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2815 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2817 if (FirstToken == TRUE){
2819 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2824 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2834 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2836 // Add the name token data.
2838 if (!PropertyTokens.IsEmpty()){
2840 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2846 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2848 std::map<int, int> SplitPoints;
2849 std::map<int, int> SplitLength;
2851 int intPrevValue = 5;
2854 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2858 PropertyType PropType = PROPERTY_NONE;
2860 // Look for type before continuing.
2862 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2864 std::map<int, wxString> *GeopositionList = NULL;
2865 std::map<int, wxString> *GeopositionListType = NULL;
2866 std::map<int, wxString> *GeopositionListAltID = NULL;
2867 std::map<int, wxString> *GeopositionListPID = NULL;
2868 std::map<int, wxString> *GeopositionListTokens = NULL;
2869 std::map<int, wxString> *GeopositionListMediatype = NULL;
2870 std::map<int, int> *GeopositionListPref = NULL;
2874 GeopositionList = &GeneralGeographyList;
2875 GeopositionListType = &GeneralGeographyListType;
2876 GeopositionListAltID = &GeneralGeographyListAltID;
2877 GeopositionListPID = &GeneralGeographyListPID;
2878 GeopositionListTokens = &GeneralGeographyListTokens;
2879 GeopositionListMediatype = &GeneralGeographyListMediatype;
2880 GeopositionListPref = &GeneralGeographyListPref;
2883 GeopositionList = &HomeGeographyList;
2884 GeopositionListType = &HomeGeographyListType;
2885 GeopositionListAltID = &HomeGeographyListAltID;
2886 GeopositionListPID = &HomeGeographyListPID;
2887 GeopositionListTokens = &HomeGeographyListTokens;
2888 GeopositionListMediatype = &HomeGeographyListMediatype;
2889 GeopositionListPref = &HomeGeographyListPref;
2892 GeopositionList = &BusinessGeographyList;
2893 GeopositionListType = &BusinessGeographyListType;
2894 GeopositionListAltID = &BusinessGeographyListAltID;
2895 GeopositionListPID = &BusinessGeographyListPID;
2896 GeopositionListTokens = &BusinessGeographyListTokens;
2897 GeopositionListMediatype = &BusinessGeographyListMediatype;
2898 GeopositionListPref = &BusinessGeographyListPref;
2904 std::map<int,int>::iterator SLiter;
2905 wxString PropertyData;
2906 wxString PropertyName;
2907 wxString PropertyValue;
2908 wxString PropertyTokens;
2909 bool FirstToken = TRUE;
2911 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2912 intiter != SplitPoints.end(); ++intiter){
2914 SLiter = SplitLength.find(intiter->first);
2916 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2918 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2919 PropertyName = PropertyElement.GetNextToken();
2920 PropertyValue = PropertyElement.GetNextToken();
2922 intPrevValue = intiter->second;
2924 CaptureString(&PropertyValue, FALSE);
2926 // Process properties.
2928 if (PropertyName == wxT("ALTID")){
2930 GeopositionListAltID->erase(*GeographicCount);
2931 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2933 } else if (PropertyName == wxT("PID")){
2935 GeopositionListPID->erase(*GeographicCount);
2936 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2938 } else if (PropertyName == wxT("MEDIATYPE")){
2940 GeopositionListMediatype->erase(*GeographicCount);
2941 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2943 } else if (PropertyName == wxT("PREF")){
2945 int PriorityNumber = 0;
2946 bool ValidNumber = TRUE;
2949 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2952 catch(std::invalid_argument &e){
2953 ValidNumber = FALSE;
2956 if (ValidNumber == TRUE){
2958 GeopositionListPref->erase(*GeographicCount);
2959 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2965 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2967 if (FirstToken == TRUE){
2969 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2974 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2984 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2986 // Add the name token data.
2988 if (!PropertyTokens.IsEmpty()){
2990 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2996 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2998 size_t intPropertyLen = PropertySeg1.Len();
2999 std::map<int, int> SplitPoints;
3000 std::map<int, int> SplitLength;
3001 std::map<int, int>::iterator SLiter;
3002 wxString PropertyData;
3003 wxString PropertyName;
3004 wxString PropertyValue;
3005 wxString PropertyTokens;
3006 wxString RelatedType;
3007 wxString RelatedTypeOriginal;
3008 wxString RelatedName;
3009 bool FirstToken = TRUE;
3010 int intSplitsFound = 0;
3011 int intSplitSize = 0;
3012 int intPrevValue = 9;
3016 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3020 // Look for type before continuing.
3022 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3023 intiter != SplitPoints.end(); ++intiter){
3025 SLiter = SplitLength.find(intiter->first);
3027 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3029 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3030 PropertyName = PropertyElement.GetNextToken();
3031 PropertyValue = PropertyElement.GetNextToken();
3033 intPrevValue = intiter->second;
3037 RelatedTypeOriginal = PropertyValue;
3039 if (PropertyName == wxT("TYPE")){
3041 if (PropertyValue == wxT("contact")){
3043 RelatedType = _("Contact");
3045 } else if (PropertyValue == wxT("acquaintance")){
3047 RelatedType = _("Acquaintance");
3049 } else if (PropertyValue == wxT("friend")){
3051 RelatedType = _("Friend");
3053 } else if (PropertyValue == wxT("met")){
3055 RelatedType = _("Met");
3057 } else if (PropertyValue == wxT("co-worker")){
3059 RelatedType = _("Co-worker");
3061 } else if (PropertyValue == wxT("colleague")){
3063 RelatedType = _("Colleague");
3065 } else if (PropertyValue == wxT("co-resident")){
3067 RelatedType = _("Co-resident");
3069 } else if (PropertyValue == wxT("neighbor")){
3071 RelatedType = _("Neighbour");
3073 } else if (PropertyValue == wxT("child")){
3075 RelatedType = _("Child");
3077 } else if (PropertyValue == wxT("parent")){
3079 RelatedType = _("Parent");
3081 } else if (PropertyValue == wxT("sibling")){
3083 RelatedType = _("Sibling");
3085 } else if (PropertyValue == wxT("spouse")){
3087 RelatedType = _("Spouse");
3089 } else if (PropertyValue == wxT("kin")){
3091 RelatedType = _("Kin");
3093 } else if (PropertyValue == wxT("muse")){
3095 RelatedType = _("Muse");
3097 } else if (PropertyValue == wxT("crush")){
3099 RelatedType = _("Crush");
3101 } else if (PropertyValue == wxT("date")){
3103 RelatedType = _("Date");
3105 } else if (PropertyValue == wxT("sweetheart")){
3107 RelatedType = _("Sweetheart");
3109 } else if (PropertyValue == wxT("me")){
3111 RelatedType = _("Me");
3113 } else if (PropertyValue == wxT("agent")){
3115 RelatedType = _("Agent");
3117 } else if (PropertyValue == wxT("emergency")){
3119 RelatedType = _("Emergency");
3123 RelatedType = PropertyValue;
3133 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3134 intiter != SplitPoints.end(); ++intiter){
3136 SLiter = SplitLength.find(intiter->first);
3138 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3140 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3141 PropertyName = PropertyElement.GetNextToken();
3142 PropertyValue = PropertyElement.GetNextToken();
3144 intPrevValue = intiter->second;
3146 // Process properties.
3148 size_t intPropertyValueLen = PropertyValue.Len();
3150 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3152 PropertyValue.Trim();
3153 PropertyValue.RemoveLast();
3157 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3159 PropertyValue.Remove(0, 1);
3163 CaptureString(&PropertyValue, FALSE);
3165 if (PropertyName == wxT("ALTID")){
3167 GeneralRelatedListAltID.erase(*RelatedCount);
3168 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3170 } else if (PropertyName == wxT("PID")){
3172 GeneralRelatedListPID.erase(*RelatedCount);
3173 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3175 } else if (PropertyName == wxT("PREF")){
3177 int PriorityNumber = 0;
3178 bool ValidNumber = TRUE;
3181 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3184 catch(std::invalid_argument &e){
3185 ValidNumber = FALSE;
3188 if (ValidNumber == TRUE){
3190 GeneralRelatedListPref.erase(*RelatedCount);
3191 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3195 } else if (PropertyName == wxT("LANGUAGE")){
3197 GeneralRelatedListLanguage.erase(*RelatedCount);
3198 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3200 } else if (PropertyName != wxT("TYPE")) {
3202 // Something else we don't know about so append
3203 // to the tokens variable.
3205 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3207 if (FirstToken == TRUE){
3209 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3214 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3224 // Add the data to the General/Home/Work address variables.
3226 GeneralRelatedList.erase(*RelatedCount);
3227 GeneralRelatedListRelType.erase(*RelatedCount);
3228 GeneralRelatedListType.erase(*RelatedCount);
3229 GeneralRelatedListTokens.erase(*RelatedCount);
3230 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3231 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3232 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3233 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3237 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3239 std::map<int, int> SplitPoints;
3240 std::map<int, int> SplitLength;
3241 std::map<int, int>::iterator SLiter;
3242 wxString PropertyData;
3243 wxString PropertyName;
3244 wxString PropertyValue;
3245 wxString PropertyTokens;
3246 bool FirstToken = TRUE;
3247 int intPrevValue = 5;
3252 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3256 PropertyType PropType = PROPERTY_NONE;
3258 // Look for type before continuing.
3260 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3262 // Setup the pointers.
3264 std::map<int, wxString> *WebsiteList = NULL;
3265 std::map<int, wxString> *WebsiteListAltID = NULL;
3266 std::map<int, wxString> *WebsiteListPID = NULL;
3267 std::map<int, wxString> *WebsiteListType = NULL;
3268 std::map<int, wxString> *WebsiteListTokens = NULL;
3269 std::map<int, wxString> *WebsiteListMediatype = NULL;
3270 std::map<int, int> *WebsiteListPref = NULL;
3272 // Setup blank lines for later on.
3276 WebsiteList = &GeneralWebsiteList;
3277 WebsiteListType = &GeneralWebsiteListType;
3278 WebsiteListAltID = &GeneralWebsiteListAltID;
3279 WebsiteListPID = &GeneralWebsiteListPID;
3280 WebsiteListTokens = &GeneralWebsiteListTokens;
3281 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3282 WebsiteListPref = &GeneralWebsiteListPref;
3285 WebsiteList = &HomeWebsiteList;
3286 WebsiteListType = &HomeWebsiteListType;
3287 WebsiteListAltID = &HomeWebsiteListAltID;
3288 WebsiteListPID = &HomeWebsiteListPID;
3289 WebsiteListTokens = &HomeWebsiteListTokens;
3290 WebsiteListMediatype = &HomeWebsiteListMediatype;
3291 WebsiteListPref = &HomeWebsiteListPref;
3294 WebsiteList = &BusinessWebsiteList;
3295 WebsiteListType = &BusinessWebsiteListType;
3296 WebsiteListAltID = &BusinessWebsiteListAltID;
3297 WebsiteListPID = &BusinessWebsiteListPID;
3298 WebsiteListTokens = &BusinessWebsiteListTokens;
3299 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3300 WebsiteListPref = &BusinessWebsiteListPref;
3306 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3307 intiter != SplitPoints.end(); ++intiter){
3309 SLiter = SplitLength.find(intiter->first);
3311 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3313 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3314 PropertyName = PropertyElement.GetNextToken();
3315 PropertyValue = PropertyElement.GetNextToken();
3317 intPrevValue = intiter->second;
3319 // Process properties.
3321 size_t intPropertyValueLen = PropertyValue.Len();
3323 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3325 PropertyValue.Trim();
3326 PropertyValue.RemoveLast();
3330 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3332 PropertyValue.Remove(0, 1);
3336 CaptureString(&PropertyValue, FALSE);
3338 if (PropertyName == wxT("ALTID")){
3340 WebsiteListAltID->erase(*URLCount);
3341 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3343 } else if (PropertyName == wxT("PID")){
3345 WebsiteListPID->erase(*URLCount);
3346 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3348 } else if (PropertyName == wxT("PREF")){
3350 int PriorityNumber = 0;
3351 bool ValidNumber = TRUE;
3354 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3357 catch(std::invalid_argument &e){
3358 ValidNumber = FALSE;
3361 if (ValidNumber == TRUE){
3363 WebsiteListPref->erase(*URLCount);
3364 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3368 } else if (PropertyName == wxT("MEDIATYPE")){
3370 WebsiteListMediatype->erase(*URLCount);
3371 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3375 // Something else we don't know about so append
3376 // to the tokens variable.
3378 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3380 if (FirstToken == TRUE){
3382 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3387 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3397 // Add the data to the General/Home/Work address variables.
3399 CaptureString(&PropertySeg2, FALSE);
3401 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3403 if (!PropertyTokens.IsEmpty()){
3405 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3411 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3413 std::map<int, int> SplitPoints;
3414 std::map<int, int> SplitLength;
3415 std::map<int, int>::iterator SLiter;
3416 wxString PropertyData;
3417 wxString PropertyName;
3418 wxString PropertyValue;
3419 wxString PropertyTokens;
3420 bool FirstToken = TRUE;
3421 int intPrevValue = 7;
3426 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3430 PropertyType PropType = PROPERTY_NONE;
3432 // Look for type before continuing.
3434 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3436 // Setup the pointers.
3438 std::map<int, wxString> *TitleList = NULL;
3439 std::map<int, wxString> *TitleListAltID = NULL;
3440 std::map<int, wxString> *TitleListPID = NULL;
3441 std::map<int, wxString> *TitleListType = NULL;
3442 std::map<int, wxString> *TitleListTokens = NULL;
3443 std::map<int, wxString> *TitleListLanguage = NULL;
3444 std::map<int, int> *TitleListPref = NULL;
3446 // Setup blank lines for later on.
3450 TitleList = &GeneralTitleList;
3451 TitleListType = &GeneralTitleListType;
3452 TitleListAltID = &GeneralTitleListAltID;
3453 TitleListPID = &GeneralTitleListPID;
3454 TitleListTokens = &GeneralTitleListTokens;
3455 TitleListLanguage = &GeneralTitleListLanguage;
3456 TitleListPref = &GeneralTitleListPref;
3459 TitleList = &HomeTitleList;
3460 TitleListType = &HomeTitleListType;
3461 TitleListAltID = &HomeTitleListAltID;
3462 TitleListPID = &HomeTitleListPID;
3463 TitleListTokens = &HomeTitleListTokens;
3464 TitleListLanguage = &HomeTitleListLanguage;
3465 TitleListPref = &HomeTitleListPref;
3468 TitleList = &BusinessTitleList;
3469 TitleListType = &BusinessTitleListType;
3470 TitleListAltID = &BusinessTitleListAltID;
3471 TitleListPID = &BusinessTitleListPID;
3472 TitleListTokens = &BusinessTitleListTokens;
3473 TitleListLanguage = &BusinessTitleListLanguage;
3474 TitleListPref = &BusinessTitleListPref;
3480 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3481 intiter != SplitPoints.end(); ++intiter){
3483 SLiter = SplitLength.find(intiter->first);
3485 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3487 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3488 PropertyName = PropertyElement.GetNextToken();
3489 PropertyValue = PropertyElement.GetNextToken();
3491 intPrevValue = intiter->second;
3493 // Process properties.
3495 size_t intPropertyValueLen = PropertyValue.Len();
3497 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3499 PropertyValue.Trim();
3500 PropertyValue.RemoveLast();
3504 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3506 PropertyValue.Remove(0, 1);
3510 CaptureString(&PropertyValue, FALSE);
3512 if (PropertyName == wxT("ALTID")){
3514 TitleListAltID->erase(*TitleCount);
3515 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3517 } else if (PropertyName == wxT("PID")){
3519 TitleListPID->erase(*TitleCount);
3520 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3522 } else if (PropertyName == wxT("PREF")){
3524 int PriorityNumber = 0;
3525 bool ValidNumber = TRUE;
3528 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3531 catch(std::invalid_argument &e){
3532 ValidNumber = FALSE;
3535 if (ValidNumber == TRUE){
3537 TitleListPref->erase(*TitleCount);
3538 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3542 } else if (PropertyName == wxT("LANGUAGE")){
3544 TitleListLanguage->erase(*TitleCount);
3545 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3549 // Something else we don't know about so append
3550 // to the tokens variable.
3552 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3554 if (FirstToken == TRUE){
3556 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3561 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3571 // Add the data to the General/Home/Work address variables.
3573 CaptureString(&PropertySeg2, FALSE);
3575 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3577 if (!PropertyTokens.IsEmpty()){
3579 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3585 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3587 std::map<int, int> SplitPoints;
3588 std::map<int, int> SplitLength;
3589 std::map<int, int>::iterator SLiter;
3590 wxString PropertyData;
3591 wxString PropertyName;
3592 wxString PropertyValue;
3593 wxString PropertyTokens;
3594 bool FirstToken = TRUE;
3595 int intPrevValue = 6;
3600 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3604 PropertyType PropType = PROPERTY_NONE;
3606 // Look for type before continuing.
3608 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3610 // Setup the pointers.
3612 std::map<int, wxString> *RoleList = NULL;
3613 std::map<int, wxString> *RoleListAltID = NULL;
3614 std::map<int, wxString> *RoleListPID = NULL;
3615 std::map<int, wxString> *RoleListType = NULL;
3616 std::map<int, wxString> *RoleListTokens = NULL;
3617 std::map<int, wxString> *RoleListLanguage = NULL;
3618 std::map<int, int> *RoleListPref = NULL;
3620 // Setup blank lines for later on.
3624 RoleList = &GeneralRoleList;
3625 RoleListType = &GeneralRoleListType;
3626 RoleListAltID = &GeneralRoleListAltID;
3627 RoleListPID = &GeneralRoleListPID;
3628 RoleListTokens = &GeneralRoleListTokens;
3629 RoleListLanguage = &GeneralRoleListLanguage;
3630 RoleListPref = &GeneralRoleListPref;
3633 RoleList = &HomeRoleList;
3634 RoleListType = &HomeRoleListType;
3635 RoleListAltID = &HomeRoleListAltID;
3636 RoleListPID = &HomeRoleListPID;
3637 RoleListTokens = &HomeRoleListTokens;
3638 RoleListLanguage = &HomeRoleListLanguage;
3639 RoleListPref = &HomeRoleListPref;
3642 RoleList = &BusinessRoleList;
3643 RoleListType = &BusinessRoleListType;
3644 RoleListAltID = &BusinessRoleListAltID;
3645 RoleListPID = &BusinessRoleListPID;
3646 RoleListTokens = &BusinessRoleListTokens;
3647 RoleListLanguage = &BusinessRoleListLanguage;
3648 RoleListPref = &BusinessRoleListPref;
3654 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3655 intiter != SplitPoints.end(); ++intiter){
3657 SLiter = SplitLength.find(intiter->first);
3659 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3661 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3662 PropertyName = PropertyElement.GetNextToken();
3663 PropertyValue = PropertyElement.GetNextToken();
3665 intPrevValue = intiter->second;
3667 // Process properties.
3669 size_t intPropertyValueLen = PropertyValue.Len();
3671 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3673 PropertyValue.Trim();
3674 PropertyValue.RemoveLast();
3678 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3680 PropertyValue.Remove(0, 1);
3684 CaptureString(&PropertyValue, FALSE);
3686 if (PropertyName == wxT("ALTID")){
3688 RoleListAltID->erase(*RoleCount);
3689 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3691 } else if (PropertyName == wxT("PID")){
3693 RoleListPID->erase(*RoleCount);
3694 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3696 } else if (PropertyName == wxT("PREF")){
3698 int PriorityNumber = 0;
3699 bool ValidNumber = TRUE;
3702 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3705 catch(std::invalid_argument &e){
3706 ValidNumber = FALSE;
3709 if (ValidNumber == TRUE){
3711 RoleListPref->erase(*RoleCount);
3712 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3716 } else if (PropertyName == wxT("LANGUAGE")){
3718 RoleListLanguage->erase(*RoleCount);
3719 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3723 // Something else we don't know about so append
3724 // to the tokens variable.
3726 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3728 if (FirstToken == TRUE){
3730 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3735 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3745 // Add the data to the General/Home/Work address variables.
3747 CaptureString(&PropertySeg2, FALSE);
3749 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3751 if (!PropertyTokens.IsEmpty()){
3753 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3759 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3761 std::map<int, int> SplitPoints;
3762 std::map<int, int> SplitLength;
3763 std::map<int, int>::iterator SLiter;
3764 wxString PropertyData;
3765 wxString PropertyName;
3766 wxString PropertyValue;
3767 wxString PropertyTokens;
3768 bool FirstToken = TRUE;
3769 int intPrevValue = 5;
3774 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3778 PropertyType PropType = PROPERTY_NONE;
3780 // Look for type before continuing.
3782 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3784 // Setup the pointers.
3786 std::map<int, wxString> *OrganisationsList = NULL;
3787 std::map<int, wxString> *OrganisationsListAltID = NULL;
3788 std::map<int, wxString> *OrganisationsListPID = NULL;
3789 std::map<int, wxString> *OrganisationsListType = NULL;
3790 std::map<int, wxString> *OrganisationsListTokens = NULL;
3791 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3792 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3793 std::map<int, int> *OrganisationsListPref = NULL;
3795 // Setup blank lines for later on.
3799 OrganisationsList = &GeneralOrganisationsList;
3800 OrganisationsListType = &GeneralOrganisationsListType;
3801 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3802 OrganisationsListPID = &GeneralOrganisationsListPID;
3803 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3804 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3805 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3806 OrganisationsListPref = &GeneralOrganisationsListPref;
3809 OrganisationsList = &HomeOrganisationsList;
3810 OrganisationsListType = &HomeOrganisationsListType;
3811 OrganisationsListAltID = &HomeOrganisationsListAltID;
3812 OrganisationsListPID = &HomeOrganisationsListPID;
3813 OrganisationsListTokens = &HomeOrganisationsListTokens;
3814 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3815 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3816 OrganisationsListPref = &HomeOrganisationsListPref;
3819 OrganisationsList = &BusinessOrganisationsList;
3820 OrganisationsListType = &BusinessOrganisationsListType;
3821 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3822 OrganisationsListPID = &BusinessOrganisationsListPID;
3823 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3824 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3825 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3826 OrganisationsListPref = &BusinessOrganisationsListPref;
3832 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3833 intiter != SplitPoints.end(); ++intiter){
3835 SLiter = SplitLength.find(intiter->first);
3837 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3839 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3840 PropertyName = PropertyElement.GetNextToken();
3841 PropertyValue = PropertyElement.GetNextToken();
3843 intPrevValue = intiter->second;
3845 // Process properties.
3847 size_t intPropertyValueLen = PropertyValue.Len();
3849 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3851 PropertyValue.Trim();
3852 PropertyValue.RemoveLast();
3856 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3858 PropertyValue.Remove(0, 1);
3862 CaptureString(&PropertyValue, FALSE);
3864 if (PropertyName == wxT("ALTID")){
3866 OrganisationsListAltID->erase(*OrganisationCount);
3867 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3869 } else if (PropertyName == wxT("PID")){
3871 OrganisationsListPID->erase(*OrganisationCount);
3872 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3874 } else if (PropertyName == wxT("SORT-AS")){
3876 OrganisationsListSortAs->erase(*OrganisationCount);
3877 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3879 } else if (PropertyName == wxT("PREF")){
3881 int PriorityNumber = 0;
3882 bool ValidNumber = TRUE;
3885 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3888 catch(std::invalid_argument &e){
3889 ValidNumber = FALSE;
3892 if (ValidNumber == TRUE){
3894 OrganisationsListPref->erase(*OrganisationCount);
3895 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3899 } else if (PropertyName == wxT("LANGUAGE")){
3901 OrganisationsListLanguage->erase(*OrganisationCount);
3902 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3906 // Something else we don't know about so append
3907 // to the tokens variable.
3909 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3911 if (FirstToken == TRUE){
3913 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3918 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3928 // Add the data to the General/Home/Work address variables.
3930 CaptureString(&PropertySeg2, FALSE);
3932 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3934 if (!PropertyTokens.IsEmpty()){
3936 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3942 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3944 std::map<int, int> SplitPoints;
3945 std::map<int, int> SplitLength;
3946 std::map<int, int>::iterator SLiter;
3947 wxString PropertyData;
3948 wxString PropertyName;
3949 wxString PropertyValue;
3950 wxString PropertyTokens;
3951 bool FirstToken = TRUE;
3952 int intPrevValue = 6;
3957 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3961 PropertyType PropType = PROPERTY_NONE;
3963 // Look for type before continuing.
3965 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3967 // Setup the pointers.
3969 std::map<int, wxString> *NoteList = NULL;
3970 std::map<int, wxString> *NoteListAltID = NULL;
3971 std::map<int, wxString> *NoteListPID = NULL;
3972 std::map<int, wxString> *NoteListType = NULL;
3973 std::map<int, wxString> *NoteListTokens = NULL;
3974 std::map<int, wxString> *NoteListLanguage = NULL;
3975 std::map<int, int> *NoteListPref = NULL;
3977 // Setup blank lines for later on.
3981 NoteList = &GeneralNoteList;
3982 NoteListType = &GeneralNoteListType;
3983 NoteListAltID = &GeneralNoteListAltID;
3984 NoteListPID = &GeneralNoteListPID;
3985 NoteListTokens = &GeneralNoteListTokens;
3986 NoteListLanguage = &GeneralNoteListLanguage;
3987 NoteListPref = &GeneralNoteListPref;
3990 NoteList = &HomeNoteList;
3991 NoteListType = &HomeNoteListType;
3992 NoteListAltID = &HomeNoteListAltID;
3993 NoteListPID = &HomeNoteListPID;
3994 NoteListTokens = &HomeNoteListTokens;
3995 NoteListLanguage = &HomeNoteListLanguage;
3996 NoteListPref = &HomeNoteListPref;
3999 NoteList = &BusinessNoteList;
4000 NoteListType = &BusinessNoteListType;
4001 NoteListAltID = &BusinessNoteListAltID;
4002 NoteListPID = &BusinessNoteListPID;
4003 NoteListTokens = &BusinessNoteListTokens;
4004 NoteListLanguage = &BusinessNoteListLanguage;
4005 NoteListPref = &BusinessNoteListPref;
4011 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4012 intiter != SplitPoints.end(); ++intiter){
4014 SLiter = SplitLength.find(intiter->first);
4016 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4018 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4019 PropertyName = PropertyElement.GetNextToken();
4020 PropertyValue = PropertyElement.GetNextToken();
4022 intPrevValue = intiter->second;
4024 // Process properties.
4026 size_t intPropertyValueLen = PropertyValue.Len();
4028 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4030 PropertyValue.Trim();
4031 PropertyValue.RemoveLast();
4035 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4037 PropertyValue.Remove(0, 1);
4041 CaptureString(&PropertyValue, FALSE);
4043 if (PropertyName == wxT("ALTID")){
4045 NoteListAltID->erase(*NoteCount);
4046 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4048 } else if (PropertyName == wxT("PID")){
4050 NoteListPID->erase(*NoteCount);
4051 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4053 } else if (PropertyName == wxT("PREF")){
4055 int PriorityNumber = 0;
4056 bool ValidNumber = TRUE;
4059 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4062 catch(std::invalid_argument &e){
4063 ValidNumber = FALSE;
4066 if (ValidNumber == TRUE){
4068 NoteListPref->erase(*NoteCount);
4069 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4073 } else if (PropertyName == wxT("LANGUAGE")){
4075 NoteListLanguage->erase(*NoteCount);
4076 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4080 // Something else we don't know about so append
4081 // to the tokens variable.
4083 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4085 if (FirstToken == TRUE){
4087 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4092 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4102 // Add the data to the General/Home/Work address variables.
4104 CaptureString(&PropertySeg2, FALSE);
4106 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4108 if (!PropertyTokens.IsEmpty()){
4110 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4116 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4118 std::map<int, int> SplitPoints;
4119 std::map<int, int> SplitLength;
4120 std::map<int, int>::iterator SLiter;
4121 wxString PropertyData;
4122 wxString PropertyName;
4123 wxString PropertyValue;
4124 wxString PropertyTokens;
4125 bool FirstToken = TRUE;
4126 int intPrevValue = 12;
4131 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4135 PropertyType PropType = PROPERTY_NONE;
4137 // Look for type before continuing.
4139 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4141 // Setup blank lines for later on.
4147 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4150 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4156 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4157 intiter != SplitPoints.end(); ++intiter){
4159 SLiter = SplitLength.find(intiter->first);
4161 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4163 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4164 PropertyName = PropertyElement.GetNextToken();
4165 PropertyValue = PropertyElement.GetNextToken();
4167 intPrevValue = intiter->second;
4169 // Process properties.
4171 size_t intPropertyValueLen = PropertyValue.Len();
4173 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4175 PropertyValue.Trim();
4176 PropertyValue.RemoveLast();
4180 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4182 PropertyValue.Remove(0, 1);
4186 CaptureString(&PropertyValue, FALSE);
4188 if (PropertyName == wxT("ALTID")){
4190 CategoriesListAltID.erase(*CategoryCount);
4191 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4193 } else if (PropertyName == wxT("PID")){
4195 CategoriesListPID.erase(*CategoryCount);
4196 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4198 } else if (PropertyName == wxT("PREF")){
4200 int PriorityNumber = 0;
4201 bool ValidNumber = TRUE;
4204 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4207 catch(std::invalid_argument &e){
4208 ValidNumber = FALSE;
4211 if (ValidNumber == TRUE){
4213 CategoriesListPref.erase(*CategoryCount);
4214 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4218 } else if (PropertyName == wxT("LANGUAGE")){
4220 CategoriesListLanguage.erase(*CategoryCount);
4221 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4225 // Something else we don't know about so append
4226 // to the tokens variable.
4228 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4230 if (FirstToken == TRUE){
4232 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4237 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4247 // Deal with multiple categories.
4249 int intOrigCatCount = *CategoryCount;
4250 bool FirstCategoryProcessed = TRUE;
4251 bool AfterFirstToken = FALSE;
4252 int intSplitSize = 0;
4253 int intSplitsFound = 0;
4254 int intSplitSeek = 0;
4255 int intPropertyLen = PropertySeg2.Len();
4257 SplitPoints.clear();
4258 SplitLength.clear();
4261 for (int i = 0; i <= intPropertyLen; i++){
4263 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4271 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4273 if (AfterFirstToken == TRUE){
4275 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4276 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4280 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4281 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4282 AfterFirstToken = TRUE;
4294 if (SplitPoints.size() > 0){
4296 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4297 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4301 if (SplitPoints.size() == 0){
4303 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4305 if (!PropertyTokens.IsEmpty()){
4307 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4313 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4314 intiter != SplitPoints.end(); ++intiter){
4316 SLiter = SplitLength.find(intiter->first);
4318 intPrevValue = intiter->second;
4320 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4322 // Add the data to the General/Home/Work address variables.
4324 // Trim any whitespace from the start and end.
4326 PropertyData = PropertyData.Trim(FALSE);
4327 PropertyData = PropertyData.Trim(TRUE);
4329 CaptureString(&PropertyData, FALSE);
4331 if (FirstCategoryProcessed == TRUE){
4333 FirstCategoryProcessed = FALSE;
4335 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4337 if (!PropertyTokens.IsEmpty()){
4339 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4349 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4351 if (!PropertyTokens.IsEmpty()){
4353 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4359 // Copy the properties to each of the categories (if it exists).
4361 if (!PropertyTokens.IsEmpty()){
4363 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4367 // Check if ALTID was used.
4369 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4371 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4375 // Check if PID was used.
4377 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4379 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4383 // Check if PREF was used.
4385 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4387 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4391 // Check if LANGUAGE was used.
4393 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4395 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4399 // Check if TYPE was used.
4405 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4408 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4416 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4418 size_t intPropertyLen = PropertySeg1.Len();
4419 std::map<int, int> SplitPoints;
4420 std::map<int, int> SplitLength;
4421 std::map<int, int>::iterator SLiter;
4422 wxString PropertyData;
4423 wxString PropertyName;
4424 wxString PropertyValue;
4425 wxString PropertyTokens;
4426 bool FirstToken = TRUE;
4427 int intSplitsFound = 0;
4428 int intSplitSize = 0;
4429 int intPrevValue = 7;
4433 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4437 PropertyType PropType = PROPERTY_NONE;
4439 // Look for type before continuing.
4441 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4445 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4446 intiter != SplitPoints.end(); ++intiter){
4448 SLiter = SplitLength.find(intiter->first);
4450 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4452 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4453 PropertyName = PropertyElement.GetNextToken();
4454 PropertyValue = PropertyElement.GetNextToken();
4456 intPrevValue = intiter->second;
4458 // Process properties.
4460 size_t intPropertyValueLen = PropertyValue.Len();
4462 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4464 PropertyValue.Trim();
4465 PropertyValue.RemoveLast();
4469 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4471 PropertyValue.Remove(0, 1);
4475 CaptureString(&PropertyValue, FALSE);
4477 if (PropertyName == wxT("ALTID")){
4479 PicturesListAltID.erase(*PhotoCount);
4480 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4482 } else if (PropertyName == wxT("PID")){
4484 PicturesListPID.erase(*PhotoCount);
4485 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4487 } else if (PropertyName == wxT("PREF")){
4489 int PriorityNumber = 0;
4490 bool ValidNumber = TRUE;
4493 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4496 catch(std::invalid_argument &e){
4497 ValidNumber = FALSE;
4500 if (ValidNumber == TRUE){
4502 PicturesListPref.erase(*PhotoCount);
4503 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4507 } else if (PropertyName == wxT("MEDIATYPE")){
4509 PicturesListMediatype.erase(*PhotoCount);
4510 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4514 // Something else we don't know about so append
4515 // to the tokens variable.
4517 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4519 if (FirstToken == TRUE){
4521 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4526 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4536 intPropertyLen = PropertySeg2.Len();
4537 SplitPoints.clear();
4538 SplitLength.clear();
4543 CaptureString(&PropertySeg2, FALSE);
4545 for (int i = 0; i <= intPropertyLen; i++){
4549 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4552 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4554 if (intSplitsFound == 6){
4556 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4561 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4571 wxString wxSPhotoURI;
4572 wxString wxSPhotoMIME;
4573 wxString wxSPhotoEncoding;
4574 wxString wxSPhotoData;
4575 std::string base64enc;
4577 if (intSplitsFound == 0){
4581 std::map<int, int>::iterator striter;
4583 striter = SplitLength.find(1);
4585 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4587 while (wSTDataType.HasMoreTokens() == TRUE){
4589 wxSPhotoURI = wSTDataType.GetNextToken();
4590 wxSPhotoMIME = wSTDataType.GetNextToken();
4595 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4597 while (wSTDataInfo.HasMoreTokens() == TRUE){
4599 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4600 wxSPhotoData = wSTDataInfo.GetNextToken();
4601 base64enc = wxSPhotoData.mb_str();
4608 // Add the data to the General/Home/Work address variables.
4610 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4611 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4612 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4618 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4621 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4625 if (!PropertyTokens.IsEmpty()){
4627 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4633 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4635 size_t intPropertyLen = PropertySeg1.Len();
4636 std::map<int, int> SplitPoints;
4637 std::map<int, int> SplitLength;
4638 std::map<int, int>::iterator SLiter;
4639 wxString PropertyData;
4640 wxString PropertyName;
4641 wxString PropertyValue;
4642 wxString PropertyTokens;
4643 bool FirstToken = TRUE;
4644 int intSplitsFound = 0;
4645 int intSplitSize = 0;
4646 int intPrevValue = 6;
4650 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4654 PropertyType PropType = PROPERTY_NONE;
4656 // Look for type before continuing.
4658 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4662 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4663 intiter != SplitPoints.end(); ++intiter){
4665 SLiter = SplitLength.find(intiter->first);
4667 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4669 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4670 PropertyName = PropertyElement.GetNextToken();
4671 PropertyValue = PropertyElement.GetNextToken();
4673 intPrevValue = intiter->second;
4675 // Process properties.
4677 size_t intPropertyValueLen = PropertyValue.Len();
4679 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4681 PropertyValue.Trim();
4682 PropertyValue.RemoveLast();
4686 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4688 PropertyValue.Remove(0, 1);
4692 CaptureString(&PropertyValue, FALSE);
4694 if (PropertyName == wxT("ALTID")){
4696 LogosListAltID.erase(*LogoCount);
4697 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4699 } else if (PropertyName == wxT("PID")){
4701 LogosListPID.erase(*LogoCount);
4702 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4704 } else if (PropertyName == wxT("PREF")){
4706 int PriorityNumber = 0;
4707 bool ValidNumber = TRUE;
4710 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4713 catch(std::invalid_argument &e){
4714 ValidNumber = FALSE;
4717 if (ValidNumber == TRUE){
4719 LogosListPref.erase(*LogoCount);
4720 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4724 } else if (PropertyName == wxT("MEDIATYPE")){
4726 LogosListMediatype.erase(*LogoCount);
4727 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4731 // Something else we don't know about so append
4732 // to the tokens variable.
4734 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4736 if (FirstToken == TRUE){
4738 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4743 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4753 intPropertyLen = PropertySeg2.Len();
4754 SplitPoints.clear();
4755 SplitLength.clear();
4760 CaptureString(&PropertySeg2, FALSE);
4762 for (int i = 0; i <= intPropertyLen; i++){
4766 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4769 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4771 if (intSplitsFound == 6){
4773 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4778 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4788 wxString wxSPhotoURI;
4789 wxString wxSPhotoMIME;
4790 wxString wxSPhotoEncoding;
4791 wxString wxSPhotoData;
4792 std::string base64enc;
4794 if (intSplitsFound == 0){
4798 std::map<int, int>::iterator striter;
4800 striter = SplitLength.find(1);
4802 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4804 while (wSTDataType.HasMoreTokens() == TRUE){
4806 wxSPhotoURI = wSTDataType.GetNextToken();
4807 wxSPhotoMIME = wSTDataType.GetNextToken();
4812 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4814 while (wSTDataInfo.HasMoreTokens() == TRUE){
4816 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4817 wxSPhotoData = wSTDataInfo.GetNextToken();
4818 base64enc = wxSPhotoData.mb_str();
4825 // Add the data to the General/Home/Work address variables.
4827 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4828 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4829 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4835 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4838 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4842 if (!PropertyTokens.IsEmpty()){
4844 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4850 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4852 size_t intPropertyLen = PropertySeg1.Len();
4853 std::map<int, int> SplitPoints;
4854 std::map<int, int> SplitLength;
4855 std::map<int, int>::iterator SLiter;
4856 wxString PropertyData;
4857 wxString PropertyName;
4858 wxString PropertyValue;
4859 wxString PropertyTokens;
4860 bool FirstToken = TRUE;
4861 int intSplitsFound = 0;
4862 int intSplitSize = 0;
4863 int intPrevValue = 7;
4867 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4871 PropertyType PropType = PROPERTY_NONE;
4873 // Look for type before continuing.
4875 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4879 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4880 intiter != SplitPoints.end(); ++intiter){
4882 SLiter = SplitLength.find(intiter->first);
4884 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4886 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4887 PropertyName = PropertyElement.GetNextToken();
4888 PropertyValue = PropertyElement.GetNextToken();
4890 intPrevValue = intiter->second;
4892 // Process properties.
4894 size_t intPropertyValueLen = PropertyValue.Len();
4896 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4898 PropertyValue.Trim();
4899 PropertyValue.RemoveLast();
4903 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4905 PropertyValue.Remove(0, 1);
4909 CaptureString(&PropertyValue, FALSE);
4911 if (PropertyName == wxT("ALTID")){
4913 SoundsListAltID.erase(*SoundCount);
4914 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4916 } else if (PropertyName == wxT("PID")){
4918 SoundsListPID.erase(*SoundCount);
4919 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4921 } else if (PropertyName == wxT("PREF")){
4923 int PriorityNumber = 0;
4924 bool ValidNumber = TRUE;
4927 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4930 catch(std::invalid_argument &e){
4931 ValidNumber = FALSE;
4934 if (ValidNumber == TRUE){
4936 SoundsListPref.erase(*SoundCount);
4937 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4941 } else if (PropertyName == wxT("MEDIATYPE")){
4943 SoundsListMediatype.erase(*SoundCount);
4944 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4946 } else if (PropertyName == wxT("LANGUAGE")){
4948 SoundsListLanguage.erase(*SoundCount);
4949 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4953 // Something else we don't know about so append
4954 // to the tokens variable.
4956 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4958 if (FirstToken == TRUE){
4960 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4965 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4975 intPropertyLen = PropertySeg2.Len();
4976 SplitPoints.clear();
4977 SplitLength.clear();
4982 CaptureString(&PropertySeg2, FALSE);
4984 for (int i = 0; i <= intPropertyLen; i++){
4988 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4991 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4993 if (intSplitsFound == 6){
4995 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5000 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5010 wxString wxSSoundURI;
5011 wxString wxSSoundMIME;
5012 wxString wxSSoundEncoding;
5013 wxString wxSSoundData;
5014 std::string base64enc;
5016 if (intSplitsFound == 0){
5020 std::map<int, int>::iterator striter;
5022 striter = SplitLength.find(1);
5024 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5026 while (wSTDataType.HasMoreTokens() == TRUE){
5028 wxSSoundURI = wSTDataType.GetNextToken();
5029 wxSSoundMIME = wSTDataType.GetNextToken();
5034 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5036 while (wSTDataInfo.HasMoreTokens() == TRUE){
5038 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5039 wxSSoundData = wSTDataInfo.GetNextToken();
5040 base64enc = wxSSoundData.mb_str();
5047 // Add the data to the General/Home/Work address variables.
5053 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5056 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5060 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5061 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5062 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5064 if (!PropertyTokens.IsEmpty()){
5066 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5072 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5074 size_t intPropertyLen = PropertySeg1.Len();
5075 std::map<int, int> SplitPoints;
5076 std::map<int, int> SplitLength;
5077 std::map<int, int>::iterator SLiter;
5078 wxString PropertyData;
5079 wxString PropertyName;
5080 wxString PropertyValue;
5081 wxString PropertyTokens;
5082 bool FirstToken = TRUE;
5083 int intSplitsFound = 0;
5084 int intSplitSize = 0;
5085 int intPrevValue = 8;
5089 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5093 PropertyType PropType = PROPERTY_NONE;
5095 // Look for type before continuing.
5097 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5101 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5102 intiter != SplitPoints.end(); ++intiter){
5104 SLiter = SplitLength.find(intiter->first);
5106 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5108 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5109 PropertyName = PropertyElement.GetNextToken();
5110 PropertyValue = PropertyElement.GetNextToken();
5112 intPrevValue = intiter->second;
5114 // Process properties.
5116 size_t intPropertyValueLen = PropertyValue.Len();
5118 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5120 PropertyValue.Trim();
5121 PropertyValue.RemoveLast();
5125 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5127 PropertyValue.Remove(0, 1);
5131 CaptureString(&PropertyValue, FALSE);
5133 if (PropertyName == wxT("ALTID")){
5135 CalendarListAltID.erase(*CalURICount);
5136 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5138 } else if (PropertyName == wxT("PID")){
5140 CalendarListPID.erase(*CalURICount);
5141 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5143 } else if (PropertyName == wxT("PREF")){
5145 int PriorityNumber = 0;
5146 bool ValidNumber = TRUE;
5149 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5152 catch(std::invalid_argument &e){
5153 ValidNumber = FALSE;
5156 if (ValidNumber == TRUE){
5158 CalendarListPref.erase(*CalURICount);
5159 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5163 } else if (PropertyName == wxT("MEDIATYPE")){
5165 CalendarListMediatype.erase(*CalURICount);
5166 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5170 // Something else we don't know about so append
5171 // to the tokens variable.
5173 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5175 if (FirstToken == TRUE){
5177 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5182 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5192 intPropertyLen = PropertySeg2.Len();
5193 SplitPoints.clear();
5194 SplitLength.clear();
5199 CaptureString(&PropertySeg2, FALSE);
5201 // Add the data to the General/Home/Work address variables.
5207 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5210 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5214 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5216 if (!PropertyTokens.IsEmpty()){
5218 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5224 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5226 size_t intPropertyLen = PropertySeg1.Len();
5227 std::map<int, int> SplitPoints;
5228 std::map<int, int> SplitLength;
5229 std::map<int, int>::iterator SLiter;
5230 wxString PropertyData;
5231 wxString PropertyName;
5232 wxString PropertyValue;
5233 wxString PropertyTokens;
5234 bool FirstToken = TRUE;
5235 int intSplitsFound = 0;
5236 int intSplitSize = 0;
5237 int intPrevValue = 8;
5241 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5245 PropertyType PropType = PROPERTY_NONE;
5247 // Look for type before continuing.
5249 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5253 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5254 intiter != SplitPoints.end(); ++intiter){
5256 SLiter = SplitLength.find(intiter->first);
5258 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5260 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5261 PropertyName = PropertyElement.GetNextToken();
5262 PropertyValue = PropertyElement.GetNextToken();
5264 intPrevValue = intiter->second;
5266 // Process properties.
5268 size_t intPropertyValueLen = PropertyValue.Len();
5270 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5272 PropertyValue.Trim();
5273 PropertyValue.RemoveLast();
5277 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5279 PropertyValue.Remove(0, 1);
5283 CaptureString(&PropertyValue, FALSE);
5285 if (PropertyName == wxT("ALTID")){
5287 CalendarRequestListAltID.erase(*CalAdrURICount);
5288 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5290 } else if (PropertyName == wxT("PID")){
5292 CalendarRequestListPID.erase(*CalAdrURICount);
5293 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5295 } else if (PropertyName == wxT("PREF")){
5297 int PriorityNumber = 0;
5298 bool ValidNumber = TRUE;
5301 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5304 catch(std::invalid_argument &e){
5305 ValidNumber = FALSE;
5308 if (ValidNumber == TRUE){
5310 CalendarRequestListPref.erase(*CalAdrURICount);
5311 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5315 } else if (PropertyName == wxT("MEDIATYPE")){
5317 CalendarRequestListMediatype.erase(*CalAdrURICount);
5318 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5322 // Something else we don't know about so append
5323 // to the tokens variable.
5325 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5327 if (FirstToken == TRUE){
5329 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5334 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5344 intPropertyLen = PropertySeg2.Len();
5345 SplitPoints.clear();
5346 SplitLength.clear();
5351 CaptureString(&PropertySeg2, FALSE);
5353 // Add the data to the General/Home/Work address variables.
5359 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5362 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5366 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5368 if (!PropertyTokens.IsEmpty()){
5370 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5376 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5378 size_t intPropertyLen = PropertySeg1.Len();
5379 std::map<int, int> SplitPoints;
5380 std::map<int, int> SplitLength;
5381 std::map<int, int>::iterator SLiter;
5382 wxString PropertyData;
5383 wxString PropertyName;
5384 wxString PropertyValue;
5385 wxString PropertyTokens;
5386 bool FirstToken = TRUE;
5387 int intSplitsFound = 0;
5388 int intSplitSize = 0;
5389 int intPrevValue = 7;
5393 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5397 PropertyType PropType = PROPERTY_NONE;
5399 // Look for type before continuing.
5401 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5405 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5406 intiter != SplitPoints.end(); ++intiter){
5408 SLiter = SplitLength.find(intiter->first);
5410 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5412 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5413 PropertyName = PropertyElement.GetNextToken();
5414 PropertyValue = PropertyElement.GetNextToken();
5416 intPrevValue = intiter->second;
5418 // Process properties.
5420 size_t intPropertyValueLen = PropertyValue.Len();
5422 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5424 PropertyValue.Trim();
5425 PropertyValue.RemoveLast();
5429 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5431 PropertyValue.Remove(0, 1);
5435 CaptureString(&PropertyValue, FALSE);
5437 if (PropertyName == wxT("ALTID")){
5439 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5440 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5442 } else if (PropertyName == wxT("PID")){
5444 FreeBusyListPID.erase(*FreeBusyAddressCount);
5445 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5447 } else if (PropertyName == wxT("PREF")){
5449 int PriorityNumber = 0;
5450 bool ValidNumber = TRUE;
5453 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5456 catch(std::invalid_argument &e){
5457 ValidNumber = FALSE;
5460 if (ValidNumber == TRUE){
5462 FreeBusyListPref.erase(*FreeBusyAddressCount);
5463 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5467 } else if (PropertyName == wxT("MEDIATYPE")){
5469 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5470 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5474 // Something else we don't know about so append
5475 // to the tokens variable.
5477 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5479 if (FirstToken == TRUE){
5481 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5486 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5496 intPropertyLen = PropertySeg2.Len();
5497 SplitPoints.clear();
5498 SplitLength.clear();
5503 CaptureString(&PropertySeg2, FALSE);
5505 // Add the data to the General/Home/Work address variables.
5511 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5514 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5518 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5520 if (!PropertyTokens.IsEmpty()){
5522 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5528 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5530 size_t intPropertyLen = PropertySeg1.Len();
5531 std::map<int, int> SplitPoints;
5532 std::map<int, int> SplitLength;
5533 std::map<int, int>::iterator SLiter;
5534 wxString PropertyData;
5535 wxString PropertyName;
5536 wxString PropertyValue;
5537 wxString PropertyTokens;
5538 bool FirstToken = TRUE;
5539 int intSplitsFound = 0;
5540 int intSplitSize = 0;
5541 int intPrevValue = 5;
5546 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5550 PropertyType PropType = PROPERTY_NONE;
5552 // Look for type before continuing.
5554 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5558 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5559 intiter != SplitPoints.end(); ++intiter){
5561 SLiter = SplitLength.find(intiter->first);
5563 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5565 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5566 PropertyName = PropertyElement.GetNextToken();
5567 PropertyValue = PropertyElement.GetNextToken();
5569 intPrevValue = intiter->second;
5571 // Process properties.
5573 size_t intPropertyValueLen = PropertyValue.Len();
5575 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5577 PropertyValue.Trim();
5578 PropertyValue.RemoveLast();
5582 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5584 PropertyValue.Remove(0, 1);
5588 if (PropertyName == wxT("ALTID")){
5590 KeyListAltID.erase(*KeyCount);
5591 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5593 } else if (PropertyName == wxT("PID")){
5595 KeyListPID.erase(*KeyCount);
5596 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5598 } else if (PropertyName == wxT("PREF")){
5600 int PriorityNumber = 0;
5601 bool ValidNumber = TRUE;
5604 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5607 catch(std::invalid_argument &e){
5608 ValidNumber = FALSE;
5611 if (ValidNumber == TRUE){
5613 KeyListPref.erase(*KeyCount);
5614 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5620 // Something else we don't know about so append
5621 // to the tokens variable.
5623 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5625 if (FirstToken == TRUE){
5627 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5632 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5642 intPropertyLen = PropertySeg2.Len();
5643 SplitPoints.clear();
5644 SplitLength.clear();
5649 for (int i = 0; i <= intPropertyLen; i++){
5653 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5656 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5658 if (intSplitsFound == 6){
5660 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5665 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5676 wxString wxSKeyMIME;
5677 wxString wxSKeyEncoding;
5678 wxString wxSKeyData;
5679 std::string base64enc;
5681 if (intSplitsFound == 0){
5685 std::map<int, int>::iterator striter;
5687 striter = SplitLength.find(1);
5689 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5691 while (wSTDataType.HasMoreTokens() == TRUE){
5693 wxSKeyURI = wSTDataType.GetNextToken();
5694 wxSKeyMIME = wSTDataType.GetNextToken();
5699 if (wxSKeyURI == wxT("data")){
5701 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5703 while (wSTDataInfo.HasMoreTokens() == TRUE){
5705 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5706 wxSKeyData = wSTDataInfo.GetNextToken();
5715 // Add the data to the General/Home/Work address variables.
5717 if (wxSKeyURI == wxT("data")){
5719 KeyListDataEncType.erase(*KeyCount);
5720 KeyListKeyType.erase(*KeyCount);
5721 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5722 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5724 KeyList.erase(*KeyCount);
5725 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5729 KeyList.erase(*KeyCount);
5730 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5734 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5740 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5743 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5747 if (!PropertyTokens.IsEmpty()){
5749 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5755 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5757 // Split the Vendor three ways.
5759 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5762 wxString wxSVNDPropName;
5765 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5767 wSTVendorDetails.GetNextToken();
5768 wxSVNDID = wSTVendorDetails.GetNextToken();
5769 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5774 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5776 // Add the data to the vendor variables.
5778 VendorList.erase(*VendorCount);
5779 VendorListPEN.erase(*VendorCount);
5780 VendorListElement.erase(*VendorCount);
5782 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5783 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5784 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5790 void SplitValues(wxString *PropertyLine,
5791 std::map<int,int> *SplitPoints,
5792 std::map<int,int> *SplitLength,
5795 size_t intPropertyLen = PropertyLine->Len();
5796 int intSplitsFound = 0;
5797 int intSplitSize = 0;
5798 int intSplitSeek = 0;
5800 for (int i = intSize; i <= intPropertyLen; i++){
5804 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5805 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5807 if (intSplitsFound == 0){
5809 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5813 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5817 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5827 if (intSplitsFound == 0){
5829 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5830 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5834 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5835 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5841 void CheckType(wxString *PropertySeg1,
5842 std::map<int,int> *SplitPoints,
5843 std::map<int,int> *SplitLength,
5845 PropertyType *PropType){
5847 wxString PropertyData;
5848 wxString PropertyName;
5849 wxString PropertyValue;
5850 std::map<int,int>::iterator SLiter;
5852 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5853 intiter != SplitPoints->end(); ++intiter){
5855 SLiter = SplitLength->find(intiter->first);
5857 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5859 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5860 PropertyName = PropertyElement.GetNextToken();
5861 PropertyValue = PropertyElement.GetNextToken();
5863 *intPrevValue = intiter->second;
5865 if (PropertyName == wxT("TYPE")){
5867 if (PropertyValue == wxT("work")){
5869 *PropType = PROPERTY_WORK;
5871 } else if (PropertyValue == wxT("home")){
5873 *PropType = PROPERTY_HOME;
5877 *PropType = PROPERTY_NONE;