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 int ContactLineLen = 0;
83 int QuoteBreakPoint = 0;
87 int NicknameCount = 0;
88 int TimeZoneCount = 0;
92 int TelephoneCount = 0;
93 int LanguageCount = 0;
94 int GeographicCount = 0;
99 int OrganisationCount = 0;
101 int CategoryCount = 0;
105 int CalendarCount = 0;
106 int CalendarAddressCount = 0;
107 int FreeBusyAddressCount = 0;
112 wxString ContactLine;
113 wxString PropertyLine;
114 wxString PropertySeg1;
115 wxString PropertySeg2;
116 wxString PropertyNextLine;
119 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
120 iter != ContactFileLines.end(); ++iter){
122 ExtraLineSeek = TRUE;
128 PropertyLine.Clear();
129 PropertySeg1.Clear();
130 PropertySeg2.Clear();
133 ContactLine = iter->second;
135 while (ExtraLineSeek == TRUE){
137 // Check if there is extra data on the next line
138 // (indicated by space or tab at the start) and add data.
142 if (iter == ContactFileLines.end()){
149 PropertyNextLine = iter->second;
151 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
153 PropertyNextLine.Remove(0, 1);
154 ContactLine.Append(PropertyNextLine);
159 ExtraLineSeek = FALSE;
165 ContactLineLen = ContactLine.Len();
167 // Make sure we are not in quotation mode.
168 // Make sure colon does not have \ or \\ before it.
170 for (int i = 0; i <= ContactLineLen; i++){
172 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
174 PropertyFind = FALSE;
176 } else if (PropertyFind == TRUE){
178 Property.Append(ContactLine.Mid(i, 1));
182 if (ContactLine.Mid(i, 1) == wxT("\"")){
184 if (QuoteMode == TRUE){
196 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
205 // Split that line at the point into two variables (ignore the colon).
207 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
208 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
210 if (Property == wxT("KIND") && KindProcessed == FALSE){
212 ProcessKind(PropertySeg2);
214 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
216 UIDToken = PropertySeg2;
219 } else if (Property == wxT("SOURCE")){
221 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
224 } else if (Property == wxT("XML")){
226 ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
229 } else if (Property == wxT("MEMBER")){
231 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
234 } else if (Property == wxT("FN")){
236 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
239 } else if (Property == wxT("N") && NameProcessed == FALSE){
241 ProcessN(PropertySeg1, PropertySeg2);
242 NameProcessed = TRUE;
244 } else if (Property == wxT("NICKNAME")){
246 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
249 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
251 ProcessGender(PropertySeg1, PropertySeg2);
252 GenderProcessed = TRUE;
254 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
256 ProcessBirthday(PropertySeg1, PropertySeg2);
257 BirthdayProcessed = TRUE;
259 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
261 ProcessAnniversary(PropertySeg1, PropertySeg2);
262 AnniversaryProcessed = TRUE;
264 } else if (Property == wxT("TZ")){
266 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
269 } else if (Property == wxT("ADR")){
271 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
274 } else if (Property == wxT("EMAIL")){
276 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
279 } else if (Property == wxT("IMPP")){
281 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
284 } else if (Property == wxT("TEL")){
286 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
289 } else if (Property == wxT("LANG")){
291 // See frmContactEditor-LoadLanguage.cpp
293 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
296 } else if (Property == wxT("GEO")){
298 // See frmContactEditor-LoadGeo.cpp
300 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
303 } else if (Property == wxT("RELATED")){
305 // See fromContactEditor-LoadRelated.cpp
307 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
310 } else if (Property == wxT("URL")){
312 // See frmContactEditor-LoadURL.cpp
314 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
317 } else if (Property == wxT("TITLE")) {
319 // See frmContactEditor-LoadTitle.cpp
321 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
324 } else if (Property == wxT("ROLE")) {
326 // See frmContactEditor-LoadTitle.cpp
328 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
331 } else if (Property == wxT("ORG")) {
333 // See frmContactEditor-LoadOrg.cpp
335 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
338 } else if (Property == wxT("NOTE")) {
340 // See frmContactEditor-LoadNote.cpp
342 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
345 } else if (Property == wxT("CATEGORIES")) {
347 // See frmContactEditor-LoadCategory.cpp
349 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
352 } else if (Property == wxT("PHOTO")) {
354 // See frmContactEditor-LoadPhoto.cpp
356 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
359 } else if (Property == wxT("LOGO")) {
361 // See frmContactEditor-LoadPhoto.cpp
363 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
366 } else if (Property == wxT("LOGO")) {
368 // See frmContactEditor-LoadPhoto.cpp
370 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
373 } else if (Property == wxT("SOUND")) {
375 // See frmContactEditor-LoadSound.cpp
377 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
380 } else if (Property == wxT("CALURI")){
382 // See frmContactEditor-LoadCalendar.cpp
384 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
387 } else if (Property == wxT("CALADRURI")){
389 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
390 CalendarAddressCount++;
392 } else if (Property == wxT("FBURL")){
394 // See frmContactEditor-LoadCalendar.cpp
396 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
397 FreeBusyAddressCount++;
399 } else if (Property == wxT("KEY")){
401 // See frmContactEditor-LoadKey.cpp
403 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
406 } else if (Property.Mid(0, 3) == wxT("VND")){
408 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
411 } else if (Property.Mid(0, 2) == wxT("X-")){
413 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
414 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
421 return CONTACTLOAD_OK;
425 void ContactDataObject::ProcessKind(wxString KindType){
427 if (KindType == wxT("individual")){
429 ContactKind = CONTACTKIND_INDIVIDUAL;
431 } else if (KindType == wxT("group")){
433 ContactKind = CONTACTKIND_GROUP;
435 } else if (KindType == wxT("org")){
437 ContactKind = CONTACTKIND_ORGANISATION;
439 } else if (KindType == wxT("location")){
441 ContactKind = CONTACTKIND_LOCATION;
445 ContactKind = CONTACTKIND_NONE;
450 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
452 size_t intPropertyLen = PropertySeg1.Len();
453 std::map<int, int> SplitPoints;
454 std::map<int, int> SplitLength;
455 std::map<int, int>::iterator SLiter;
456 wxString PropertyData;
457 wxString PropertyName;
458 wxString PropertyValue;
459 wxString PropertyTokens;
460 bool FirstToken = TRUE;
461 int intSplitsFound = 0;
462 int intSplitSize = 0;
463 int intPrevValue = 8;
467 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
471 PropertyType PropType = PROPERTY_NONE;
473 // Look for type before continuing.
475 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
479 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
480 intiter != SplitPoints.end(); ++intiter){
482 SLiter = SplitLength.find(intiter->first);
484 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
486 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
487 PropertyName = PropertyElement.GetNextToken();
488 PropertyValue = PropertyElement.GetNextToken();
490 intPrevValue = intiter->second;
492 // Process properties.
494 size_t intPropertyValueLen = PropertyValue.Len();
496 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
498 PropertyValue.Trim();
499 PropertyValue.RemoveLast();
503 if (PropertyValue.Mid(0, 1) == wxT("\"")){
505 PropertyValue.Remove(0, 1);
509 CaptureString(&PropertyValue, FALSE);
511 if (PropertyName == wxT("ALTID")){
513 SourceListAltID.erase(*SourceCount);
514 SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
516 } else if (PropertyName == wxT("PID")){
518 SourceListPID.erase(*SourceCount);
519 SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
521 } else if (PropertyName == wxT("PREF")){
523 int PriorityNumber = 0;
524 bool ValidNumber = TRUE;
527 PriorityNumber = std::stoi(PropertyValue.ToStdString());
530 catch(std::invalid_argument &e){
534 if (ValidNumber == TRUE){
536 SourceListPref.erase(*SourceCount);
537 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
541 } else if (PropertyName == wxT("MEDIATYPE")){
543 SourceListMediatype.erase(*SourceCount);
544 SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
548 // Something else we don't know about so append
549 // to the tokens variable.
551 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
553 if (FirstToken == TRUE){
555 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
560 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
570 intPropertyLen = PropertySeg2.Len();
577 CaptureString(&PropertySeg2, FALSE);
579 // Add the data to the General/Home/Work address variables.
585 SourceListType.insert(std::make_pair(*SourceCount, "home"));
588 SourceListType.insert(std::make_pair(*SourceCount, "work"));
592 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
594 if (!PropertyTokens.IsEmpty()){
596 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
602 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
604 std::map<int, int> SplitPoints;
605 std::map<int, int> SplitLength;
607 int intPrevValue = 5;
611 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
615 wxString PropertyName;
616 wxString PropertyValue;
617 wxString PropertyData;
618 wxString PropertyTokens;
619 std::map<int,int>::iterator SLiter;
620 bool FirstToken = TRUE;
622 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
623 intiter != SplitPoints.end(); ++intiter){
625 SLiter = SplitLength.find(intiter->first);
627 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
629 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
630 PropertyName = PropertyElement.GetNextToken();
631 PropertyValue = PropertyElement.GetNextToken();
633 intPrevValue = intiter->second;
635 CaptureString(&PropertyValue, FALSE);
637 if (PropertyName == wxT("ALTID")){
639 XMLListAltID.erase(*XMLCount);
640 XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
646 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
650 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
652 std::map<int, int> SplitPoints;
653 std::map<int, int> SplitLength;
655 int intPrevValue = 8;
659 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
663 wxString PropertyName;
664 wxString PropertyValue;
665 wxString PropertyData;
666 wxString PropertyTokens;
667 std::map<int,int>::iterator SLiter;
668 bool FirstToken = TRUE;
670 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
671 intiter != SplitPoints.end(); ++intiter){
673 SLiter = SplitLength.find(intiter->first);
675 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
677 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
678 PropertyName = PropertyElement.GetNextToken();
679 PropertyValue = PropertyElement.GetNextToken();
681 intPrevValue = intiter->second;
683 CaptureString(&PropertyValue, FALSE);
685 if (PropertyName == wxT("ALTID")){
687 GroupsListAltID.erase(*GroupCount);
688 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
690 } else if (PropertyName == wxT("PID")){
692 GroupsListPID.erase(*GroupCount);
693 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
695 } else if (PropertyName == wxT("PREF")){
697 int PriorityNumber = 0;
698 bool ValidNumber = TRUE;
701 PriorityNumber = std::stoi(PropertyValue.ToStdString());
704 catch(std::invalid_argument &e){
708 if (ValidNumber == TRUE){
710 GroupsListPref.erase(*GroupCount);
711 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
715 } else if (PropertyName == wxT("MEDIATYPE")){
717 GroupsListMediaType.erase(*GroupCount);
718 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
720 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
722 if (FirstToken == TRUE){
724 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
729 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
737 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
739 if (!PropertyTokens.IsEmpty()){
741 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
748 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
750 std::map<int, int> SplitPoints;
751 std::map<int, int> SplitLength;
753 int intPrevValue = 4;
757 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
761 wxString PropertyName;
762 wxString PropertyValue;
763 wxString PropertyData;
764 wxString PropertyTokens;
765 std::map<int,int>::iterator SLiter;
766 bool FirstToken = TRUE;
768 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
769 intiter != SplitPoints.end(); ++intiter){
771 SLiter = SplitLength.find(intiter->first);
773 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
775 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
776 PropertyName = PropertyElement.GetNextToken();
777 PropertyValue = PropertyElement.GetNextToken();
779 intPrevValue = intiter->second;
781 CaptureString(&PropertyValue, FALSE);
783 if (PropertyName == wxT("TYPE")){
785 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
786 PropertyValue == wxT("work") ){
788 FullNamesListType.erase(*FNCount);
789 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
793 } else if (PropertyName == wxT("LANGUAGE")){
795 FullNamesListLanguage.erase(*FNCount);
796 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
798 } else if (PropertyName == wxT("ALTID")){
800 FullNamesListAltID.erase(*FNCount);
801 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
803 } else if (PropertyName == wxT("PID")){
805 FullNamesListPID.erase(*FNCount);
806 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
808 } else if (PropertyName == wxT("PREF")){
810 int PriorityNumber = 0;
811 bool ValidNumber = TRUE;
814 PriorityNumber = std::stoi(PropertyValue.ToStdString());
817 catch(std::invalid_argument &e){
821 if (ValidNumber == TRUE){
823 FullNamesListPref.erase(*FNCount);
824 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
828 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
830 if (FirstToken == TRUE){
832 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
837 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
845 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
847 if (!PropertyTokens.IsEmpty()){
849 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
855 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
857 std::map<int, int> SplitPoints;
858 std::map<int, int> SplitLength;
860 int intPrevValue = 3;
864 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
868 wxString PropertyName;
869 wxString PropertyValue;
870 wxString PropertyData;
871 wxString PropertyTokens;
872 std::map<int,int>::iterator SLiter;
873 bool FirstToken = TRUE;
875 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
876 intiter != SplitPoints.end(); ++intiter){
878 SLiter = SplitLength.find(intiter->first);
880 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
882 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
883 PropertyName = PropertyElement.GetNextToken();
884 PropertyValue = PropertyElement.GetNextToken();
886 intPrevValue = intiter->second;
888 CaptureString(&PropertyValue, FALSE);
890 if (PropertyName == wxT("ALTID")){
892 NameAltID = PropertyValue;
894 } else if (PropertyName == wxT("LANGUAGE")){
896 NameLanguage = PropertyValue;
898 } else if (PropertyName == wxT("SORT-AS")){
900 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
901 PropertyValue.Len() >= 3){
902 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
905 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
907 if (FirstToken == TRUE){
909 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
914 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
922 // Split the name data.
924 int intSplitSeek = 0;
925 int intSplitsFound = 0;
926 int intSplitSize = 0;
927 int intPropertyLen = PropertySeg2.Len();
929 std::map<int,wxString> NameValues;
932 for (int i = 0; i <= intPropertyLen; i++){
934 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
936 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
941 if (intSplitsFound == 4){
943 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
957 // Split the data into several parts.
959 for (std::map<int, wxString>::iterator iter = NameValues.begin();
960 iter != NameValues.end(); ++iter){
962 if (iter->first == 1){
964 // Deal with family name.
966 NameSurname = iter->second;
968 } else if (iter->first == 2){
970 // Deal with given names.
972 NameForename = iter->second;
974 } else if (iter->first == 3){
976 // Deal with additional names.
978 NameOtherNames = iter->second;
980 } else if (iter->first == 4){
982 // Deal with honorifix prefixes and suffixes.
984 NameTitle = iter->second;
988 if (iter == NameValues.end()){
994 NameSuffix = iter->second;
1000 // Add the name token data.
1002 if (!PropertyTokens.IsEmpty()){
1004 NameTokens = PropertyTokens;
1010 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1012 std::map<int, int> SplitPoints;
1013 std::map<int, int> SplitLength;
1015 int intPrevValue = 10;
1018 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1022 PropertyType PropType = PROPERTY_NONE;
1024 // Look for type before continuing.
1026 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1030 std::map<int, wxString> *NicknamesList = NULL;
1031 std::map<int, wxString> *NicknamesListType = NULL;
1032 std::map<int, wxString> *NicknamesListLanguage = NULL;
1033 std::map<int, wxString> *NicknamesListAltID = NULL;
1034 std::map<int, wxString> *NicknamesListPID = NULL;
1035 std::map<int, wxString> *NicknamesListTokens = NULL;
1036 std::map<int, int> *NicknamesListPref = NULL;
1040 NicknamesList = &GeneralNicknamesList;
1041 NicknamesListType = &GeneralNicknamesListType;
1042 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1043 NicknamesListAltID = &GeneralNicknamesListAltID;
1044 NicknamesListPID = &GeneralNicknamesListPID;
1045 NicknamesListTokens = &GeneralNicknamesListTokens;
1046 NicknamesListPref = &GeneralNicknamesListPref;
1049 NicknamesList = &HomeNicknamesList;
1050 NicknamesListType = &HomeNicknamesListType;
1051 NicknamesListLanguage = &HomeNicknamesListLanguage;
1052 NicknamesListAltID = &HomeNicknamesListAltID;
1053 NicknamesListPID = &HomeNicknamesListPID;
1054 NicknamesListTokens = &HomeNicknamesListTokens;
1055 NicknamesListPref = &HomeNicknamesListPref;
1058 NicknamesList = &BusinessNicknamesList;
1059 NicknamesListType = &BusinessNicknamesListType;
1060 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1061 NicknamesListAltID = &BusinessNicknamesListAltID;
1062 NicknamesListPID = &BusinessNicknamesListPID;
1063 NicknamesListTokens = &BusinessNicknamesListTokens;
1064 NicknamesListPref = &BusinessNicknamesListPref;
1068 std::map<int, int>::iterator SLiter;
1069 wxString PropertyData;
1070 wxString PropertyName;
1071 wxString PropertyValue;
1072 wxString PropertyTokens;
1073 bool FirstToken = TRUE;
1075 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1076 intiter != SplitPoints.end(); ++intiter){
1078 SLiter = SplitLength.find(intiter->first);
1080 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1082 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1083 PropertyName = PropertyElement.GetNextToken();
1084 PropertyValue = PropertyElement.GetNextToken();
1086 intPrevValue = intiter->second;
1088 CaptureString(&PropertyValue, FALSE);
1090 if (PropertyName == wxT("ALTID")){
1092 NicknamesListAltID->erase(*NicknameCount);
1093 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1095 } else if (PropertyName == wxT("PID")){
1097 NicknamesListPID->erase(*NicknameCount);
1098 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1100 } else if (PropertyName == wxT("PREF")){
1102 int PriorityNumber = 0;
1103 bool ValidNumber = TRUE;
1106 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1109 catch(std::invalid_argument &e){
1110 ValidNumber = FALSE;
1113 if (ValidNumber == TRUE){
1115 NicknamesListPref->erase(*NicknameCount);
1116 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1120 } else if (PropertyName == wxT("LANGUAGE")){
1122 NicknamesListLanguage->erase(*NicknameCount);
1123 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1127 // Something else we don't know about so append
1128 // to the tokens variable.
1130 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1132 if (FirstToken == TRUE){
1134 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1139 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1149 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1151 // Add the name token data.
1153 if (!PropertyTokens.IsEmpty()){
1155 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1161 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1163 std::map<int, int> SplitPoints;
1164 std::map<int, int> SplitLength;
1165 std::map<int, int>::iterator SLiter;
1166 wxString PropertyData;
1167 wxString PropertyName;
1168 wxString PropertyValue;
1169 wxString PropertyTokens;
1170 bool FirstToken = TRUE;
1171 int intPrevValue = 8;
1173 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1177 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1178 intiter != SplitPoints.end(); ++intiter){
1180 SLiter = SplitLength.find(intiter->first);
1182 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1184 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1185 PropertyName = PropertyElement.GetNextToken();
1186 PropertyValue = PropertyElement.GetNextToken();
1188 intPrevValue = intiter->second;
1190 // Process properties.
1192 size_t intPropertyValueLen = PropertyValue.Len();
1194 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1196 PropertyValue.Trim();
1197 PropertyValue.RemoveLast();
1201 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1203 PropertyValue.Remove(0, 1);
1207 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1209 if (FirstToken == TRUE){
1211 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1216 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1224 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1226 wxString GenderComponent;
1228 if (GenderData.CountTokens() >= 2){
1230 Gender = GenderData.GetNextToken();
1231 GenderDetails = GenderData.GetString();
1233 CaptureString(&GenderDetails, FALSE);
1237 Gender = GenderData.GetNextToken();
1241 if (!PropertyTokens.IsEmpty()){
1243 GenderTokens = PropertyTokens;
1249 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1251 // Process date. Preserve the remainder in the string.
1253 std::map<int, int> SplitPoints;
1254 std::map<int, int> SplitLength;
1255 std::map<int, int>::iterator SLiter;
1256 wxString PropertyData;
1257 wxString PropertyName;
1258 wxString PropertyValue;
1259 wxString PropertyTokens;
1260 bool BirthdayText = FALSE;
1261 int intPrevValue = 6;
1263 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1267 // Look for type before continuing.
1269 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1270 intiter != SplitPoints.end(); ++intiter){
1272 SLiter = SplitLength.find(intiter->first);
1274 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1276 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1277 PropertyName = PropertyElement.GetNextToken();
1278 PropertyValue = PropertyElement.GetNextToken();
1280 intPrevValue = intiter->second;
1282 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1284 CaptureString(&PropertySeg2, FALSE);
1285 Birthday = PropertySeg2;
1286 BirthdayText = TRUE;
1292 // Setup blank lines for later on.
1295 bool FirstToken = TRUE;
1297 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1298 intiter != SplitPoints.end(); ++intiter){
1300 SLiter = SplitLength.find(intiter->first);
1302 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1304 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1305 PropertyName = PropertyElement.GetNextToken();
1306 PropertyValue = PropertyElement.GetNextToken();
1308 intPrevValue = intiter->second;
1310 // Process properties.
1312 CaptureString(&PropertyValue, FALSE);
1314 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1316 PropertyValue.Trim();
1317 PropertyValue.RemoveLast();
1321 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1323 PropertyValue.Remove(0, 1);
1327 if (PropertyName == wxT("ALTID")){
1329 BirthdayAltID = PropertyValue;
1331 } else if (PropertyName == wxT("CALSCALE")){
1333 BirthdayCalScale = PropertyValue;
1335 } else if (PropertyName != wxT("VALUE")) {
1337 // Something else we don't know about so append
1338 // to the tokens variable.
1340 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1342 if (FirstToken == TRUE){
1344 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1349 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1359 // Add the data to the variables and form.
1361 if (BirthdayText == FALSE){
1363 Birthday = PropertySeg2;
1367 if (!PropertyTokens.IsEmpty()){
1369 BirthdayTokens = PropertyTokens;
1375 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1377 // Process date. Preserve the remainder in the string.
1379 std::map<int, int> SplitPoints;
1380 std::map<int, int> SplitLength;
1381 std::map<int, int>::iterator SLiter;
1382 wxString PropertyData;
1383 wxString PropertyName;
1384 wxString PropertyValue;
1385 wxString PropertyTokens;
1386 bool AnniversaryText = FALSE;
1387 int intPrevValue = 13;
1389 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1393 // Look for type before continuing.
1395 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1396 intiter != SplitPoints.end(); ++intiter){
1398 SLiter = SplitLength.find(intiter->first);
1400 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1402 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1403 PropertyName = PropertyElement.GetNextToken();
1404 PropertyValue = PropertyElement.GetNextToken();
1406 intPrevValue = intiter->second;
1408 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1410 CaptureString(&PropertySeg2, FALSE);
1411 Anniversary = PropertySeg2;
1412 AnniversaryText = TRUE;
1418 // Setup blank lines for later on.
1421 bool FirstToken = TRUE;
1423 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1424 intiter != SplitPoints.end(); ++intiter){
1426 SLiter = SplitLength.find(intiter->first);
1428 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1430 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1431 PropertyName = PropertyElement.GetNextToken();
1432 PropertyValue = PropertyElement.GetNextToken();
1434 intPrevValue = intiter->second;
1436 // Process properties.
1438 CaptureString(&PropertyValue, FALSE);
1440 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1442 PropertyValue.Trim();
1443 PropertyValue.RemoveLast();
1447 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1449 PropertyValue.Remove(0, 1);
1453 if (PropertyName == wxT("ALTID")){
1455 AnniversaryAltID = PropertyValue;
1457 } else if (PropertyName == wxT("CALSCALE")){
1459 AnniversaryCalScale = PropertyValue;
1461 } else if (PropertyName != wxT("VALUE")) {
1463 // Something else we don't know about so append
1464 // to the tokens variable.
1466 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1468 if (FirstToken == TRUE){
1470 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1475 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1485 // Add the data to the variables and form.
1487 if (AnniversaryText == FALSE){
1489 Anniversary = PropertySeg2;
1493 if (!PropertyTokens.IsEmpty()){
1495 AnniversaryTokens = PropertyTokens;
1501 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1503 std::map<int, int> SplitPoints;
1504 std::map<int, int> SplitLength;
1506 int intPrevValue = 4;
1509 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1513 PropertyType PropType = PROPERTY_NONE;
1515 // Look for type before continuing.
1517 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1521 std::map<int, wxString> *TZList = NULL;
1522 std::map<int, wxString> *TZListType = NULL;
1523 std::map<int, wxString> *TZListMediatype = NULL;
1524 std::map<int, wxString> *TZListAltID = NULL;
1525 std::map<int, wxString> *TZListPID = NULL;
1526 std::map<int, wxString> *TZListTokens = NULL;
1527 std::map<int, int> *TZListPref = NULL;
1531 TZList = &GeneralTZList;
1532 TZListType = &GeneralTZListType;
1533 TZListMediatype = &GeneralTZListMediatype;
1534 TZListAltID = &GeneralTZListAltID;
1535 TZListPID = &GeneralTZListPID;
1536 TZListTokens = &GeneralTZListTokens;
1537 TZListPref = &GeneralTZListPref;
1540 TZList = &HomeTZList;
1541 TZListType = &HomeTZListType;
1542 TZListMediatype = &HomeTZListMediatype;
1543 TZListAltID = &HomeTZListAltID;
1544 TZListPID = &HomeTZListPID;
1545 TZListTokens = &HomeTZListTokens;
1546 TZListPref = &HomeTZListPref;
1549 TZList = &BusinessTZList;
1550 TZListType = &BusinessTZListType;
1551 TZListMediatype = &BusinessTZListMediatype;
1552 TZListAltID = &BusinessTZListAltID;
1553 TZListPID = &BusinessTZListPID;
1554 TZListTokens = &BusinessTZListTokens;
1555 TZListPref = &BusinessTZListPref;
1559 std::map<int, int>::iterator SLiter;
1560 wxString PropertyData;
1561 wxString PropertyName;
1562 wxString PropertyValue;
1563 wxString PropertyTokens;
1564 bool FirstToken = TRUE;
1566 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1567 intiter != SplitPoints.end(); ++intiter){
1569 SLiter = SplitLength.find(intiter->first);
1571 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1573 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1574 PropertyName = PropertyElement.GetNextToken();
1575 PropertyValue = PropertyElement.GetNextToken();
1577 intPrevValue = intiter->second;
1579 CaptureString(&PropertyValue, FALSE);
1581 if (PropertyName == wxT("ALTID")){
1583 TZListAltID->erase(*TimeZoneCount);
1584 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1586 } else if (PropertyName == wxT("PID")){
1588 TZListPID->erase(*TimeZoneCount);
1589 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1591 } else if (PropertyName == wxT("PREF")){
1593 int PriorityNumber = 0;
1594 bool ValidNumber = TRUE;
1597 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1600 catch(std::invalid_argument &e){
1601 ValidNumber = FALSE;
1604 if (ValidNumber == TRUE){
1606 TZListPref->erase(*TimeZoneCount);
1607 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1611 } else if (PropertyName == wxT("MEDIATYPE")){
1613 TZListMediatype->erase(*TimeZoneCount);
1614 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1618 // Something else we don't know about so append
1619 // to the tokens variable.
1621 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1623 if (FirstToken == TRUE){
1625 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1630 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1640 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1642 // Add the name token data.
1644 if (!PropertyTokens.IsEmpty()){
1646 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1653 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1655 size_t intPropertyLen = PropertySeg1.Len();
1656 std::map<int, int> SplitPoints;
1657 std::map<int, int> SplitLength;
1658 std::map<int, int>::iterator SLiter;
1659 wxString PropertyData;
1660 wxString PropertyName;
1661 wxString PropertyValue;
1662 wxString PropertyTokens;
1663 wxString AddressLabel;
1664 wxString AddressLang;
1665 wxString AddressAltID;
1666 wxString AddressPID;
1667 wxString AddressTokens;
1668 wxString AddressGeo;
1669 wxString AddressTimezone;
1670 wxString AddressType;
1671 wxString AddressMediatype;
1672 wxString AddressPOBox;
1673 wxString AddressExtended;
1674 wxString AddressStreet;
1675 wxString AddressLocality;
1676 wxString AddressCity;
1677 wxString AddressRegion;
1678 wxString AddressPostalCode;
1679 wxString AddressCountry;
1680 bool FirstToken = TRUE;
1681 int intSplitsFound = 0;
1682 int intSplitSize = 0;
1683 int intPrevValue = 5;
1688 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1692 PropertyType PropType = PROPERTY_NONE;
1694 // Look for type before continuing.
1696 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1700 std::map<int, wxString> *AddressList = NULL;
1701 std::map<int, wxString> *AddressListTown = NULL;
1702 std::map<int, wxString> *AddressListCounty = NULL;
1703 std::map<int, wxString> *AddressListPostCode = NULL;
1704 std::map<int, wxString> *AddressListCountry = NULL;
1705 std::map<int, wxString> *AddressListLabel = NULL;
1706 std::map<int, wxString> *AddressListLang = NULL;
1707 std::map<int, wxString> *AddressListAltID = NULL;
1708 std::map<int, wxString> *AddressListPID = NULL;
1709 std::map<int, wxString> *AddressListTokens = NULL;
1710 std::map<int, wxString> *AddressListGeo = NULL;
1711 std::map<int, wxString> *AddressListTimezone = NULL;
1712 std::map<int, wxString> *AddressListType = NULL;
1713 std::map<int, wxString> *AddressListMediatype = NULL;
1714 std::map<int, int> *AddressListPref = NULL;
1718 AddressList = &GeneralAddressList;
1719 AddressListTown = &GeneralAddressListTown;
1720 AddressListCounty = &GeneralAddressListCounty;
1721 AddressListPostCode = &GeneralAddressListPostCode;
1722 AddressListCountry = &GeneralAddressListCountry;
1723 AddressListLabel = &GeneralAddressListLabel;
1724 AddressListLang = &GeneralAddressListLang;
1725 AddressListAltID = &GeneralAddressListAltID;
1726 AddressListPID = &GeneralAddressListPID;
1727 AddressListTokens = &GeneralAddressListTokens;
1728 AddressListGeo = &GeneralAddressListGeo;
1729 AddressListTimezone = &GeneralAddressListTimezone;
1730 AddressListType = &GeneralAddressListType;
1731 AddressListMediatype = &GeneralAddressListMediatype;
1732 AddressListPref = &GeneralAddressListPref;
1735 AddressList = &HomeAddressList;
1736 AddressListTown = &HomeAddressListTown;
1737 AddressListCounty = &HomeAddressListCounty;
1738 AddressListPostCode = &HomeAddressListPostCode;
1739 AddressListCountry = &HomeAddressListCountry;
1740 AddressListLabel = &HomeAddressListLabel;
1741 AddressListLang = &HomeAddressListLang;
1742 AddressListAltID = &HomeAddressListAltID;
1743 AddressListPID = &HomeAddressListPID;
1744 AddressListTokens = &HomeAddressListTokens;
1745 AddressListGeo = &HomeAddressListGeo;
1746 AddressListTimezone = &HomeAddressListTimezone;
1747 AddressListType = &HomeAddressListType;
1748 AddressListMediatype = &HomeAddressListMediatype;
1749 AddressListPref = &HomeAddressListPref;
1752 AddressList = &BusinessAddressList;
1753 AddressListTown = &BusinessAddressListTown;
1754 AddressListCounty = &BusinessAddressListCounty;
1755 AddressListPostCode = &BusinessAddressListPostCode;
1756 AddressListCountry = &BusinessAddressListCountry;
1757 AddressListLabel = &BusinessAddressListLabel;
1758 AddressListLang = &BusinessAddressListLang;
1759 AddressListAltID = &BusinessAddressListAltID;
1760 AddressListPID = &BusinessAddressListPID;
1761 AddressListTokens = &BusinessAddressListTokens;
1762 AddressListGeo = &BusinessAddressListGeo;
1763 AddressListTimezone = &BusinessAddressListTimezone;
1764 AddressListType = &BusinessAddressListType;
1765 AddressListMediatype = &BusinessAddressListMediatype;
1766 AddressListPref = &BusinessAddressListPref;
1772 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1773 intiter != SplitPoints.end(); ++intiter){
1775 SLiter = SplitLength.find(intiter->first);
1777 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1779 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1780 PropertyName = PropertyElement.GetNextToken();
1781 PropertyValue = PropertyElement.GetNextToken();
1783 intPrevValue = intiter->second;
1785 CaptureString(&PropertyValue, FALSE);
1787 // Process properties.
1789 if (PropertyName == wxT("LABEL")){
1791 AddressListLabel->erase(*AddressCount);
1792 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1794 } else if (PropertyName == wxT("LANGUAGE")){
1796 AddressListLang->erase(*AddressCount);
1797 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1799 } else if (PropertyName == wxT("ALTID")){
1801 AddressListAltID->erase(*AddressCount);
1802 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1804 } else if (PropertyName == wxT("PID")){
1806 AddressListPID->erase(*AddressCount);
1807 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1809 } else if (PropertyName == wxT("GEO")){
1811 AddressListGeo->erase(*AddressCount);
1812 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1814 } else if (PropertyName == wxT("TZ")){
1816 AddressListTimezone->erase(*AddressCount);
1817 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1819 } else if (PropertyName == wxT("MEDIATYPE")){
1821 AddressListMediatype->erase(*AddressCount);
1822 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1824 } else if (PropertyName == wxT("PREF")){
1826 int PriorityNumber = 0;
1827 bool ValidNumber = TRUE;
1830 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1833 catch(std::invalid_argument &e){
1834 ValidNumber = FALSE;
1837 if (ValidNumber == TRUE){
1839 AddressListPref->erase(*AddressCount);
1840 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1846 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1848 if (FirstToken == TRUE){
1850 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1855 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1865 // Split the address.
1867 //std::map<int, int>::iterator SLiter;
1868 intPropertyLen = PropertySeg2.Len();
1869 SplitPoints.clear();
1870 SplitLength.clear();
1875 for (int i = 0; i <= intPropertyLen; i++){
1879 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1882 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1884 if (intSplitsFound == 6){
1886 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1891 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1901 // Split the data into several parts.
1903 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1904 intiter != SplitPoints.end(); ++intiter){
1906 if (intiter->first == 1){
1908 // Deal with PO Box.
1910 SLiter = SplitLength.find(1);
1912 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1913 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1914 intPrevValue = intiter->second;
1916 } else if (intiter->first == 2){
1918 // Deal with extended address.
1920 SLiter = SplitLength.find(2);
1922 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1923 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1924 intPrevValue = intiter->second;
1926 } else if (intiter->first == 3){
1928 // Deal with street address.
1930 SLiter = SplitLength.find(3);
1932 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1933 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1934 intPrevValue = intiter->second;
1936 } else if (intiter->first == 4){
1938 // Deal with locality
1940 SLiter = SplitLength.find(4);
1942 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1943 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1944 intPrevValue = intiter->second;
1946 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1948 } else if (intiter->first == 5){
1950 // Deal with region.
1952 SLiter = SplitLength.find(5);
1954 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1955 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1956 intPrevValue = intiter->second;
1958 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1960 } else if (intiter->first == 6){
1962 // Deal with post code.
1964 SLiter = SplitLength.find(6);
1966 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1967 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1968 intPrevValue = intiter->second;
1970 // Deal with country.
1972 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1973 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1981 // Add the data to the General/Home/Work address variables.
1983 CaptureString(&AddressStreet, FALSE);
1984 CaptureString(&AddressLocality, FALSE);
1985 CaptureString(&AddressRegion, FALSE);
1986 CaptureString(&AddressPostalCode, FALSE);
1987 CaptureString(&AddressCountry, FALSE);
1989 if (!PropertyTokens.IsEmpty()){
1991 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1995 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1996 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1997 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1998 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1999 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2003 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2006 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2009 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2013 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2017 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2019 std::map<int, int> SplitPoints;
2020 std::map<int, int> SplitLength;
2022 int intPrevValue = 7;
2025 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2029 PropertyType PropType = PROPERTY_NONE;
2031 // Look for type before continuing.
2033 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2035 std::map<int, wxString> *EmailList = NULL;
2036 std::map<int, wxString> *EmailListType = NULL;
2037 std::map<int, wxString> *EmailListAltID = NULL;
2038 std::map<int, wxString> *EmailListPID = NULL;
2039 std::map<int, wxString> *EmailListTokens = NULL;
2040 std::map<int, int> *EmailListPref = NULL;
2044 EmailList = &GeneralEmailList;
2045 EmailListType = &GeneralEmailListType;
2046 EmailListAltID = &GeneralEmailListAltID;
2047 EmailListPID = &GeneralEmailListPID;
2048 EmailListTokens = &GeneralEmailListTokens;
2049 EmailListPref = &GeneralEmailListPref;
2052 EmailList = &HomeEmailList;
2053 EmailListType = &HomeEmailListType;
2054 EmailListAltID = &HomeEmailListAltID;
2055 EmailListPID = &HomeEmailListPID;
2056 EmailListTokens = &HomeEmailListTokens;
2057 EmailListPref = &HomeEmailListPref;
2060 EmailList = &BusinessEmailList;
2061 EmailListType = &BusinessEmailListType;
2062 EmailListAltID = &BusinessEmailListAltID;
2063 EmailListPID = &BusinessEmailListPID;
2064 EmailListTokens = &BusinessEmailListTokens;
2065 EmailListPref = &BusinessEmailListPref;
2071 std::map<int,int>::iterator SLiter;
2072 wxString PropertyData;
2073 wxString PropertyName;
2074 wxString PropertyValue;
2075 wxString PropertyTokens;
2076 bool FirstToken = TRUE;
2078 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2079 intiter != SplitPoints.end(); ++intiter){
2081 SLiter = SplitLength.find(intiter->first);
2083 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2085 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2086 PropertyName = PropertyElement.GetNextToken();
2087 PropertyValue = PropertyElement.GetNextToken();
2089 intPrevValue = intiter->second;
2091 CaptureString(&PropertyValue, FALSE);
2093 // Process properties.
2095 if (PropertyName == wxT("ALTID")){
2097 EmailListAltID->erase(*EmailCount);
2098 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2100 } else if (PropertyName == wxT("PID")){
2102 EmailListPID->erase(*EmailCount);
2103 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2105 } else if (PropertyName == wxT("PREF")){
2107 int PriorityNumber = 0;
2108 bool ValidNumber = TRUE;
2111 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2114 catch(std::invalid_argument &e){
2115 ValidNumber = FALSE;
2118 if (ValidNumber == TRUE){
2120 EmailListPref->erase(*EmailCount);
2121 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2127 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2129 if (FirstToken == TRUE){
2131 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2136 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2146 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2148 // Add the name token data.
2150 if (!PropertyTokens.IsEmpty()){
2152 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2159 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2161 std::map<int, int> SplitPoints;
2162 std::map<int, int> SplitLength;
2164 int intPrevValue = 6;
2167 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2171 PropertyType PropType = PROPERTY_NONE;
2173 // Look for type before continuing.
2175 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2177 std::map<int, wxString> *IMList = NULL;
2178 std::map<int, wxString> *IMListType = NULL;
2179 std::map<int, wxString> *IMListAltID = NULL;
2180 std::map<int, wxString> *IMListPID = NULL;
2181 std::map<int, wxString> *IMListTokens = NULL;
2182 std::map<int, wxString> *IMListMediatype = NULL;
2183 std::map<int, int> *IMListPref = NULL;
2187 IMList = &GeneralIMList;
2188 IMListType = &GeneralIMListType;
2189 IMListAltID = &GeneralIMListAltID;
2190 IMListPID = &GeneralIMListPID;
2191 IMListTokens = &GeneralIMListTokens;
2192 IMListMediatype = &GeneralIMListMediatype;
2193 IMListPref = &GeneralIMListPref;
2196 IMList = &HomeIMList;
2197 IMListType = &HomeIMListType;
2198 IMListAltID = &HomeIMListAltID;
2199 IMListPID = &HomeIMListPID;
2200 IMListTokens = &HomeIMListTokens;
2201 IMListMediatype = &HomeIMListMediatype;
2202 IMListPref = &HomeIMListPref;
2205 IMList = &BusinessIMList;
2206 IMListType = &BusinessIMListType;
2207 IMListAltID = &BusinessIMListAltID;
2208 IMListPID = &BusinessIMListPID;
2209 IMListTokens = &BusinessIMListTokens;
2210 IMListMediatype = &BusinessIMListMediatype;
2211 IMListPref = &BusinessIMListPref;
2217 std::map<int,int>::iterator SLiter;
2218 wxString PropertyData;
2219 wxString PropertyName;
2220 wxString PropertyValue;
2221 wxString PropertyTokens;
2222 bool FirstToken = TRUE;
2224 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2225 intiter != SplitPoints.end(); ++intiter){
2227 SLiter = SplitLength.find(intiter->first);
2229 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2231 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2232 PropertyName = PropertyElement.GetNextToken();
2233 PropertyValue = PropertyElement.GetNextToken();
2235 intPrevValue = intiter->second;
2237 CaptureString(&PropertyValue, FALSE);
2239 // Process properties.
2241 if (PropertyName == wxT("ALTID")){
2243 IMListAltID->erase(*IMCount);
2244 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2246 } else if (PropertyName == wxT("PID")){
2248 IMListPID->erase(*IMCount);
2249 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2251 } else if (PropertyName == wxT("MEDIATYPE")){
2253 IMListMediatype->erase(*IMCount);
2254 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2256 } else if (PropertyName == wxT("PREF")){
2258 int PriorityNumber = 0;
2259 bool ValidNumber = TRUE;
2262 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2265 catch(std::invalid_argument &e){
2266 ValidNumber = FALSE;
2269 if (ValidNumber == TRUE){
2271 IMListPref->erase(*IMCount);
2272 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2278 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2280 if (FirstToken == TRUE){
2282 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2287 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2297 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2299 // Add the name token data.
2301 if (!PropertyTokens.IsEmpty()){
2303 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2309 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2311 std::map<int, int> SplitPoints;
2312 std::map<int, int> SplitLength;
2313 std::map<int, int>::iterator SLiter;
2317 PropertyType PropType = PROPERTY_NONE;
2319 // Look for type before continuing.
2322 wxString TelTypeDetail;
2323 wxString PropertyData;
2324 wxString PropertyName;
2325 wxString PropertyValue;
2326 wxString PropertyTokens;
2328 std::map<int,int> TypeSplitPoints;
2329 std::map<int,int> TypeSplitLength;
2330 std::map<int,int>::iterator TSLiter;
2332 int intSplitSize = 0;
2333 int intSplitsFound = 0;
2334 int intSplitPoint = 0;
2336 int intPrevValue = 5;
2338 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2342 // Look for type before continuing.
2344 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2345 intiter != SplitPoints.end(); ++intiter){
2347 SLiter = SplitLength.find(intiter->first);
2349 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2351 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2352 PropertyName = PropertyElement.GetNextToken();
2353 PropertyValue = PropertyElement.GetNextToken();
2355 intPrevValue = intiter->second;
2357 if (PropertyName == wxT("TYPE")){
2359 // Process each value in type and translate each
2362 // Strip out the quotes if they are there.
2364 size_t intPropertyValueLen = PropertyValue.Len();
2366 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2368 PropertyValue.Trim();
2369 PropertyValue.RemoveLast();
2373 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2375 PropertyValue.Remove(0, 1);
2379 TelTypeDetail = PropertyValue;
2385 for (int i = 0; i <= intPropertyValueLen; i++){
2389 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2391 if (intSplitsFound == 0){
2393 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2394 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2398 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2399 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2412 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2413 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2415 int intTypeSeek = 0;
2417 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2418 typeiter != TypeSplitPoints.end(); ++typeiter){
2420 wxString TypePropertyName;
2422 TSLiter = TypeSplitLength.find(typeiter->first);
2424 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2426 if (intTypeSeek == 0){
2431 TelTypeUI.Append(wxT(","));
2435 if (TypePropertyName == wxT("home")){
2437 PropType = PROPERTY_HOME;
2439 } else if (TypePropertyName == wxT("work")){
2441 PropType = PROPERTY_WORK;
2446 if (TypePropertyName == wxT("text")){
2448 TelTypeUI.Append(_("text"));
2451 } else if (TypePropertyName == wxT("voice")){
2453 TelTypeUI.Append(_("voice"));
2456 } else if (TypePropertyName == wxT("fax")){
2458 TelTypeUI.Append(_("fax"));
2461 } else if (TypePropertyName == wxT("cell")){
2463 TelTypeUI.Append(_("mobile"));
2466 } else if (TypePropertyName == wxT("video")){
2468 TelTypeUI.Append(_("video"));
2471 } else if (TypePropertyName == wxT("pager")){
2473 TelTypeUI.Append(_("pager"));
2476 } else if (TypePropertyName == wxT("textphone")){
2478 TelTypeUI.Append(_("textphone"));
2489 std::map<int, wxString> *TelephoneList = NULL;
2490 std::map<int, wxString> *TelephoneListType = NULL;
2491 std::map<int, wxString> *TelephoneListAltID = NULL;
2492 std::map<int, wxString> *TelephoneListPID = NULL;
2493 std::map<int, wxString> *TelephoneListTokens = NULL;
2494 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2495 std::map<int, int> *TelephoneListPref = NULL;
2499 TelephoneList = &GeneralTelephoneList;
2500 TelephoneListType = &GeneralTelephoneListType;
2501 TelephoneListAltID = &GeneralTelephoneListAltID;
2502 TelephoneListPID = &GeneralTelephoneListPID;
2503 TelephoneListTokens = &GeneralTelephoneListTokens;
2504 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2505 TelephoneListPref = &GeneralTelephoneListPref;
2508 TelephoneList = &HomeTelephoneList;
2509 TelephoneListType = &HomeTelephoneListType;
2510 TelephoneListAltID = &HomeTelephoneListAltID;
2511 TelephoneListPID = &HomeTelephoneListPID;
2512 TelephoneListTokens = &HomeTelephoneListTokens;
2513 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2514 TelephoneListPref = &HomeTelephoneListPref;
2517 TelephoneList = &BusinessTelephoneList;
2518 TelephoneListType = &BusinessTelephoneListType;
2519 TelephoneListAltID = &BusinessTelephoneListAltID;
2520 TelephoneListPID = &BusinessTelephoneListPID;
2521 TelephoneListTokens = &BusinessTelephoneListTokens;
2522 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2523 TelephoneListPref = &BusinessTelephoneListPref;
2527 // Process the properties.
2529 bool FirstToken = TRUE;
2532 SplitPoints.clear();
2533 SplitLength.clear();
2535 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2539 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2540 intiter != SplitPoints.end(); ++intiter){
2542 SLiter = SplitLength.find(intiter->first);
2544 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2546 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2547 PropertyName = PropertyElement.GetNextToken();
2548 PropertyValue = PropertyElement.GetNextToken();
2550 intPrevValue = intiter->second;
2552 CaptureString(&PropertyValue, FALSE);
2554 // Process properties.
2556 if (PropertyName == wxT("ALTID")){
2558 TelephoneListAltID->erase(*TelephoneCount);
2559 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2561 } else if (PropertyName == wxT("PID")){
2563 TelephoneListPID->erase(*TelephoneCount);
2564 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2566 } else if (PropertyName == wxT("PREF")){
2568 int PriorityNumber = 0;
2569 bool ValidNumber = TRUE;
2572 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2575 catch(std::invalid_argument &e){
2576 ValidNumber = FALSE;
2579 if (ValidNumber == TRUE){
2581 TelephoneListPref->erase(*TelephoneCount);
2582 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2588 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2590 if (FirstToken == TRUE){
2592 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2597 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2607 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2608 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2610 // Add the name token data.
2612 if (!PropertyTokens.IsEmpty()){
2614 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2620 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2622 std::map<int, int> SplitPoints;
2623 std::map<int, int> SplitLength;
2625 int intPrevValue = 6;
2628 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2632 PropertyType PropType = PROPERTY_NONE;
2634 // Look for type before continuing.
2636 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2638 std::map<int, wxString> *LanguageList = NULL;
2639 std::map<int, wxString> *LanguageListType = NULL;
2640 std::map<int, wxString> *LanguageListAltID = NULL;
2641 std::map<int, wxString> *LanguageListPID = NULL;
2642 std::map<int, wxString> *LanguageListTokens = NULL;
2643 std::map<int, int> *LanguageListPref = NULL;
2647 LanguageList = &GeneralLanguageList;
2648 LanguageListType = &GeneralLanguageListType;
2649 LanguageListAltID = &GeneralLanguageListAltID;
2650 LanguageListPID = &GeneralLanguageListPID;
2651 LanguageListTokens = &GeneralLanguageListTokens;
2652 LanguageListPref = &GeneralLanguageListPref;
2655 LanguageList = &HomeLanguageList;
2656 LanguageListType = &HomeLanguageListType;
2657 LanguageListAltID = &HomeLanguageListAltID;
2658 LanguageListPID = &HomeLanguageListPID;
2659 LanguageListTokens = &HomeLanguageListTokens;
2660 LanguageListPref = &HomeLanguageListPref;
2663 LanguageList = &BusinessLanguageList;
2664 LanguageListType = &BusinessLanguageListType;
2665 LanguageListAltID = &BusinessLanguageListAltID;
2666 LanguageListPID = &BusinessLanguageListPID;
2667 LanguageListTokens = &BusinessLanguageListTokens;
2668 LanguageListPref = &BusinessLanguageListPref;
2674 std::map<int,int>::iterator SLiter;
2675 wxString PropertyData;
2676 wxString PropertyName;
2677 wxString PropertyValue;
2678 wxString PropertyTokens;
2679 bool FirstToken = TRUE;
2681 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2682 intiter != SplitPoints.end(); ++intiter){
2684 SLiter = SplitLength.find(intiter->first);
2686 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2688 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2689 PropertyName = PropertyElement.GetNextToken();
2690 PropertyValue = PropertyElement.GetNextToken();
2692 intPrevValue = intiter->second;
2694 CaptureString(&PropertyValue, FALSE);
2696 // Process properties.
2698 if (PropertyName == wxT("ALTID")){
2700 LanguageListAltID->erase(*LanguageCount);
2701 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2703 } else if (PropertyName == wxT("PID")){
2705 LanguageListPID->erase(*LanguageCount);
2706 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2708 } else if (PropertyName == wxT("PREF")){
2710 int PriorityNumber = 0;
2711 bool ValidNumber = TRUE;
2714 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2717 catch(std::invalid_argument &e){
2718 ValidNumber = FALSE;
2721 if (ValidNumber == TRUE){
2723 LanguageListPref->erase(*LanguageCount);
2724 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2730 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2732 if (FirstToken == TRUE){
2734 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2739 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2749 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2751 // Add the name token data.
2753 if (!PropertyTokens.IsEmpty()){
2755 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2761 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2763 std::map<int, int> SplitPoints;
2764 std::map<int, int> SplitLength;
2766 int intPrevValue = 5;
2769 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2773 PropertyType PropType = PROPERTY_NONE;
2775 // Look for type before continuing.
2777 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2779 std::map<int, wxString> *GeopositionList = NULL;
2780 std::map<int, wxString> *GeopositionListType = NULL;
2781 std::map<int, wxString> *GeopositionListAltID = NULL;
2782 std::map<int, wxString> *GeopositionListPID = NULL;
2783 std::map<int, wxString> *GeopositionListTokens = NULL;
2784 std::map<int, wxString> *GeopositionListMediatype = NULL;
2785 std::map<int, int> *GeopositionListPref = NULL;
2789 GeopositionList = &GeneralGeographyList;
2790 GeopositionListType = &GeneralGeographyListType;
2791 GeopositionListAltID = &GeneralGeographyListAltID;
2792 GeopositionListPID = &GeneralGeographyListPID;
2793 GeopositionListTokens = &GeneralGeographyListTokens;
2794 GeopositionListMediatype = &GeneralGeographyListMediatype;
2795 GeopositionListPref = &GeneralGeographyListPref;
2798 GeopositionList = &HomeGeographyList;
2799 GeopositionListType = &HomeGeographyListType;
2800 GeopositionListAltID = &HomeGeographyListAltID;
2801 GeopositionListPID = &HomeGeographyListPID;
2802 GeopositionListTokens = &HomeGeographyListTokens;
2803 GeopositionListMediatype = &HomeGeographyListMediatype;
2804 GeopositionListPref = &HomeGeographyListPref;
2807 GeopositionList = &BusinessGeographyList;
2808 GeopositionListType = &BusinessGeographyListType;
2809 GeopositionListAltID = &BusinessGeographyListAltID;
2810 GeopositionListPID = &BusinessGeographyListPID;
2811 GeopositionListTokens = &BusinessGeographyListTokens;
2812 GeopositionListMediatype = &BusinessGeographyListMediatype;
2813 GeopositionListPref = &BusinessGeographyListPref;
2819 std::map<int,int>::iterator SLiter;
2820 wxString PropertyData;
2821 wxString PropertyName;
2822 wxString PropertyValue;
2823 wxString PropertyTokens;
2824 bool FirstToken = TRUE;
2826 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2827 intiter != SplitPoints.end(); ++intiter){
2829 SLiter = SplitLength.find(intiter->first);
2831 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2833 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2834 PropertyName = PropertyElement.GetNextToken();
2835 PropertyValue = PropertyElement.GetNextToken();
2837 intPrevValue = intiter->second;
2839 CaptureString(&PropertyValue, FALSE);
2841 // Process properties.
2843 if (PropertyName == wxT("ALTID")){
2845 GeopositionListAltID->erase(*GeographicCount);
2846 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2848 } else if (PropertyName == wxT("PID")){
2850 GeopositionListPID->erase(*GeographicCount);
2851 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2853 } else if (PropertyName == wxT("MEDIATYPE")){
2855 GeopositionListMediatype->erase(*GeographicCount);
2856 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2858 } else if (PropertyName == wxT("PREF")){
2860 int PriorityNumber = 0;
2861 bool ValidNumber = TRUE;
2864 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2867 catch(std::invalid_argument &e){
2868 ValidNumber = FALSE;
2871 if (ValidNumber == TRUE){
2873 GeopositionListPref->erase(*GeographicCount);
2874 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2880 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2882 if (FirstToken == TRUE){
2884 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2889 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2899 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2901 // Add the name token data.
2903 if (!PropertyTokens.IsEmpty()){
2905 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2911 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2913 size_t intPropertyLen = PropertySeg1.Len();
2914 std::map<int, int> SplitPoints;
2915 std::map<int, int> SplitLength;
2916 std::map<int, int>::iterator SLiter;
2917 wxString PropertyData;
2918 wxString PropertyName;
2919 wxString PropertyValue;
2920 wxString PropertyTokens;
2921 wxString RelatedType;
2922 wxString RelatedTypeOriginal;
2923 wxString RelatedName;
2924 bool FirstToken = TRUE;
2925 int intSplitsFound = 0;
2926 int intSplitSize = 0;
2927 int intPrevValue = 9;
2931 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2935 // Look for type before continuing.
2937 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2938 intiter != SplitPoints.end(); ++intiter){
2940 SLiter = SplitLength.find(intiter->first);
2942 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2944 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2945 PropertyName = PropertyElement.GetNextToken();
2946 PropertyValue = PropertyElement.GetNextToken();
2948 intPrevValue = intiter->second;
2952 RelatedTypeOriginal = PropertyValue;
2954 if (PropertyName == wxT("TYPE")){
2956 if (PropertyValue == wxT("contact")){
2958 RelatedType = _("Contact");
2960 } else if (PropertyValue == wxT("acquaintance")){
2962 RelatedType = _("Acquaintance");
2964 } else if (PropertyValue == wxT("friend")){
2966 RelatedType = _("Friend");
2968 } else if (PropertyValue == wxT("met")){
2970 RelatedType = _("Met");
2972 } else if (PropertyValue == wxT("co-worker")){
2974 RelatedType = _("Co-worker");
2976 } else if (PropertyValue == wxT("colleague")){
2978 RelatedType = _("Colleague");
2980 } else if (PropertyValue == wxT("co-resident")){
2982 RelatedType = _("Co-resident");
2984 } else if (PropertyValue == wxT("neighbor")){
2986 RelatedType = _("Neighbour");
2988 } else if (PropertyValue == wxT("child")){
2990 RelatedType = _("Child");
2992 } else if (PropertyValue == wxT("parent")){
2994 RelatedType = _("Parent");
2996 } else if (PropertyValue == wxT("sibling")){
2998 RelatedType = _("Sibling");
3000 } else if (PropertyValue == wxT("spouse")){
3002 RelatedType = _("Spouse");
3004 } else if (PropertyValue == wxT("kin")){
3006 RelatedType = _("Kin");
3008 } else if (PropertyValue == wxT("muse")){
3010 RelatedType = _("Muse");
3012 } else if (PropertyValue == wxT("crush")){
3014 RelatedType = _("Crush");
3016 } else if (PropertyValue == wxT("date")){
3018 RelatedType = _("Date");
3020 } else if (PropertyValue == wxT("sweetheart")){
3022 RelatedType = _("Sweetheart");
3024 } else if (PropertyValue == wxT("me")){
3026 RelatedType = _("Me");
3028 } else if (PropertyValue == wxT("agent")){
3030 RelatedType = _("Agent");
3032 } else if (PropertyValue == wxT("emergency")){
3034 RelatedType = _("Emergency");
3038 RelatedType = PropertyValue;
3048 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3049 intiter != SplitPoints.end(); ++intiter){
3051 SLiter = SplitLength.find(intiter->first);
3053 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3055 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3056 PropertyName = PropertyElement.GetNextToken();
3057 PropertyValue = PropertyElement.GetNextToken();
3059 intPrevValue = intiter->second;
3061 // Process properties.
3063 size_t intPropertyValueLen = PropertyValue.Len();
3065 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3067 PropertyValue.Trim();
3068 PropertyValue.RemoveLast();
3072 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3074 PropertyValue.Remove(0, 1);
3078 CaptureString(&PropertyValue, FALSE);
3080 if (PropertyName == wxT("ALTID")){
3082 GeneralRelatedListAltID.erase(*RelatedCount);
3083 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3085 } else if (PropertyName == wxT("PID")){
3087 GeneralRelatedListPID.erase(*RelatedCount);
3088 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3090 } else if (PropertyName == wxT("PREF")){
3092 int PriorityNumber = 0;
3093 bool ValidNumber = TRUE;
3096 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3099 catch(std::invalid_argument &e){
3100 ValidNumber = FALSE;
3103 if (ValidNumber == TRUE){
3105 GeneralRelatedListPref.erase(*RelatedCount);
3106 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3110 } else if (PropertyName == wxT("LANGUAGE")){
3112 GeneralRelatedListLanguage.erase(*RelatedCount);
3113 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3115 } else if (PropertyName != wxT("TYPE")) {
3117 // Something else we don't know about so append
3118 // to the tokens variable.
3120 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3122 if (FirstToken == TRUE){
3124 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3129 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3139 // Add the data to the General/Home/Work address variables.
3141 GeneralRelatedList.erase(*RelatedCount);
3142 GeneralRelatedListRelType.erase(*RelatedCount);
3143 GeneralRelatedListType.erase(*RelatedCount);
3144 GeneralRelatedListTokens.erase(*RelatedCount);
3145 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3146 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3147 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3148 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3152 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3154 std::map<int, int> SplitPoints;
3155 std::map<int, int> SplitLength;
3156 std::map<int, int>::iterator SLiter;
3157 wxString PropertyData;
3158 wxString PropertyName;
3159 wxString PropertyValue;
3160 wxString PropertyTokens;
3161 bool FirstToken = TRUE;
3162 int intPrevValue = 5;
3167 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3171 PropertyType PropType = PROPERTY_NONE;
3173 // Look for type before continuing.
3175 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3177 // Setup the pointers.
3179 std::map<int, wxString> *WebsiteList = NULL;
3180 std::map<int, wxString> *WebsiteListAltID = NULL;
3181 std::map<int, wxString> *WebsiteListPID = NULL;
3182 std::map<int, wxString> *WebsiteListType = NULL;
3183 std::map<int, wxString> *WebsiteListTokens = NULL;
3184 std::map<int, wxString> *WebsiteListMediatype = NULL;
3185 std::map<int, int> *WebsiteListPref = NULL;
3187 // Setup blank lines for later on.
3191 WebsiteList = &GeneralWebsiteList;
3192 WebsiteListType = &GeneralWebsiteListType;
3193 WebsiteListAltID = &GeneralWebsiteListAltID;
3194 WebsiteListPID = &GeneralWebsiteListPID;
3195 WebsiteListTokens = &GeneralWebsiteListTokens;
3196 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3197 WebsiteListPref = &GeneralWebsiteListPref;
3200 WebsiteList = &HomeWebsiteList;
3201 WebsiteListType = &HomeWebsiteListType;
3202 WebsiteListAltID = &HomeWebsiteListAltID;
3203 WebsiteListPID = &HomeWebsiteListPID;
3204 WebsiteListTokens = &HomeWebsiteListTokens;
3205 WebsiteListMediatype = &HomeWebsiteListMediatype;
3206 WebsiteListPref = &HomeWebsiteListPref;
3209 WebsiteList = &BusinessWebsiteList;
3210 WebsiteListType = &BusinessWebsiteListType;
3211 WebsiteListAltID = &BusinessWebsiteListAltID;
3212 WebsiteListPID = &BusinessWebsiteListPID;
3213 WebsiteListTokens = &BusinessWebsiteListTokens;
3214 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3215 WebsiteListPref = &BusinessWebsiteListPref;
3221 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3222 intiter != SplitPoints.end(); ++intiter){
3224 SLiter = SplitLength.find(intiter->first);
3226 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3228 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3229 PropertyName = PropertyElement.GetNextToken();
3230 PropertyValue = PropertyElement.GetNextToken();
3232 intPrevValue = intiter->second;
3234 // Process properties.
3236 size_t intPropertyValueLen = PropertyValue.Len();
3238 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3240 PropertyValue.Trim();
3241 PropertyValue.RemoveLast();
3245 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3247 PropertyValue.Remove(0, 1);
3251 CaptureString(&PropertyValue, FALSE);
3253 if (PropertyName == wxT("ALTID")){
3255 WebsiteListAltID->erase(*URLCount);
3256 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3258 } else if (PropertyName == wxT("PID")){
3260 WebsiteListPID->erase(*URLCount);
3261 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3263 } else if (PropertyName == wxT("PREF")){
3265 int PriorityNumber = 0;
3266 bool ValidNumber = TRUE;
3269 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3272 catch(std::invalid_argument &e){
3273 ValidNumber = FALSE;
3276 if (ValidNumber == TRUE){
3278 WebsiteListPref->erase(*URLCount);
3279 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3283 } else if (PropertyName == wxT("MEDIATYPE")){
3285 WebsiteListMediatype->erase(*URLCount);
3286 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3290 // Something else we don't know about so append
3291 // to the tokens variable.
3293 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3295 if (FirstToken == TRUE){
3297 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3302 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3312 // Add the data to the General/Home/Work address variables.
3314 CaptureString(&PropertySeg2, FALSE);
3316 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3318 if (!PropertyTokens.IsEmpty()){
3320 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3326 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3328 std::map<int, int> SplitPoints;
3329 std::map<int, int> SplitLength;
3330 std::map<int, int>::iterator SLiter;
3331 wxString PropertyData;
3332 wxString PropertyName;
3333 wxString PropertyValue;
3334 wxString PropertyTokens;
3335 bool FirstToken = TRUE;
3336 int intPrevValue = 7;
3341 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3345 PropertyType PropType = PROPERTY_NONE;
3347 // Look for type before continuing.
3349 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3351 // Setup the pointers.
3353 std::map<int, wxString> *TitleList = NULL;
3354 std::map<int, wxString> *TitleListAltID = NULL;
3355 std::map<int, wxString> *TitleListPID = NULL;
3356 std::map<int, wxString> *TitleListType = NULL;
3357 std::map<int, wxString> *TitleListTokens = NULL;
3358 std::map<int, wxString> *TitleListLanguage = NULL;
3359 std::map<int, int> *TitleListPref = NULL;
3361 // Setup blank lines for later on.
3365 TitleList = &GeneralTitleList;
3366 TitleListType = &GeneralTitleListType;
3367 TitleListAltID = &GeneralTitleListAltID;
3368 TitleListPID = &GeneralTitleListPID;
3369 TitleListTokens = &GeneralTitleListTokens;
3370 TitleListLanguage = &GeneralTitleListLanguage;
3371 TitleListPref = &GeneralTitleListPref;
3374 TitleList = &HomeTitleList;
3375 TitleListType = &HomeTitleListType;
3376 TitleListAltID = &HomeTitleListAltID;
3377 TitleListPID = &HomeTitleListPID;
3378 TitleListTokens = &HomeTitleListTokens;
3379 TitleListLanguage = &HomeTitleListLanguage;
3380 TitleListPref = &HomeTitleListPref;
3383 TitleList = &BusinessTitleList;
3384 TitleListType = &BusinessTitleListType;
3385 TitleListAltID = &BusinessTitleListAltID;
3386 TitleListPID = &BusinessTitleListPID;
3387 TitleListTokens = &BusinessTitleListTokens;
3388 TitleListLanguage = &BusinessTitleListLanguage;
3389 TitleListPref = &BusinessTitleListPref;
3395 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3396 intiter != SplitPoints.end(); ++intiter){
3398 SLiter = SplitLength.find(intiter->first);
3400 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3402 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3403 PropertyName = PropertyElement.GetNextToken();
3404 PropertyValue = PropertyElement.GetNextToken();
3406 intPrevValue = intiter->second;
3408 // Process properties.
3410 size_t intPropertyValueLen = PropertyValue.Len();
3412 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3414 PropertyValue.Trim();
3415 PropertyValue.RemoveLast();
3419 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3421 PropertyValue.Remove(0, 1);
3425 CaptureString(&PropertyValue, FALSE);
3427 if (PropertyName == wxT("ALTID")){
3429 TitleListAltID->erase(*TitleCount);
3430 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3432 } else if (PropertyName == wxT("PID")){
3434 TitleListPID->erase(*TitleCount);
3435 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3437 } else if (PropertyName == wxT("PREF")){
3439 int PriorityNumber = 0;
3440 bool ValidNumber = TRUE;
3443 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3446 catch(std::invalid_argument &e){
3447 ValidNumber = FALSE;
3450 if (ValidNumber == TRUE){
3452 TitleListPref->erase(*TitleCount);
3453 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3457 } else if (PropertyName == wxT("LANGUAGE")){
3459 TitleListLanguage->erase(*TitleCount);
3460 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3464 // Something else we don't know about so append
3465 // to the tokens variable.
3467 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3469 if (FirstToken == TRUE){
3471 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3476 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3486 // Add the data to the General/Home/Work address variables.
3488 CaptureString(&PropertySeg2, FALSE);
3490 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3492 if (!PropertyTokens.IsEmpty()){
3494 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3500 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3502 std::map<int, int> SplitPoints;
3503 std::map<int, int> SplitLength;
3504 std::map<int, int>::iterator SLiter;
3505 wxString PropertyData;
3506 wxString PropertyName;
3507 wxString PropertyValue;
3508 wxString PropertyTokens;
3509 bool FirstToken = TRUE;
3510 int intPrevValue = 6;
3515 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3519 PropertyType PropType = PROPERTY_NONE;
3521 // Look for type before continuing.
3523 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3525 // Setup the pointers.
3527 std::map<int, wxString> *RoleList = NULL;
3528 std::map<int, wxString> *RoleListAltID = NULL;
3529 std::map<int, wxString> *RoleListPID = NULL;
3530 std::map<int, wxString> *RoleListType = NULL;
3531 std::map<int, wxString> *RoleListTokens = NULL;
3532 std::map<int, wxString> *RoleListLanguage = NULL;
3533 std::map<int, int> *RoleListPref = NULL;
3535 // Setup blank lines for later on.
3539 RoleList = &GeneralRoleList;
3540 RoleListType = &GeneralRoleListType;
3541 RoleListAltID = &GeneralRoleListAltID;
3542 RoleListPID = &GeneralRoleListPID;
3543 RoleListTokens = &GeneralRoleListTokens;
3544 RoleListLanguage = &GeneralRoleListLanguage;
3545 RoleListPref = &GeneralRoleListPref;
3548 RoleList = &HomeRoleList;
3549 RoleListType = &HomeRoleListType;
3550 RoleListAltID = &HomeRoleListAltID;
3551 RoleListPID = &HomeRoleListPID;
3552 RoleListTokens = &HomeRoleListTokens;
3553 RoleListLanguage = &HomeRoleListLanguage;
3554 RoleListPref = &HomeRoleListPref;
3557 RoleList = &BusinessRoleList;
3558 RoleListType = &BusinessRoleListType;
3559 RoleListAltID = &BusinessRoleListAltID;
3560 RoleListPID = &BusinessRoleListPID;
3561 RoleListTokens = &BusinessRoleListTokens;
3562 RoleListLanguage = &BusinessRoleListLanguage;
3563 RoleListPref = &BusinessRoleListPref;
3569 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3570 intiter != SplitPoints.end(); ++intiter){
3572 SLiter = SplitLength.find(intiter->first);
3574 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3576 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3577 PropertyName = PropertyElement.GetNextToken();
3578 PropertyValue = PropertyElement.GetNextToken();
3580 intPrevValue = intiter->second;
3582 // Process properties.
3584 size_t intPropertyValueLen = PropertyValue.Len();
3586 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3588 PropertyValue.Trim();
3589 PropertyValue.RemoveLast();
3593 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3595 PropertyValue.Remove(0, 1);
3599 CaptureString(&PropertyValue, FALSE);
3601 if (PropertyName == wxT("ALTID")){
3603 RoleListAltID->erase(*RoleCount);
3604 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3606 } else if (PropertyName == wxT("PID")){
3608 RoleListPID->erase(*RoleCount);
3609 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3611 } else if (PropertyName == wxT("PREF")){
3613 int PriorityNumber = 0;
3614 bool ValidNumber = TRUE;
3617 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3620 catch(std::invalid_argument &e){
3621 ValidNumber = FALSE;
3624 if (ValidNumber == TRUE){
3626 RoleListPref->erase(*RoleCount);
3627 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3631 } else if (PropertyName == wxT("LANGUAGE")){
3633 RoleListLanguage->erase(*RoleCount);
3634 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3638 // Something else we don't know about so append
3639 // to the tokens variable.
3641 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3643 if (FirstToken == TRUE){
3645 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3650 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3660 // Add the data to the General/Home/Work address variables.
3662 CaptureString(&PropertySeg2, FALSE);
3664 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3666 if (!PropertyTokens.IsEmpty()){
3668 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3674 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3676 std::map<int, int> SplitPoints;
3677 std::map<int, int> SplitLength;
3678 std::map<int, int>::iterator SLiter;
3679 wxString PropertyData;
3680 wxString PropertyName;
3681 wxString PropertyValue;
3682 wxString PropertyTokens;
3683 bool FirstToken = TRUE;
3684 int intPrevValue = 5;
3689 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3693 PropertyType PropType = PROPERTY_NONE;
3695 // Look for type before continuing.
3697 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3699 // Setup the pointers.
3701 std::map<int, wxString> *OrganisationsList = NULL;
3702 std::map<int, wxString> *OrganisationsListAltID = NULL;
3703 std::map<int, wxString> *OrganisationsListPID = NULL;
3704 std::map<int, wxString> *OrganisationsListType = NULL;
3705 std::map<int, wxString> *OrganisationsListTokens = NULL;
3706 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3707 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3708 std::map<int, int> *OrganisationsListPref = NULL;
3710 // Setup blank lines for later on.
3714 OrganisationsList = &GeneralOrganisationsList;
3715 OrganisationsListType = &GeneralOrganisationsListType;
3716 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3717 OrganisationsListPID = &GeneralOrganisationsListPID;
3718 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3719 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3720 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3721 OrganisationsListPref = &GeneralOrganisationsListPref;
3724 OrganisationsList = &HomeOrganisationsList;
3725 OrganisationsListType = &HomeOrganisationsListType;
3726 OrganisationsListAltID = &HomeOrganisationsListAltID;
3727 OrganisationsListPID = &HomeOrganisationsListPID;
3728 OrganisationsListTokens = &HomeOrganisationsListTokens;
3729 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3730 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3731 OrganisationsListPref = &HomeOrganisationsListPref;
3734 OrganisationsList = &BusinessOrganisationsList;
3735 OrganisationsListType = &BusinessOrganisationsListType;
3736 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3737 OrganisationsListPID = &BusinessOrganisationsListPID;
3738 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3739 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3740 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3741 OrganisationsListPref = &BusinessOrganisationsListPref;
3747 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3748 intiter != SplitPoints.end(); ++intiter){
3750 SLiter = SplitLength.find(intiter->first);
3752 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3754 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3755 PropertyName = PropertyElement.GetNextToken();
3756 PropertyValue = PropertyElement.GetNextToken();
3758 intPrevValue = intiter->second;
3760 // Process properties.
3762 size_t intPropertyValueLen = PropertyValue.Len();
3764 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3766 PropertyValue.Trim();
3767 PropertyValue.RemoveLast();
3771 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3773 PropertyValue.Remove(0, 1);
3777 CaptureString(&PropertyValue, FALSE);
3779 if (PropertyName == wxT("ALTID")){
3781 OrganisationsListAltID->erase(*OrganisationCount);
3782 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3784 } else if (PropertyName == wxT("PID")){
3786 OrganisationsListPID->erase(*OrganisationCount);
3787 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3789 } else if (PropertyName == wxT("SORT-AS")){
3791 OrganisationsListSortAs->erase(*OrganisationCount);
3792 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3794 } else if (PropertyName == wxT("PREF")){
3796 int PriorityNumber = 0;
3797 bool ValidNumber = TRUE;
3800 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3803 catch(std::invalid_argument &e){
3804 ValidNumber = FALSE;
3807 if (ValidNumber == TRUE){
3809 OrganisationsListPref->erase(*OrganisationCount);
3810 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3814 } else if (PropertyName == wxT("LANGUAGE")){
3816 OrganisationsListLanguage->erase(*OrganisationCount);
3817 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3821 // Something else we don't know about so append
3822 // to the tokens variable.
3824 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3826 if (FirstToken == TRUE){
3828 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3833 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3843 // Add the data to the General/Home/Work address variables.
3845 CaptureString(&PropertySeg2, FALSE);
3847 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3849 if (!PropertyTokens.IsEmpty()){
3851 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3857 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3859 std::map<int, int> SplitPoints;
3860 std::map<int, int> SplitLength;
3861 std::map<int, int>::iterator SLiter;
3862 wxString PropertyData;
3863 wxString PropertyName;
3864 wxString PropertyValue;
3865 wxString PropertyTokens;
3866 bool FirstToken = TRUE;
3867 int intPrevValue = 6;
3872 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3876 PropertyType PropType = PROPERTY_NONE;
3878 // Look for type before continuing.
3880 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3882 // Setup the pointers.
3884 std::map<int, wxString> *NoteList = NULL;
3885 std::map<int, wxString> *NoteListAltID = NULL;
3886 std::map<int, wxString> *NoteListPID = NULL;
3887 std::map<int, wxString> *NoteListType = NULL;
3888 std::map<int, wxString> *NoteListTokens = NULL;
3889 std::map<int, wxString> *NoteListLanguage = NULL;
3890 std::map<int, int> *NoteListPref = NULL;
3892 // Setup blank lines for later on.
3896 NoteList = &GeneralNoteList;
3897 NoteListType = &GeneralNoteListType;
3898 NoteListAltID = &GeneralNoteListAltID;
3899 NoteListPID = &GeneralNoteListPID;
3900 NoteListTokens = &GeneralNoteListTokens;
3901 NoteListLanguage = &GeneralNoteListLanguage;
3902 NoteListPref = &GeneralNoteListPref;
3905 NoteList = &HomeNoteList;
3906 NoteListType = &HomeNoteListType;
3907 NoteListAltID = &HomeNoteListAltID;
3908 NoteListPID = &HomeNoteListPID;
3909 NoteListTokens = &HomeNoteListTokens;
3910 NoteListLanguage = &HomeNoteListLanguage;
3911 NoteListPref = &HomeNoteListPref;
3914 NoteList = &BusinessNoteList;
3915 NoteListType = &BusinessNoteListType;
3916 NoteListAltID = &BusinessNoteListAltID;
3917 NoteListPID = &BusinessNoteListPID;
3918 NoteListTokens = &BusinessNoteListTokens;
3919 NoteListLanguage = &BusinessNoteListLanguage;
3920 NoteListPref = &BusinessNoteListPref;
3926 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3927 intiter != SplitPoints.end(); ++intiter){
3929 SLiter = SplitLength.find(intiter->first);
3931 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3933 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3934 PropertyName = PropertyElement.GetNextToken();
3935 PropertyValue = PropertyElement.GetNextToken();
3937 intPrevValue = intiter->second;
3939 // Process properties.
3941 size_t intPropertyValueLen = PropertyValue.Len();
3943 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3945 PropertyValue.Trim();
3946 PropertyValue.RemoveLast();
3950 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3952 PropertyValue.Remove(0, 1);
3956 CaptureString(&PropertyValue, FALSE);
3958 if (PropertyName == wxT("ALTID")){
3960 NoteListAltID->erase(*NoteCount);
3961 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3963 } else if (PropertyName == wxT("PID")){
3965 NoteListPID->erase(*NoteCount);
3966 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3968 } else if (PropertyName == wxT("PREF")){
3970 int PriorityNumber = 0;
3971 bool ValidNumber = TRUE;
3974 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3977 catch(std::invalid_argument &e){
3978 ValidNumber = FALSE;
3981 if (ValidNumber == TRUE){
3983 NoteListPref->erase(*NoteCount);
3984 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3988 } else if (PropertyName == wxT("LANGUAGE")){
3990 NoteListLanguage->erase(*NoteCount);
3991 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3995 // Something else we don't know about so append
3996 // to the tokens variable.
3998 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4000 if (FirstToken == TRUE){
4002 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4007 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4017 // Add the data to the General/Home/Work address variables.
4019 CaptureString(&PropertySeg2, FALSE);
4021 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4023 if (!PropertyTokens.IsEmpty()){
4025 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4031 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4033 std::map<int, int> SplitPoints;
4034 std::map<int, int> SplitLength;
4035 std::map<int, int>::iterator SLiter;
4036 wxString PropertyData;
4037 wxString PropertyName;
4038 wxString PropertyValue;
4039 wxString PropertyTokens;
4040 bool FirstToken = TRUE;
4041 int intPrevValue = 12;
4046 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4050 PropertyType PropType = PROPERTY_NONE;
4052 // Look for type before continuing.
4054 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4056 // Setup blank lines for later on.
4062 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4065 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4071 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4072 intiter != SplitPoints.end(); ++intiter){
4074 SLiter = SplitLength.find(intiter->first);
4076 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4078 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4079 PropertyName = PropertyElement.GetNextToken();
4080 PropertyValue = PropertyElement.GetNextToken();
4082 intPrevValue = intiter->second;
4084 // Process properties.
4086 size_t intPropertyValueLen = PropertyValue.Len();
4088 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4090 PropertyValue.Trim();
4091 PropertyValue.RemoveLast();
4095 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4097 PropertyValue.Remove(0, 1);
4101 CaptureString(&PropertyValue, FALSE);
4103 if (PropertyName == wxT("ALTID")){
4105 CategoriesListAltID.erase(*CategoryCount);
4106 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4108 } else if (PropertyName == wxT("PID")){
4110 CategoriesListPID.erase(*CategoryCount);
4111 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4113 } else if (PropertyName == wxT("PREF")){
4115 int PriorityNumber = 0;
4116 bool ValidNumber = TRUE;
4119 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4122 catch(std::invalid_argument &e){
4123 ValidNumber = FALSE;
4126 if (ValidNumber == TRUE){
4128 CategoriesListPref.erase(*CategoryCount);
4129 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4133 } else if (PropertyName == wxT("LANGUAGE")){
4135 CategoriesListLanguage.erase(*CategoryCount);
4136 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4140 // Something else we don't know about so append
4141 // to the tokens variable.
4143 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4145 if (FirstToken == TRUE){
4147 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4152 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4162 // Deal with multiple categories.
4164 int intOrigCatCount = *CategoryCount;
4165 bool FirstCategoryProcessed = TRUE;
4166 bool AfterFirstToken = FALSE;
4167 int intSplitSize = 0;
4168 int intSplitsFound = 0;
4169 int intSplitSeek = 0;
4170 int intPropertyLen = PropertySeg2.Len();
4172 SplitPoints.clear();
4173 SplitLength.clear();
4176 for (int i = 0; i <= intPropertyLen; i++){
4178 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4186 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4188 if (AfterFirstToken == TRUE){
4190 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4191 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4195 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4196 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4197 AfterFirstToken = TRUE;
4209 if (SplitPoints.size() > 0){
4211 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4212 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4216 if (SplitPoints.size() == 0){
4218 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4220 if (!PropertyTokens.IsEmpty()){
4222 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4228 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4229 intiter != SplitPoints.end(); ++intiter){
4231 SLiter = SplitLength.find(intiter->first);
4233 intPrevValue = intiter->second;
4235 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4237 // Add the data to the General/Home/Work address variables.
4239 // Trim any whitespace from the start and end.
4241 PropertyData = PropertyData.Trim(FALSE);
4242 PropertyData = PropertyData.Trim(TRUE);
4244 CaptureString(&PropertyData, FALSE);
4246 if (FirstCategoryProcessed == TRUE){
4248 FirstCategoryProcessed = FALSE;
4250 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4252 if (!PropertyTokens.IsEmpty()){
4254 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4264 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4266 if (!PropertyTokens.IsEmpty()){
4268 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4274 // Copy the properties to each of the categories (if it exists).
4276 if (!PropertyTokens.IsEmpty()){
4278 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4282 // Check if ALTID was used.
4284 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4286 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4290 // Check if PID was used.
4292 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4294 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4298 // Check if PREF was used.
4300 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4302 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4306 // Check if LANGUAGE was used.
4308 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4310 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4314 // Check if TYPE was used.
4320 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4323 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4331 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4333 size_t intPropertyLen = PropertySeg1.Len();
4334 std::map<int, int> SplitPoints;
4335 std::map<int, int> SplitLength;
4336 std::map<int, int>::iterator SLiter;
4337 wxString PropertyData;
4338 wxString PropertyName;
4339 wxString PropertyValue;
4340 wxString PropertyTokens;
4341 bool FirstToken = TRUE;
4342 int intSplitsFound = 0;
4343 int intSplitSize = 0;
4344 int intPrevValue = 7;
4348 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4352 PropertyType PropType = PROPERTY_NONE;
4354 // Look for type before continuing.
4356 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4360 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4361 intiter != SplitPoints.end(); ++intiter){
4363 SLiter = SplitLength.find(intiter->first);
4365 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4367 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4368 PropertyName = PropertyElement.GetNextToken();
4369 PropertyValue = PropertyElement.GetNextToken();
4371 intPrevValue = intiter->second;
4373 // Process properties.
4375 size_t intPropertyValueLen = PropertyValue.Len();
4377 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4379 PropertyValue.Trim();
4380 PropertyValue.RemoveLast();
4384 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4386 PropertyValue.Remove(0, 1);
4390 CaptureString(&PropertyValue, FALSE);
4392 if (PropertyName == wxT("ALTID")){
4394 PicturesListAltID.erase(*PhotoCount);
4395 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4397 } else if (PropertyName == wxT("PID")){
4399 PicturesListPID.erase(*PhotoCount);
4400 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4402 } else if (PropertyName == wxT("PREF")){
4404 int PriorityNumber = 0;
4405 bool ValidNumber = TRUE;
4408 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4411 catch(std::invalid_argument &e){
4412 ValidNumber = FALSE;
4415 if (ValidNumber == TRUE){
4417 PicturesListPref.erase(*PhotoCount);
4418 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4422 } else if (PropertyName == wxT("MEDIATYPE")){
4424 PicturesListMediatype.erase(*PhotoCount);
4425 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4429 // Something else we don't know about so append
4430 // to the tokens variable.
4432 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4434 if (FirstToken == TRUE){
4436 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4441 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4451 intPropertyLen = PropertySeg2.Len();
4452 SplitPoints.clear();
4453 SplitLength.clear();
4458 CaptureString(&PropertySeg2, FALSE);
4460 for (int i = 0; i <= intPropertyLen; i++){
4464 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4467 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4469 if (intSplitsFound == 6){
4471 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4476 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4486 wxString wxSPhotoURI;
4487 wxString wxSPhotoMIME;
4488 wxString wxSPhotoEncoding;
4489 wxString wxSPhotoData;
4490 std::string base64enc;
4492 if (intSplitsFound == 0){
4496 std::map<int, int>::iterator striter;
4498 striter = SplitLength.find(1);
4500 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4502 while (wSTDataType.HasMoreTokens() == TRUE){
4504 wxSPhotoURI = wSTDataType.GetNextToken();
4505 wxSPhotoMIME = wSTDataType.GetNextToken();
4510 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4512 while (wSTDataInfo.HasMoreTokens() == TRUE){
4514 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4515 wxSPhotoData = wSTDataInfo.GetNextToken();
4516 base64enc = wxSPhotoData.mb_str();
4523 // Add the data to the General/Home/Work address variables.
4525 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4526 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4527 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4533 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4536 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4540 if (!PropertyTokens.IsEmpty()){
4542 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4548 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4550 size_t intPropertyLen = PropertySeg1.Len();
4551 std::map<int, int> SplitPoints;
4552 std::map<int, int> SplitLength;
4553 std::map<int, int>::iterator SLiter;
4554 wxString PropertyData;
4555 wxString PropertyName;
4556 wxString PropertyValue;
4557 wxString PropertyTokens;
4558 bool FirstToken = TRUE;
4559 int intSplitsFound = 0;
4560 int intSplitSize = 0;
4561 int intPrevValue = 6;
4565 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4569 PropertyType PropType = PROPERTY_NONE;
4571 // Look for type before continuing.
4573 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4577 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4578 intiter != SplitPoints.end(); ++intiter){
4580 SLiter = SplitLength.find(intiter->first);
4582 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4584 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4585 PropertyName = PropertyElement.GetNextToken();
4586 PropertyValue = PropertyElement.GetNextToken();
4588 intPrevValue = intiter->second;
4590 // Process properties.
4592 size_t intPropertyValueLen = PropertyValue.Len();
4594 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4596 PropertyValue.Trim();
4597 PropertyValue.RemoveLast();
4601 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4603 PropertyValue.Remove(0, 1);
4607 CaptureString(&PropertyValue, FALSE);
4609 if (PropertyName == wxT("ALTID")){
4611 LogosListAltID.erase(*LogoCount);
4612 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4614 } else if (PropertyName == wxT("PID")){
4616 LogosListPID.erase(*LogoCount);
4617 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4619 } else if (PropertyName == wxT("PREF")){
4621 int PriorityNumber = 0;
4622 bool ValidNumber = TRUE;
4625 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4628 catch(std::invalid_argument &e){
4629 ValidNumber = FALSE;
4632 if (ValidNumber == TRUE){
4634 LogosListPref.erase(*LogoCount);
4635 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4639 } else if (PropertyName == wxT("MEDIATYPE")){
4641 LogosListMediatype.erase(*LogoCount);
4642 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4646 // Something else we don't know about so append
4647 // to the tokens variable.
4649 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4651 if (FirstToken == TRUE){
4653 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4658 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4668 intPropertyLen = PropertySeg2.Len();
4669 SplitPoints.clear();
4670 SplitLength.clear();
4675 CaptureString(&PropertySeg2, FALSE);
4677 for (int i = 0; i <= intPropertyLen; i++){
4681 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4684 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4686 if (intSplitsFound == 6){
4688 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4693 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4703 wxString wxSPhotoURI;
4704 wxString wxSPhotoMIME;
4705 wxString wxSPhotoEncoding;
4706 wxString wxSPhotoData;
4707 std::string base64enc;
4709 if (intSplitsFound == 0){
4713 std::map<int, int>::iterator striter;
4715 striter = SplitLength.find(1);
4717 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4719 while (wSTDataType.HasMoreTokens() == TRUE){
4721 wxSPhotoURI = wSTDataType.GetNextToken();
4722 wxSPhotoMIME = wSTDataType.GetNextToken();
4727 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4729 while (wSTDataInfo.HasMoreTokens() == TRUE){
4731 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4732 wxSPhotoData = wSTDataInfo.GetNextToken();
4733 base64enc = wxSPhotoData.mb_str();
4740 // Add the data to the General/Home/Work address variables.
4742 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4743 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4744 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4750 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4753 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4757 if (!PropertyTokens.IsEmpty()){
4759 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4765 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4767 size_t intPropertyLen = PropertySeg1.Len();
4768 std::map<int, int> SplitPoints;
4769 std::map<int, int> SplitLength;
4770 std::map<int, int>::iterator SLiter;
4771 wxString PropertyData;
4772 wxString PropertyName;
4773 wxString PropertyValue;
4774 wxString PropertyTokens;
4775 bool FirstToken = TRUE;
4776 int intSplitsFound = 0;
4777 int intSplitSize = 0;
4778 int intPrevValue = 7;
4782 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4786 PropertyType PropType = PROPERTY_NONE;
4788 // Look for type before continuing.
4790 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4794 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4795 intiter != SplitPoints.end(); ++intiter){
4797 SLiter = SplitLength.find(intiter->first);
4799 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4801 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4802 PropertyName = PropertyElement.GetNextToken();
4803 PropertyValue = PropertyElement.GetNextToken();
4805 intPrevValue = intiter->second;
4807 // Process properties.
4809 size_t intPropertyValueLen = PropertyValue.Len();
4811 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4813 PropertyValue.Trim();
4814 PropertyValue.RemoveLast();
4818 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4820 PropertyValue.Remove(0, 1);
4824 CaptureString(&PropertyValue, FALSE);
4826 if (PropertyName == wxT("ALTID")){
4828 SoundsListAltID.erase(*SoundCount);
4829 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4831 } else if (PropertyName == wxT("PID")){
4833 SoundsListPID.erase(*SoundCount);
4834 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4836 } else if (PropertyName == wxT("PREF")){
4838 int PriorityNumber = 0;
4839 bool ValidNumber = TRUE;
4842 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4845 catch(std::invalid_argument &e){
4846 ValidNumber = FALSE;
4849 if (ValidNumber == TRUE){
4851 SoundsListPref.erase(*SoundCount);
4852 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4856 } else if (PropertyName == wxT("MEDIATYPE")){
4858 SoundsListMediatype.erase(*SoundCount);
4859 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4861 } else if (PropertyName == wxT("LANGUAGE")){
4863 SoundsListLanguage.erase(*SoundCount);
4864 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4868 // Something else we don't know about so append
4869 // to the tokens variable.
4871 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4873 if (FirstToken == TRUE){
4875 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4880 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4890 intPropertyLen = PropertySeg2.Len();
4891 SplitPoints.clear();
4892 SplitLength.clear();
4897 CaptureString(&PropertySeg2, FALSE);
4899 for (int i = 0; i <= intPropertyLen; i++){
4903 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4906 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4908 if (intSplitsFound == 6){
4910 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4915 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4925 wxString wxSSoundURI;
4926 wxString wxSSoundMIME;
4927 wxString wxSSoundEncoding;
4928 wxString wxSSoundData;
4929 std::string base64enc;
4931 if (intSplitsFound == 0){
4935 std::map<int, int>::iterator striter;
4937 striter = SplitLength.find(1);
4939 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4941 while (wSTDataType.HasMoreTokens() == TRUE){
4943 wxSSoundURI = wSTDataType.GetNextToken();
4944 wxSSoundMIME = wSTDataType.GetNextToken();
4949 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4951 while (wSTDataInfo.HasMoreTokens() == TRUE){
4953 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4954 wxSSoundData = wSTDataInfo.GetNextToken();
4955 base64enc = wxSSoundData.mb_str();
4962 // Add the data to the General/Home/Work address variables.
4968 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4971 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4975 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4976 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4977 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4979 if (!PropertyTokens.IsEmpty()){
4981 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4987 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4989 size_t intPropertyLen = PropertySeg1.Len();
4990 std::map<int, int> SplitPoints;
4991 std::map<int, int> SplitLength;
4992 std::map<int, int>::iterator SLiter;
4993 wxString PropertyData;
4994 wxString PropertyName;
4995 wxString PropertyValue;
4996 wxString PropertyTokens;
4997 bool FirstToken = TRUE;
4998 int intSplitsFound = 0;
4999 int intSplitSize = 0;
5000 int intPrevValue = 8;
5004 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5008 PropertyType PropType = PROPERTY_NONE;
5010 // Look for type before continuing.
5012 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5016 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5017 intiter != SplitPoints.end(); ++intiter){
5019 SLiter = SplitLength.find(intiter->first);
5021 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5023 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5024 PropertyName = PropertyElement.GetNextToken();
5025 PropertyValue = PropertyElement.GetNextToken();
5027 intPrevValue = intiter->second;
5029 // Process properties.
5031 size_t intPropertyValueLen = PropertyValue.Len();
5033 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5035 PropertyValue.Trim();
5036 PropertyValue.RemoveLast();
5040 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5042 PropertyValue.Remove(0, 1);
5046 CaptureString(&PropertyValue, FALSE);
5048 if (PropertyName == wxT("ALTID")){
5050 CalendarListAltID.erase(*CalURICount);
5051 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5053 } else if (PropertyName == wxT("PID")){
5055 CalendarListPID.erase(*CalURICount);
5056 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5058 } else if (PropertyName == wxT("PREF")){
5060 int PriorityNumber = 0;
5061 bool ValidNumber = TRUE;
5064 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5067 catch(std::invalid_argument &e){
5068 ValidNumber = FALSE;
5071 if (ValidNumber == TRUE){
5073 CalendarListPref.erase(*CalURICount);
5074 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5078 } else if (PropertyName == wxT("MEDIATYPE")){
5080 CalendarListMediatype.erase(*CalURICount);
5081 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5085 // Something else we don't know about so append
5086 // to the tokens variable.
5088 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5090 if (FirstToken == TRUE){
5092 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5097 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5107 intPropertyLen = PropertySeg2.Len();
5108 SplitPoints.clear();
5109 SplitLength.clear();
5114 CaptureString(&PropertySeg2, FALSE);
5116 // Add the data to the General/Home/Work address variables.
5122 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5125 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5129 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5131 if (!PropertyTokens.IsEmpty()){
5133 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5139 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5141 size_t intPropertyLen = PropertySeg1.Len();
5142 std::map<int, int> SplitPoints;
5143 std::map<int, int> SplitLength;
5144 std::map<int, int>::iterator SLiter;
5145 wxString PropertyData;
5146 wxString PropertyName;
5147 wxString PropertyValue;
5148 wxString PropertyTokens;
5149 bool FirstToken = TRUE;
5150 int intSplitsFound = 0;
5151 int intSplitSize = 0;
5152 int intPrevValue = 8;
5156 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5160 PropertyType PropType = PROPERTY_NONE;
5162 // Look for type before continuing.
5164 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5168 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5169 intiter != SplitPoints.end(); ++intiter){
5171 SLiter = SplitLength.find(intiter->first);
5173 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5175 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5176 PropertyName = PropertyElement.GetNextToken();
5177 PropertyValue = PropertyElement.GetNextToken();
5179 intPrevValue = intiter->second;
5181 // Process properties.
5183 size_t intPropertyValueLen = PropertyValue.Len();
5185 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5187 PropertyValue.Trim();
5188 PropertyValue.RemoveLast();
5192 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5194 PropertyValue.Remove(0, 1);
5198 CaptureString(&PropertyValue, FALSE);
5200 if (PropertyName == wxT("ALTID")){
5202 CalendarRequestListAltID.erase(*CalAdrURICount);
5203 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5205 } else if (PropertyName == wxT("PID")){
5207 CalendarRequestListPID.erase(*CalAdrURICount);
5208 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5210 } else if (PropertyName == wxT("PREF")){
5212 int PriorityNumber = 0;
5213 bool ValidNumber = TRUE;
5216 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5219 catch(std::invalid_argument &e){
5220 ValidNumber = FALSE;
5223 if (ValidNumber == TRUE){
5225 CalendarRequestListPref.erase(*CalAdrURICount);
5226 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5230 } else if (PropertyName == wxT("MEDIATYPE")){
5232 CalendarRequestListMediatype.erase(*CalAdrURICount);
5233 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5237 // Something else we don't know about so append
5238 // to the tokens variable.
5240 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5242 if (FirstToken == TRUE){
5244 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5249 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5259 intPropertyLen = PropertySeg2.Len();
5260 SplitPoints.clear();
5261 SplitLength.clear();
5266 CaptureString(&PropertySeg2, FALSE);
5268 // Add the data to the General/Home/Work address variables.
5274 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5277 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5281 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5283 if (!PropertyTokens.IsEmpty()){
5285 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5291 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5293 size_t intPropertyLen = PropertySeg1.Len();
5294 std::map<int, int> SplitPoints;
5295 std::map<int, int> SplitLength;
5296 std::map<int, int>::iterator SLiter;
5297 wxString PropertyData;
5298 wxString PropertyName;
5299 wxString PropertyValue;
5300 wxString PropertyTokens;
5301 bool FirstToken = TRUE;
5302 int intSplitsFound = 0;
5303 int intSplitSize = 0;
5304 int intPrevValue = 7;
5308 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5312 PropertyType PropType = PROPERTY_NONE;
5314 // Look for type before continuing.
5316 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5320 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5321 intiter != SplitPoints.end(); ++intiter){
5323 SLiter = SplitLength.find(intiter->first);
5325 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5327 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5328 PropertyName = PropertyElement.GetNextToken();
5329 PropertyValue = PropertyElement.GetNextToken();
5331 intPrevValue = intiter->second;
5333 // Process properties.
5335 size_t intPropertyValueLen = PropertyValue.Len();
5337 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5339 PropertyValue.Trim();
5340 PropertyValue.RemoveLast();
5344 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5346 PropertyValue.Remove(0, 1);
5350 CaptureString(&PropertyValue, FALSE);
5352 if (PropertyName == wxT("ALTID")){
5354 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5355 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5357 } else if (PropertyName == wxT("PID")){
5359 FreeBusyListPID.erase(*FreeBusyAddressCount);
5360 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5362 } else if (PropertyName == wxT("PREF")){
5364 int PriorityNumber = 0;
5365 bool ValidNumber = TRUE;
5368 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5371 catch(std::invalid_argument &e){
5372 ValidNumber = FALSE;
5375 if (ValidNumber == TRUE){
5377 FreeBusyListPref.erase(*FreeBusyAddressCount);
5378 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5382 } else if (PropertyName == wxT("MEDIATYPE")){
5384 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5385 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5389 // Something else we don't know about so append
5390 // to the tokens variable.
5392 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5394 if (FirstToken == TRUE){
5396 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5401 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5411 intPropertyLen = PropertySeg2.Len();
5412 SplitPoints.clear();
5413 SplitLength.clear();
5418 CaptureString(&PropertySeg2, FALSE);
5420 // Add the data to the General/Home/Work address variables.
5426 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5429 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5433 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5435 if (!PropertyTokens.IsEmpty()){
5437 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5443 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5445 size_t intPropertyLen = PropertySeg1.Len();
5446 std::map<int, int> SplitPoints;
5447 std::map<int, int> SplitLength;
5448 std::map<int, int>::iterator SLiter;
5449 wxString PropertyData;
5450 wxString PropertyName;
5451 wxString PropertyValue;
5452 wxString PropertyTokens;
5453 bool FirstToken = TRUE;
5454 int intSplitsFound = 0;
5455 int intSplitSize = 0;
5456 int intPrevValue = 5;
5461 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5465 PropertyType PropType = PROPERTY_NONE;
5467 // Look for type before continuing.
5469 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5473 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5474 intiter != SplitPoints.end(); ++intiter){
5476 SLiter = SplitLength.find(intiter->first);
5478 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5480 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5481 PropertyName = PropertyElement.GetNextToken();
5482 PropertyValue = PropertyElement.GetNextToken();
5484 intPrevValue = intiter->second;
5486 // Process properties.
5488 size_t intPropertyValueLen = PropertyValue.Len();
5490 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5492 PropertyValue.Trim();
5493 PropertyValue.RemoveLast();
5497 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5499 PropertyValue.Remove(0, 1);
5503 if (PropertyName == wxT("ALTID")){
5505 KeyListAltID.erase(*KeyCount);
5506 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5508 } else if (PropertyName == wxT("PID")){
5510 KeyListPID.erase(*KeyCount);
5511 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5513 } else if (PropertyName == wxT("PREF")){
5515 int PriorityNumber = 0;
5516 bool ValidNumber = TRUE;
5519 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5522 catch(std::invalid_argument &e){
5523 ValidNumber = FALSE;
5526 if (ValidNumber == TRUE){
5528 KeyListPref.erase(*KeyCount);
5529 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5535 // Something else we don't know about so append
5536 // to the tokens variable.
5538 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5540 if (FirstToken == TRUE){
5542 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5547 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5557 intPropertyLen = PropertySeg2.Len();
5558 SplitPoints.clear();
5559 SplitLength.clear();
5564 for (int i = 0; i <= intPropertyLen; i++){
5568 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5571 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5573 if (intSplitsFound == 6){
5575 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5580 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5591 wxString wxSKeyMIME;
5592 wxString wxSKeyEncoding;
5593 wxString wxSKeyData;
5594 std::string base64enc;
5596 if (intSplitsFound == 0){
5600 std::map<int, int>::iterator striter;
5602 striter = SplitLength.find(1);
5604 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5606 while (wSTDataType.HasMoreTokens() == TRUE){
5608 wxSKeyURI = wSTDataType.GetNextToken();
5609 wxSKeyMIME = wSTDataType.GetNextToken();
5614 if (wxSKeyURI == wxT("data")){
5616 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5618 while (wSTDataInfo.HasMoreTokens() == TRUE){
5620 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5621 wxSKeyData = wSTDataInfo.GetNextToken();
5630 // Add the data to the General/Home/Work address variables.
5632 if (wxSKeyURI == wxT("data")){
5634 KeyListDataEncType.erase(*KeyCount);
5635 KeyListKeyType.erase(*KeyCount);
5636 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5637 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5639 KeyList.erase(*KeyCount);
5640 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5644 KeyList.erase(*KeyCount);
5645 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5649 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5655 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5658 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5662 if (!PropertyTokens.IsEmpty()){
5664 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5670 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5672 // Split the Vendor three ways.
5674 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5677 wxString wxSVNDPropName;
5680 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5682 wSTVendorDetails.GetNextToken();
5683 wxSVNDID = wSTVendorDetails.GetNextToken();
5684 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5689 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5691 // Add the data to the vendor variables.
5693 VendorList.erase(*VendorCount);
5694 VendorListPEN.erase(*VendorCount);
5695 VendorListElement.erase(*VendorCount);
5697 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5698 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5699 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5705 void SplitValues(wxString *PropertyLine,
5706 std::map<int,int> *SplitPoints,
5707 std::map<int,int> *SplitLength,
5710 size_t intPropertyLen = PropertyLine->Len();
5711 int intSplitsFound = 0;
5712 int intSplitSize = 0;
5713 int intSplitSeek = 0;
5715 for (int i = intSize; i <= intPropertyLen; i++){
5719 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5720 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5722 if (intSplitsFound == 0){
5724 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5728 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5732 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5742 if (intSplitsFound == 0){
5744 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5745 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5749 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5750 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5756 void CheckType(wxString *PropertySeg1,
5757 std::map<int,int> *SplitPoints,
5758 std::map<int,int> *SplitLength,
5760 PropertyType *PropType){
5762 wxString PropertyData;
5763 wxString PropertyName;
5764 wxString PropertyValue;
5765 std::map<int,int>::iterator SLiter;
5767 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5768 intiter != SplitPoints->end(); ++intiter){
5770 SLiter = SplitLength->find(intiter->first);
5772 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5774 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5775 PropertyName = PropertyElement.GetNextToken();
5776 PropertyValue = PropertyElement.GetNextToken();
5778 *intPrevValue = intiter->second;
5780 if (PropertyName == wxT("TYPE")){
5782 if (PropertyValue == wxT("work")){
5784 *PropType = PROPERTY_WORK;
5786 } else if (PropertyValue == wxT("home")){
5788 *PropType = PROPERTY_HOME;
5792 *PropType = PROPERTY_NONE;