1 // ContactDataObject.cpp - Client Data Object.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 bool UIDProcessed = FALSE;
82 bool RevisionProcessed = FALSE;
83 int ContactLineLen = 0;
84 int QuoteBreakPoint = 0;
88 int NicknameCount = 0;
89 int TimeZoneCount = 0;
93 int TelephoneCount = 0;
94 int LanguageCount = 0;
95 int GeographicCount = 0;
100 int OrganisationCount = 0;
102 int CategoryCount = 0;
106 int CalendarCount = 0;
107 int CalendarAddressCount = 0;
108 int FreeBusyAddressCount = 0;
113 int ClientPIDCount = 0;
114 wxString ContactLine;
115 wxString PropertyLine;
116 wxString PropertySeg1;
117 wxString PropertySeg2;
118 wxString PropertyNextLine;
121 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
122 iter != ContactFileLines.end(); ++iter){
124 ExtraLineSeek = TRUE;
130 PropertyLine.Clear();
131 PropertySeg1.Clear();
132 PropertySeg2.Clear();
135 ContactLine = iter->second;
137 while (ExtraLineSeek == TRUE){
139 // Check if there is extra data on the next line
140 // (indicated by space or tab at the start) and add data.
144 if (iter == ContactFileLines.end()){
151 PropertyNextLine = iter->second;
153 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
155 PropertyNextLine.Remove(0, 1);
156 ContactLine.Append(PropertyNextLine);
161 ExtraLineSeek = FALSE;
167 ContactLineLen = ContactLine.Len();
169 // Make sure we are not in quotation mode.
170 // Make sure colon does not have \ or \\ before it.
172 for (int i = 0; i <= ContactLineLen; i++){
174 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
176 PropertyFind = FALSE;
178 } else if (PropertyFind == TRUE){
180 Property.Append(ContactLine.Mid(i, 1));
184 if (ContactLine.Mid(i, 1) == wxT("\"")){
186 if (QuoteMode == TRUE){
198 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
207 // Split that line at the point into two variables (ignore the colon).
209 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
212 if (Property == wxT("KIND") && KindProcessed == FALSE){
214 ProcessKind(PropertySeg2);
216 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
218 UIDToken = PropertySeg2;
221 } else if (Property == wxT("SOURCE")){
223 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
226 } else if (Property == wxT("XML")){
228 ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
231 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
233 ProcessRevision(PropertySeg1, PropertySeg2);
234 RevisionProcessed = TRUE;
236 } else if (Property == wxT("MEMBER")){
238 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
241 } else if (Property == wxT("FN")){
243 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
246 } else if (Property == wxT("N") && NameProcessed == FALSE){
248 ProcessN(PropertySeg1, PropertySeg2);
249 NameProcessed = TRUE;
251 } else if (Property == wxT("CLIENTPIDMAP")){
253 ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
256 } else if (Property == wxT("NICKNAME")){
258 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
261 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
263 ProcessGender(PropertySeg1, PropertySeg2);
264 GenderProcessed = TRUE;
266 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
268 ProcessBirthday(PropertySeg1, PropertySeg2);
269 BirthdayProcessed = TRUE;
271 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
273 ProcessAnniversary(PropertySeg1, PropertySeg2);
274 AnniversaryProcessed = TRUE;
276 } else if (Property == wxT("TZ")){
278 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
281 } else if (Property == wxT("ADR")){
283 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
286 } else if (Property == wxT("EMAIL")){
288 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
291 } else if (Property == wxT("IMPP")){
293 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
296 } else if (Property == wxT("TEL")){
298 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
301 } else if (Property == wxT("LANG")){
303 // See frmContactEditor-LoadLanguage.cpp
305 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
308 } else if (Property == wxT("GEO")){
310 // See frmContactEditor-LoadGeo.cpp
312 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
315 } else if (Property == wxT("RELATED")){
317 // See fromContactEditor-LoadRelated.cpp
319 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
322 } else if (Property == wxT("URL")){
324 // See frmContactEditor-LoadURL.cpp
326 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
329 } else if (Property == wxT("TITLE")) {
331 // See frmContactEditor-LoadTitle.cpp
333 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
336 } else if (Property == wxT("ROLE")) {
338 // See frmContactEditor-LoadTitle.cpp
340 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
343 } else if (Property == wxT("ORG")) {
345 // See frmContactEditor-LoadOrg.cpp
347 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
350 } else if (Property == wxT("NOTE")) {
352 // See frmContactEditor-LoadNote.cpp
354 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
357 } else if (Property == wxT("CATEGORIES")) {
359 // See frmContactEditor-LoadCategory.cpp
361 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
364 } else if (Property == wxT("PHOTO")) {
366 // See frmContactEditor-LoadPhoto.cpp
368 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
371 } else if (Property == wxT("LOGO")) {
373 // See frmContactEditor-LoadPhoto.cpp
375 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
378 } else if (Property == wxT("LOGO")) {
380 // See frmContactEditor-LoadPhoto.cpp
382 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
385 } else if (Property == wxT("SOUND")) {
387 // See frmContactEditor-LoadSound.cpp
389 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
392 } else if (Property == wxT("CALURI")){
394 // See frmContactEditor-LoadCalendar.cpp
396 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
399 } else if (Property == wxT("CALADRURI")){
401 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402 CalendarAddressCount++;
404 } else if (Property == wxT("FBURL")){
406 // See frmContactEditor-LoadCalendar.cpp
408 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409 FreeBusyAddressCount++;
411 } else if (Property == wxT("KEY")){
413 // See frmContactEditor-LoadKey.cpp
415 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
418 } else if (Property.Mid(0, 3) == wxT("VND")){
420 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
423 } else if (Property.Mid(0, 2) == wxT("X-")){
425 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
433 return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439 if (KindType == wxT("individual")){
441 ContactKind = CONTACTKIND_INDIVIDUAL;
443 } else if (KindType == wxT("group")){
445 ContactKind = CONTACTKIND_GROUP;
447 } else if (KindType == wxT("org")){
449 ContactKind = CONTACTKIND_ORGANISATION;
451 } else if (KindType == wxT("location")){
453 ContactKind = CONTACTKIND_LOCATION;
457 ContactKind = CONTACTKIND_NONE;
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464 size_t intPropertyLen = PropertySeg1.Len();
465 std::map<int, int> SplitPoints;
466 std::map<int, int> SplitLength;
467 std::map<int, int>::iterator SLiter;
468 wxString PropertyData;
469 wxString PropertyName;
470 wxString PropertyValue;
471 wxString PropertyTokens;
472 bool FirstToken = TRUE;
473 int intSplitsFound = 0;
474 int intSplitSize = 0;
475 int intPrevValue = 5;
479 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
483 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
484 intiter != SplitPoints.end(); ++intiter){
486 SLiter = SplitLength.find(intiter->first);
488 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
490 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
491 PropertyName = PropertyElement.GetNextToken();
492 PropertyValue = PropertyElement.GetNextToken();
494 intPrevValue = intiter->second;
496 // Process properties.
498 size_t intPropertyValueLen = PropertyValue.Len();
500 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
502 PropertyValue.Trim();
503 PropertyValue.RemoveLast();
507 if (PropertyValue.Mid(0, 1) == wxT("\"")){
509 PropertyValue.Remove(0, 1);
513 CaptureString(&PropertyValue, FALSE);
515 if (FirstToken == TRUE){
517 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
522 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
528 CaptureString(&PropertySeg2, FALSE);
530 Revision = PropertySeg2;
532 if (!PropertyTokens.IsEmpty()){
534 RevisionTokens = PropertyTokens;
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543 size_t intPropertyLen = PropertySeg1.Len();
544 std::map<int, int> SplitPoints;
545 std::map<int, int> SplitLength;
546 std::map<int, int>::iterator SLiter;
547 wxString PropertyData;
548 wxString PropertyName;
549 wxString PropertyValue;
550 wxString PropertyTokens;
551 bool FirstToken = TRUE;
552 int intSplitsFound = 0;
553 int intSplitSize = 0;
554 int intPrevValue = 8;
558 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
562 PropertyType PropType = PROPERTY_NONE;
564 // Look for type before continuing.
566 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
570 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
571 intiter != SplitPoints.end(); ++intiter){
573 SLiter = SplitLength.find(intiter->first);
575 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
577 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
578 PropertyName = PropertyElement.GetNextToken();
579 PropertyValue = PropertyElement.GetNextToken();
581 intPrevValue = intiter->second;
583 // Process properties.
585 size_t intPropertyValueLen = PropertyValue.Len();
587 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
589 PropertyValue.Trim();
590 PropertyValue.RemoveLast();
594 if (PropertyValue.Mid(0, 1) == wxT("\"")){
596 PropertyValue.Remove(0, 1);
600 CaptureString(&PropertyValue, FALSE);
602 if (PropertyName == wxT("ALTID")){
604 SourceListAltID.erase(*SourceCount);
605 SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
607 } else if (PropertyName == wxT("PID")){
609 SourceListPID.erase(*SourceCount);
610 SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
612 } else if (PropertyName == wxT("PREF")){
614 ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount);
616 } else if (PropertyName == wxT("MEDIATYPE")){
618 SourceListMediatype.erase(*SourceCount);
619 SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
623 // Something else we don't know about so append
624 // to the tokens variable.
626 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
628 if (FirstToken == TRUE){
630 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
635 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
645 intPropertyLen = PropertySeg2.Len();
652 CaptureString(&PropertySeg2, FALSE);
654 // Add the data to the General/Home/Work address variables.
660 SourceListType.insert(std::make_pair(*SourceCount, "home"));
663 SourceListType.insert(std::make_pair(*SourceCount, "work"));
667 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
669 if (!PropertyTokens.IsEmpty()){
671 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
677 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
679 std::map<int, int> SplitPoints;
680 std::map<int, int> SplitLength;
682 int intPrevValue = 5;
686 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
690 wxString PropertyName;
691 wxString PropertyValue;
692 wxString PropertyData;
693 wxString PropertyTokens;
694 std::map<int,int>::iterator SLiter;
695 bool FirstToken = TRUE;
697 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
698 intiter != SplitPoints.end(); ++intiter){
700 SLiter = SplitLength.find(intiter->first);
702 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
704 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
705 PropertyName = PropertyElement.GetNextToken();
706 PropertyValue = PropertyElement.GetNextToken();
708 intPrevValue = intiter->second;
710 CaptureString(&PropertyValue, FALSE);
712 if (PropertyName == wxT("ALTID")){
714 XMLListAltID.erase(*XMLCount);
715 XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
721 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
725 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
727 std::map<int, int> SplitPoints;
728 std::map<int, int> SplitLength;
730 int intPrevValue = 8;
734 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
738 wxString PropertyName;
739 wxString PropertyValue;
740 wxString PropertyData;
741 wxString PropertyTokens;
742 std::map<int,int>::iterator SLiter;
743 bool FirstToken = TRUE;
745 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
746 intiter != SplitPoints.end(); ++intiter){
748 SLiter = SplitLength.find(intiter->first);
750 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
752 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
753 PropertyName = PropertyElement.GetNextToken();
754 PropertyValue = PropertyElement.GetNextToken();
756 intPrevValue = intiter->second;
758 CaptureString(&PropertyValue, FALSE);
760 if (PropertyName == wxT("ALTID")){
762 GroupsListAltID.erase(*GroupCount);
763 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
765 } else if (PropertyName == wxT("PID")){
767 GroupsListPID.erase(*GroupCount);
768 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
770 } else if (PropertyName == wxT("PREF")){
772 ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount);
774 } else if (PropertyName == wxT("MEDIATYPE")){
776 GroupsListMediaType.erase(*GroupCount);
777 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
779 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
781 if (FirstToken == TRUE){
783 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
788 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
796 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
798 if (!PropertyTokens.IsEmpty()){
800 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
807 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
809 std::map<int, int> SplitPoints;
810 std::map<int, int> SplitLength;
812 int intPrevValue = 4;
816 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
820 wxString PropertyName;
821 wxString PropertyValue;
822 wxString PropertyData;
823 wxString PropertyTokens;
824 std::map<int,int>::iterator SLiter;
825 bool FirstToken = TRUE;
827 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
828 intiter != SplitPoints.end(); ++intiter){
830 SLiter = SplitLength.find(intiter->first);
832 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
834 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
835 PropertyName = PropertyElement.GetNextToken();
836 PropertyValue = PropertyElement.GetNextToken();
838 intPrevValue = intiter->second;
840 CaptureString(&PropertyValue, FALSE);
842 if (PropertyName == wxT("TYPE")){
844 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
845 PropertyValue == wxT("work") ){
847 FullNamesListType.erase(*FNCount);
848 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
852 } else if (PropertyName == wxT("LANGUAGE")){
854 FullNamesListLanguage.erase(*FNCount);
855 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
857 } else if (PropertyName == wxT("ALTID")){
859 FullNamesListAltID.erase(*FNCount);
860 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
862 } else if (PropertyName == wxT("PID")){
864 FullNamesListPID.erase(*FNCount);
865 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
867 } else if (PropertyName == wxT("PREF")){
869 int PriorityNumber = 0;
870 bool ValidNumber = TRUE;
873 PriorityNumber = std::stoi(PropertyValue.ToStdString());
876 catch(std::invalid_argument &e){
880 if (ValidNumber == TRUE){
882 FullNamesListPref.erase(*FNCount);
883 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
887 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
889 if (FirstToken == TRUE){
891 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
896 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
904 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
906 if (!PropertyTokens.IsEmpty()){
908 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
914 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
916 std::map<int, int> SplitPoints;
917 std::map<int, int> SplitLength;
919 int intPrevValue = 3;
923 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
927 wxString PropertyName;
928 wxString PropertyValue;
929 wxString PropertyData;
930 wxString PropertyTokens;
931 std::map<int,int>::iterator SLiter;
932 bool FirstToken = TRUE;
934 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
935 intiter != SplitPoints.end(); ++intiter){
937 SLiter = SplitLength.find(intiter->first);
939 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
941 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
942 PropertyName = PropertyElement.GetNextToken();
943 PropertyValue = PropertyElement.GetNextToken();
945 intPrevValue = intiter->second;
947 CaptureString(&PropertyValue, FALSE);
949 if (PropertyName == wxT("ALTID")){
951 NameAltID = PropertyValue;
953 } else if (PropertyName == wxT("LANGUAGE")){
955 NameLanguage = PropertyValue;
957 } else if (PropertyName == wxT("SORT-AS")){
959 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
960 PropertyValue.Len() >= 3){
961 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
964 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
966 if (FirstToken == TRUE){
968 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
973 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
981 // Split the name data.
983 int intSplitSeek = 0;
984 int intSplitsFound = 0;
985 int intSplitSize = 0;
986 int intPropertyLen = PropertySeg2.Len();
988 std::map<int,wxString> NameValues;
991 for (int i = 0; i <= intPropertyLen; i++){
993 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
995 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
1000 if (intSplitsFound == 4){
1002 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1016 // Split the data into several parts.
1018 for (std::map<int, wxString>::iterator iter = NameValues.begin();
1019 iter != NameValues.end(); ++iter){
1021 if (iter->first == 1){
1023 // Deal with family name.
1025 NameSurname = iter->second;
1027 } else if (iter->first == 2){
1029 // Deal with given names.
1031 NameForename = iter->second;
1033 } else if (iter->first == 3){
1035 // Deal with additional names.
1037 NameOtherNames = iter->second;
1039 } else if (iter->first == 4){
1041 // Deal with honorifix prefixes and suffixes.
1043 NameTitle = iter->second;
1047 if (iter == NameValues.end()){
1053 NameSuffix = iter->second;
1059 // Add the name token data.
1061 if (!PropertyTokens.IsEmpty()){
1063 NameTokens = PropertyTokens;
1069 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1071 size_t intPropertyLen = PropertySeg1.Len();
1072 std::map<int, int> SplitPoints;
1073 std::map<int, int> SplitLength;
1074 std::map<int, int>::iterator SLiter;
1075 wxString PropertyData;
1076 wxString PropertyName;
1077 wxString PropertyValue;
1078 wxString PropertyTokens;
1079 bool FirstToken = TRUE;
1080 int intSplitsFound = 0;
1081 int intSplitSize = 0;
1082 int intPrevValue = 14;
1086 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1090 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1091 intiter != SplitPoints.end(); ++intiter){
1093 SLiter = SplitLength.find(intiter->first);
1095 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1097 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1098 PropertyName = PropertyElement.GetNextToken();
1099 PropertyValue = PropertyElement.GetNextToken();
1101 intPrevValue = intiter->second;
1103 // Process properties.
1105 size_t intPropertyValueLen = PropertyValue.Len();
1107 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1109 PropertyValue.Trim();
1110 PropertyValue.RemoveLast();
1114 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1116 PropertyValue.Remove(0, 1);
1120 CaptureString(&PropertyValue, FALSE);
1122 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1128 if (FirstToken == TRUE){
1130 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1135 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1141 CaptureString(&PropertySeg2, FALSE);
1143 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1145 if (!PropertyTokens.IsEmpty()){
1147 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1153 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1155 std::map<int, int> SplitPoints;
1156 std::map<int, int> SplitLength;
1158 int intPrevValue = 10;
1161 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1165 PropertyType PropType = PROPERTY_NONE;
1167 // Look for type before continuing.
1169 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1173 std::map<int, wxString> *NicknamesList = NULL;
1174 std::map<int, wxString> *NicknamesListType = NULL;
1175 std::map<int, wxString> *NicknamesListLanguage = NULL;
1176 std::map<int, wxString> *NicknamesListAltID = NULL;
1177 std::map<int, wxString> *NicknamesListPID = NULL;
1178 std::map<int, wxString> *NicknamesListTokens = NULL;
1179 std::map<int, int> *NicknamesListPref = NULL;
1183 NicknamesList = &GeneralNicknamesList;
1184 NicknamesListType = &GeneralNicknamesListType;
1185 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1186 NicknamesListAltID = &GeneralNicknamesListAltID;
1187 NicknamesListPID = &GeneralNicknamesListPID;
1188 NicknamesListTokens = &GeneralNicknamesListTokens;
1189 NicknamesListPref = &GeneralNicknamesListPref;
1192 NicknamesList = &HomeNicknamesList;
1193 NicknamesListType = &HomeNicknamesListType;
1194 NicknamesListLanguage = &HomeNicknamesListLanguage;
1195 NicknamesListAltID = &HomeNicknamesListAltID;
1196 NicknamesListPID = &HomeNicknamesListPID;
1197 NicknamesListTokens = &HomeNicknamesListTokens;
1198 NicknamesListPref = &HomeNicknamesListPref;
1201 NicknamesList = &BusinessNicknamesList;
1202 NicknamesListType = &BusinessNicknamesListType;
1203 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1204 NicknamesListAltID = &BusinessNicknamesListAltID;
1205 NicknamesListPID = &BusinessNicknamesListPID;
1206 NicknamesListTokens = &BusinessNicknamesListTokens;
1207 NicknamesListPref = &BusinessNicknamesListPref;
1211 std::map<int, int>::iterator SLiter;
1212 wxString PropertyData;
1213 wxString PropertyName;
1214 wxString PropertyValue;
1215 wxString PropertyTokens;
1216 bool FirstToken = TRUE;
1218 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1219 intiter != SplitPoints.end(); ++intiter){
1221 SLiter = SplitLength.find(intiter->first);
1223 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1225 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1226 PropertyName = PropertyElement.GetNextToken();
1227 PropertyValue = PropertyElement.GetNextToken();
1229 intPrevValue = intiter->second;
1231 CaptureString(&PropertyValue, FALSE);
1233 if (PropertyName == wxT("ALTID")){
1235 NicknamesListAltID->erase(*NicknameCount);
1236 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1238 } else if (PropertyName == wxT("PID")){
1240 NicknamesListPID->erase(*NicknameCount);
1241 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1243 } else if (PropertyName == wxT("PREF")){
1245 int PriorityNumber = 0;
1246 bool ValidNumber = TRUE;
1249 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1252 catch(std::invalid_argument &e){
1253 ValidNumber = FALSE;
1256 if (ValidNumber == TRUE){
1258 NicknamesListPref->erase(*NicknameCount);
1259 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1263 } else if (PropertyName == wxT("LANGUAGE")){
1265 NicknamesListLanguage->erase(*NicknameCount);
1266 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1270 // Something else we don't know about so append
1271 // to the tokens variable.
1273 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1275 if (FirstToken == TRUE){
1277 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1282 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1292 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1294 // Add the name token data.
1296 if (!PropertyTokens.IsEmpty()){
1298 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1304 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1306 std::map<int, int> SplitPoints;
1307 std::map<int, int> SplitLength;
1308 std::map<int, int>::iterator SLiter;
1309 wxString PropertyData;
1310 wxString PropertyName;
1311 wxString PropertyValue;
1312 wxString PropertyTokens;
1313 bool FirstToken = TRUE;
1314 int intPrevValue = 8;
1316 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1320 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1321 intiter != SplitPoints.end(); ++intiter){
1323 SLiter = SplitLength.find(intiter->first);
1325 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1327 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1328 PropertyName = PropertyElement.GetNextToken();
1329 PropertyValue = PropertyElement.GetNextToken();
1331 intPrevValue = intiter->second;
1333 // Process properties.
1335 size_t intPropertyValueLen = PropertyValue.Len();
1337 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1339 PropertyValue.Trim();
1340 PropertyValue.RemoveLast();
1344 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1346 PropertyValue.Remove(0, 1);
1350 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1352 if (FirstToken == TRUE){
1354 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1359 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1367 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1369 wxString GenderComponent;
1371 if (GenderData.CountTokens() >= 2){
1373 Gender = GenderData.GetNextToken();
1374 GenderDetails = GenderData.GetString();
1376 CaptureString(&GenderDetails, FALSE);
1380 Gender = GenderData.GetNextToken();
1384 if (!PropertyTokens.IsEmpty()){
1386 GenderTokens = PropertyTokens;
1392 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1394 // Process date. Preserve the remainder in the string.
1396 std::map<int, int> SplitPoints;
1397 std::map<int, int> SplitLength;
1398 std::map<int, int>::iterator SLiter;
1399 wxString PropertyData;
1400 wxString PropertyName;
1401 wxString PropertyValue;
1402 wxString PropertyTokens;
1403 bool BirthdayText = FALSE;
1404 int intPrevValue = 6;
1406 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1410 // Look for type before continuing.
1412 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1413 intiter != SplitPoints.end(); ++intiter){
1415 SLiter = SplitLength.find(intiter->first);
1417 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1419 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1420 PropertyName = PropertyElement.GetNextToken();
1421 PropertyValue = PropertyElement.GetNextToken();
1423 intPrevValue = intiter->second;
1425 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1427 CaptureString(&PropertySeg2, FALSE);
1428 Birthday = PropertySeg2;
1429 BirthdayText = TRUE;
1435 // Setup blank lines for later on.
1438 bool FirstToken = TRUE;
1440 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1441 intiter != SplitPoints.end(); ++intiter){
1443 SLiter = SplitLength.find(intiter->first);
1445 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1447 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1448 PropertyName = PropertyElement.GetNextToken();
1449 PropertyValue = PropertyElement.GetNextToken();
1451 intPrevValue = intiter->second;
1453 // Process properties.
1455 CaptureString(&PropertyValue, FALSE);
1457 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1459 PropertyValue.Trim();
1460 PropertyValue.RemoveLast();
1464 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1466 PropertyValue.Remove(0, 1);
1470 if (PropertyName == wxT("ALTID")){
1472 BirthdayAltID = PropertyValue;
1474 } else if (PropertyName == wxT("CALSCALE")){
1476 BirthdayCalScale = PropertyValue;
1478 } else if (PropertyName != wxT("VALUE")) {
1480 // Something else we don't know about so append
1481 // to the tokens variable.
1483 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1485 if (FirstToken == TRUE){
1487 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1492 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1502 // Add the data to the variables and form.
1504 if (BirthdayText == FALSE){
1506 Birthday = PropertySeg2;
1510 if (!PropertyTokens.IsEmpty()){
1512 BirthdayTokens = PropertyTokens;
1518 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1520 // Process date. Preserve the remainder in the string.
1522 std::map<int, int> SplitPoints;
1523 std::map<int, int> SplitLength;
1524 std::map<int, int>::iterator SLiter;
1525 wxString PropertyData;
1526 wxString PropertyName;
1527 wxString PropertyValue;
1528 wxString PropertyTokens;
1529 bool AnniversaryText = FALSE;
1530 int intPrevValue = 13;
1532 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1536 // Look for type before continuing.
1538 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1539 intiter != SplitPoints.end(); ++intiter){
1541 SLiter = SplitLength.find(intiter->first);
1543 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1545 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1546 PropertyName = PropertyElement.GetNextToken();
1547 PropertyValue = PropertyElement.GetNextToken();
1549 intPrevValue = intiter->second;
1551 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1553 CaptureString(&PropertySeg2, FALSE);
1554 Anniversary = PropertySeg2;
1555 AnniversaryText = TRUE;
1561 // Setup blank lines for later on.
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 // Process properties.
1581 CaptureString(&PropertyValue, FALSE);
1583 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1585 PropertyValue.Trim();
1586 PropertyValue.RemoveLast();
1590 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1592 PropertyValue.Remove(0, 1);
1596 if (PropertyName == wxT("ALTID")){
1598 AnniversaryAltID = PropertyValue;
1600 } else if (PropertyName == wxT("CALSCALE")){
1602 AnniversaryCalScale = PropertyValue;
1604 } else if (PropertyName != wxT("VALUE")) {
1606 // Something else we don't know about so append
1607 // to the tokens variable.
1609 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1611 if (FirstToken == TRUE){
1613 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1618 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1628 // Add the data to the variables and form.
1630 if (AnniversaryText == FALSE){
1632 Anniversary = PropertySeg2;
1636 if (!PropertyTokens.IsEmpty()){
1638 AnniversaryTokens = PropertyTokens;
1644 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1646 std::map<int, int> SplitPoints;
1647 std::map<int, int> SplitLength;
1649 int intPrevValue = 4;
1652 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1656 PropertyType PropType = PROPERTY_NONE;
1658 // Look for type before continuing.
1660 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1664 std::map<int, wxString> *TZList = NULL;
1665 std::map<int, wxString> *TZListType = NULL;
1666 std::map<int, wxString> *TZListMediatype = NULL;
1667 std::map<int, wxString> *TZListAltID = NULL;
1668 std::map<int, wxString> *TZListPID = NULL;
1669 std::map<int, wxString> *TZListTokens = NULL;
1670 std::map<int, int> *TZListPref = NULL;
1674 TZList = &GeneralTZList;
1675 TZListType = &GeneralTZListType;
1676 TZListMediatype = &GeneralTZListMediatype;
1677 TZListAltID = &GeneralTZListAltID;
1678 TZListPID = &GeneralTZListPID;
1679 TZListTokens = &GeneralTZListTokens;
1680 TZListPref = &GeneralTZListPref;
1683 TZList = &HomeTZList;
1684 TZListType = &HomeTZListType;
1685 TZListMediatype = &HomeTZListMediatype;
1686 TZListAltID = &HomeTZListAltID;
1687 TZListPID = &HomeTZListPID;
1688 TZListTokens = &HomeTZListTokens;
1689 TZListPref = &HomeTZListPref;
1692 TZList = &BusinessTZList;
1693 TZListType = &BusinessTZListType;
1694 TZListMediatype = &BusinessTZListMediatype;
1695 TZListAltID = &BusinessTZListAltID;
1696 TZListPID = &BusinessTZListPID;
1697 TZListTokens = &BusinessTZListTokens;
1698 TZListPref = &BusinessTZListPref;
1702 std::map<int, int>::iterator SLiter;
1703 wxString PropertyData;
1704 wxString PropertyName;
1705 wxString PropertyValue;
1706 wxString PropertyTokens;
1707 bool FirstToken = TRUE;
1709 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1710 intiter != SplitPoints.end(); ++intiter){
1712 SLiter = SplitLength.find(intiter->first);
1714 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1716 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1717 PropertyName = PropertyElement.GetNextToken();
1718 PropertyValue = PropertyElement.GetNextToken();
1720 intPrevValue = intiter->second;
1722 CaptureString(&PropertyValue, FALSE);
1724 if (PropertyName == wxT("ALTID")){
1726 TZListAltID->erase(*TimeZoneCount);
1727 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1729 } else if (PropertyName == wxT("PID")){
1731 TZListPID->erase(*TimeZoneCount);
1732 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1734 } else if (PropertyName == wxT("PREF")){
1736 int PriorityNumber = 0;
1737 bool ValidNumber = TRUE;
1740 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1743 catch(std::invalid_argument &e){
1744 ValidNumber = FALSE;
1747 if (ValidNumber == TRUE){
1749 TZListPref->erase(*TimeZoneCount);
1750 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1754 } else if (PropertyName == wxT("MEDIATYPE")){
1756 TZListMediatype->erase(*TimeZoneCount);
1757 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1761 // Something else we don't know about so append
1762 // to the tokens variable.
1764 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1766 if (FirstToken == TRUE){
1768 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1773 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1783 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1785 // Add the name token data.
1787 if (!PropertyTokens.IsEmpty()){
1789 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1796 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1798 size_t intPropertyLen = PropertySeg1.Len();
1799 std::map<int, int> SplitPoints;
1800 std::map<int, int> SplitLength;
1801 std::map<int, int>::iterator SLiter;
1802 wxString PropertyData;
1803 wxString PropertyName;
1804 wxString PropertyValue;
1805 wxString PropertyTokens;
1806 wxString AddressLabel;
1807 wxString AddressLang;
1808 wxString AddressAltID;
1809 wxString AddressPID;
1810 wxString AddressTokens;
1811 wxString AddressGeo;
1812 wxString AddressTimezone;
1813 wxString AddressType;
1814 wxString AddressMediatype;
1815 wxString AddressPOBox;
1816 wxString AddressExtended;
1817 wxString AddressStreet;
1818 wxString AddressLocality;
1819 wxString AddressCity;
1820 wxString AddressRegion;
1821 wxString AddressPostalCode;
1822 wxString AddressCountry;
1823 bool FirstToken = TRUE;
1824 int intSplitsFound = 0;
1825 int intSplitSize = 0;
1826 int intPrevValue = 5;
1831 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1835 PropertyType PropType = PROPERTY_NONE;
1837 // Look for type before continuing.
1839 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1843 std::map<int, wxString> *AddressList = NULL;
1844 std::map<int, wxString> *AddressListTown = NULL;
1845 std::map<int, wxString> *AddressListCounty = NULL;
1846 std::map<int, wxString> *AddressListPostCode = NULL;
1847 std::map<int, wxString> *AddressListCountry = NULL;
1848 std::map<int, wxString> *AddressListLabel = NULL;
1849 std::map<int, wxString> *AddressListLang = NULL;
1850 std::map<int, wxString> *AddressListAltID = NULL;
1851 std::map<int, wxString> *AddressListPID = NULL;
1852 std::map<int, wxString> *AddressListTokens = NULL;
1853 std::map<int, wxString> *AddressListGeo = NULL;
1854 std::map<int, wxString> *AddressListTimezone = NULL;
1855 std::map<int, wxString> *AddressListType = NULL;
1856 std::map<int, wxString> *AddressListMediatype = NULL;
1857 std::map<int, int> *AddressListPref = NULL;
1861 AddressList = &GeneralAddressList;
1862 AddressListTown = &GeneralAddressListTown;
1863 AddressListCounty = &GeneralAddressListCounty;
1864 AddressListPostCode = &GeneralAddressListPostCode;
1865 AddressListCountry = &GeneralAddressListCountry;
1866 AddressListLabel = &GeneralAddressListLabel;
1867 AddressListLang = &GeneralAddressListLang;
1868 AddressListAltID = &GeneralAddressListAltID;
1869 AddressListPID = &GeneralAddressListPID;
1870 AddressListTokens = &GeneralAddressListTokens;
1871 AddressListGeo = &GeneralAddressListGeo;
1872 AddressListTimezone = &GeneralAddressListTimezone;
1873 AddressListType = &GeneralAddressListType;
1874 AddressListMediatype = &GeneralAddressListMediatype;
1875 AddressListPref = &GeneralAddressListPref;
1878 AddressList = &HomeAddressList;
1879 AddressListTown = &HomeAddressListTown;
1880 AddressListCounty = &HomeAddressListCounty;
1881 AddressListPostCode = &HomeAddressListPostCode;
1882 AddressListCountry = &HomeAddressListCountry;
1883 AddressListLabel = &HomeAddressListLabel;
1884 AddressListLang = &HomeAddressListLang;
1885 AddressListAltID = &HomeAddressListAltID;
1886 AddressListPID = &HomeAddressListPID;
1887 AddressListTokens = &HomeAddressListTokens;
1888 AddressListGeo = &HomeAddressListGeo;
1889 AddressListTimezone = &HomeAddressListTimezone;
1890 AddressListType = &HomeAddressListType;
1891 AddressListMediatype = &HomeAddressListMediatype;
1892 AddressListPref = &HomeAddressListPref;
1895 AddressList = &BusinessAddressList;
1896 AddressListTown = &BusinessAddressListTown;
1897 AddressListCounty = &BusinessAddressListCounty;
1898 AddressListPostCode = &BusinessAddressListPostCode;
1899 AddressListCountry = &BusinessAddressListCountry;
1900 AddressListLabel = &BusinessAddressListLabel;
1901 AddressListLang = &BusinessAddressListLang;
1902 AddressListAltID = &BusinessAddressListAltID;
1903 AddressListPID = &BusinessAddressListPID;
1904 AddressListTokens = &BusinessAddressListTokens;
1905 AddressListGeo = &BusinessAddressListGeo;
1906 AddressListTimezone = &BusinessAddressListTimezone;
1907 AddressListType = &BusinessAddressListType;
1908 AddressListMediatype = &BusinessAddressListMediatype;
1909 AddressListPref = &BusinessAddressListPref;
1915 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1916 intiter != SplitPoints.end(); ++intiter){
1918 SLiter = SplitLength.find(intiter->first);
1920 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1922 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1923 PropertyName = PropertyElement.GetNextToken();
1924 PropertyValue = PropertyElement.GetNextToken();
1926 intPrevValue = intiter->second;
1928 CaptureString(&PropertyValue, FALSE);
1930 // Process properties.
1932 if (PropertyName == wxT("LABEL")){
1934 AddressListLabel->erase(*AddressCount);
1935 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1937 } else if (PropertyName == wxT("LANGUAGE")){
1939 AddressListLang->erase(*AddressCount);
1940 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1942 } else if (PropertyName == wxT("ALTID")){
1944 AddressListAltID->erase(*AddressCount);
1945 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1947 } else if (PropertyName == wxT("PID")){
1949 AddressListPID->erase(*AddressCount);
1950 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1952 } else if (PropertyName == wxT("GEO")){
1954 AddressListGeo->erase(*AddressCount);
1955 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1957 } else if (PropertyName == wxT("TZ")){
1959 AddressListTimezone->erase(*AddressCount);
1960 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1962 } else if (PropertyName == wxT("MEDIATYPE")){
1964 AddressListMediatype->erase(*AddressCount);
1965 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1967 } else if (PropertyName == wxT("PREF")){
1969 int PriorityNumber = 0;
1970 bool ValidNumber = TRUE;
1973 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1976 catch(std::invalid_argument &e){
1977 ValidNumber = FALSE;
1980 if (ValidNumber == TRUE){
1982 AddressListPref->erase(*AddressCount);
1983 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1989 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1991 if (FirstToken == TRUE){
1993 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1998 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2008 // Split the address.
2010 //std::map<int, int>::iterator SLiter;
2011 intPropertyLen = PropertySeg2.Len();
2012 SplitPoints.clear();
2013 SplitLength.clear();
2018 for (int i = 0; i <= intPropertyLen; i++){
2022 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2025 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2027 if (intSplitsFound == 6){
2029 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2034 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2044 // Split the data into several parts.
2046 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2047 intiter != SplitPoints.end(); ++intiter){
2049 if (intiter->first == 1){
2051 // Deal with PO Box.
2053 SLiter = SplitLength.find(1);
2055 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2056 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2057 intPrevValue = intiter->second;
2059 } else if (intiter->first == 2){
2061 // Deal with extended address.
2063 SLiter = SplitLength.find(2);
2065 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2066 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2067 intPrevValue = intiter->second;
2069 } else if (intiter->first == 3){
2071 // Deal with street address.
2073 SLiter = SplitLength.find(3);
2075 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2076 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2077 intPrevValue = intiter->second;
2079 } else if (intiter->first == 4){
2081 // Deal with locality
2083 SLiter = SplitLength.find(4);
2085 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2086 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2087 intPrevValue = intiter->second;
2089 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2091 } else if (intiter->first == 5){
2093 // Deal with region.
2095 SLiter = SplitLength.find(5);
2097 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2098 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2099 intPrevValue = intiter->second;
2101 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2103 } else if (intiter->first == 6){
2105 // Deal with post code.
2107 SLiter = SplitLength.find(6);
2109 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2110 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2111 intPrevValue = intiter->second;
2113 // Deal with country.
2115 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2116 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2124 // Add the data to the General/Home/Work address variables.
2126 CaptureString(&AddressStreet, FALSE);
2127 CaptureString(&AddressLocality, FALSE);
2128 CaptureString(&AddressRegion, FALSE);
2129 CaptureString(&AddressPostalCode, FALSE);
2130 CaptureString(&AddressCountry, FALSE);
2132 if (!PropertyTokens.IsEmpty()){
2134 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2138 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2139 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2140 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2141 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2142 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2146 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2149 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2152 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2156 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2160 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2162 std::map<int, int> SplitPoints;
2163 std::map<int, int> SplitLength;
2165 int intPrevValue = 7;
2168 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2172 PropertyType PropType = PROPERTY_NONE;
2174 // Look for type before continuing.
2176 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2178 std::map<int, wxString> *EmailList = NULL;
2179 std::map<int, wxString> *EmailListType = NULL;
2180 std::map<int, wxString> *EmailListAltID = NULL;
2181 std::map<int, wxString> *EmailListPID = NULL;
2182 std::map<int, wxString> *EmailListTokens = NULL;
2183 std::map<int, int> *EmailListPref = NULL;
2187 EmailList = &GeneralEmailList;
2188 EmailListType = &GeneralEmailListType;
2189 EmailListAltID = &GeneralEmailListAltID;
2190 EmailListPID = &GeneralEmailListPID;
2191 EmailListTokens = &GeneralEmailListTokens;
2192 EmailListPref = &GeneralEmailListPref;
2195 EmailList = &HomeEmailList;
2196 EmailListType = &HomeEmailListType;
2197 EmailListAltID = &HomeEmailListAltID;
2198 EmailListPID = &HomeEmailListPID;
2199 EmailListTokens = &HomeEmailListTokens;
2200 EmailListPref = &HomeEmailListPref;
2203 EmailList = &BusinessEmailList;
2204 EmailListType = &BusinessEmailListType;
2205 EmailListAltID = &BusinessEmailListAltID;
2206 EmailListPID = &BusinessEmailListPID;
2207 EmailListTokens = &BusinessEmailListTokens;
2208 EmailListPref = &BusinessEmailListPref;
2214 std::map<int,int>::iterator SLiter;
2215 wxString PropertyData;
2216 wxString PropertyName;
2217 wxString PropertyValue;
2218 wxString PropertyTokens;
2219 bool FirstToken = TRUE;
2221 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2222 intiter != SplitPoints.end(); ++intiter){
2224 SLiter = SplitLength.find(intiter->first);
2226 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2228 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2229 PropertyName = PropertyElement.GetNextToken();
2230 PropertyValue = PropertyElement.GetNextToken();
2232 intPrevValue = intiter->second;
2234 CaptureString(&PropertyValue, FALSE);
2236 // Process properties.
2238 if (PropertyName == wxT("ALTID")){
2240 EmailListAltID->erase(*EmailCount);
2241 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2243 } else if (PropertyName == wxT("PID")){
2245 EmailListPID->erase(*EmailCount);
2246 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2248 } else if (PropertyName == wxT("PREF")){
2250 int PriorityNumber = 0;
2251 bool ValidNumber = TRUE;
2254 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2257 catch(std::invalid_argument &e){
2258 ValidNumber = FALSE;
2261 if (ValidNumber == TRUE){
2263 EmailListPref->erase(*EmailCount);
2264 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2270 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2272 if (FirstToken == TRUE){
2274 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2279 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2289 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2291 // Add the name token data.
2293 if (!PropertyTokens.IsEmpty()){
2295 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2302 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2304 std::map<int, int> SplitPoints;
2305 std::map<int, int> SplitLength;
2307 int intPrevValue = 6;
2310 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2314 PropertyType PropType = PROPERTY_NONE;
2316 // Look for type before continuing.
2318 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2320 std::map<int, wxString> *IMList = NULL;
2321 std::map<int, wxString> *IMListType = NULL;
2322 std::map<int, wxString> *IMListAltID = NULL;
2323 std::map<int, wxString> *IMListPID = NULL;
2324 std::map<int, wxString> *IMListTokens = NULL;
2325 std::map<int, wxString> *IMListMediatype = NULL;
2326 std::map<int, int> *IMListPref = NULL;
2330 IMList = &GeneralIMList;
2331 IMListType = &GeneralIMListType;
2332 IMListAltID = &GeneralIMListAltID;
2333 IMListPID = &GeneralIMListPID;
2334 IMListTokens = &GeneralIMListTokens;
2335 IMListMediatype = &GeneralIMListMediatype;
2336 IMListPref = &GeneralIMListPref;
2339 IMList = &HomeIMList;
2340 IMListType = &HomeIMListType;
2341 IMListAltID = &HomeIMListAltID;
2342 IMListPID = &HomeIMListPID;
2343 IMListTokens = &HomeIMListTokens;
2344 IMListMediatype = &HomeIMListMediatype;
2345 IMListPref = &HomeIMListPref;
2348 IMList = &BusinessIMList;
2349 IMListType = &BusinessIMListType;
2350 IMListAltID = &BusinessIMListAltID;
2351 IMListPID = &BusinessIMListPID;
2352 IMListTokens = &BusinessIMListTokens;
2353 IMListMediatype = &BusinessIMListMediatype;
2354 IMListPref = &BusinessIMListPref;
2360 std::map<int,int>::iterator SLiter;
2361 wxString PropertyData;
2362 wxString PropertyName;
2363 wxString PropertyValue;
2364 wxString PropertyTokens;
2365 bool FirstToken = TRUE;
2367 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2368 intiter != SplitPoints.end(); ++intiter){
2370 SLiter = SplitLength.find(intiter->first);
2372 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2374 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2375 PropertyName = PropertyElement.GetNextToken();
2376 PropertyValue = PropertyElement.GetNextToken();
2378 intPrevValue = intiter->second;
2380 CaptureString(&PropertyValue, FALSE);
2382 // Process properties.
2384 if (PropertyName == wxT("ALTID")){
2386 IMListAltID->erase(*IMCount);
2387 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2389 } else if (PropertyName == wxT("PID")){
2391 IMListPID->erase(*IMCount);
2392 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2394 } else if (PropertyName == wxT("MEDIATYPE")){
2396 IMListMediatype->erase(*IMCount);
2397 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2399 } else if (PropertyName == wxT("PREF")){
2401 int PriorityNumber = 0;
2402 bool ValidNumber = TRUE;
2405 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2408 catch(std::invalid_argument &e){
2409 ValidNumber = FALSE;
2412 if (ValidNumber == TRUE){
2414 IMListPref->erase(*IMCount);
2415 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2421 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2423 if (FirstToken == TRUE){
2425 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2430 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2440 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2442 // Add the name token data.
2444 if (!PropertyTokens.IsEmpty()){
2446 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2452 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2454 std::map<int, int> SplitPoints;
2455 std::map<int, int> SplitLength;
2456 std::map<int, int>::iterator SLiter;
2460 PropertyType PropType = PROPERTY_NONE;
2462 // Look for type before continuing.
2465 wxString TelTypeDetail;
2466 wxString PropertyData;
2467 wxString PropertyName;
2468 wxString PropertyValue;
2469 wxString PropertyTokens;
2471 std::map<int,int> TypeSplitPoints;
2472 std::map<int,int> TypeSplitLength;
2473 std::map<int,int>::iterator TSLiter;
2475 int intSplitSize = 0;
2476 int intSplitsFound = 0;
2477 int intSplitPoint = 0;
2479 int intPrevValue = 5;
2481 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2485 // Look for type before continuing.
2487 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2488 intiter != SplitPoints.end(); ++intiter){
2490 SLiter = SplitLength.find(intiter->first);
2492 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2494 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2495 PropertyName = PropertyElement.GetNextToken();
2496 PropertyValue = PropertyElement.GetNextToken();
2498 intPrevValue = intiter->second;
2500 if (PropertyName == wxT("TYPE")){
2502 // Process each value in type and translate each
2505 // Strip out the quotes if they are there.
2507 size_t intPropertyValueLen = PropertyValue.Len();
2509 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2511 PropertyValue.Trim();
2512 PropertyValue.RemoveLast();
2516 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2518 PropertyValue.Remove(0, 1);
2522 TelTypeDetail = PropertyValue;
2528 for (int i = 0; i <= intPropertyValueLen; i++){
2532 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2534 if (intSplitsFound == 0){
2536 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2537 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2541 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2542 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2555 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2556 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2558 int intTypeSeek = 0;
2560 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2561 typeiter != TypeSplitPoints.end(); ++typeiter){
2563 wxString TypePropertyName;
2565 TSLiter = TypeSplitLength.find(typeiter->first);
2567 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2569 if (intTypeSeek == 0){
2574 TelTypeUI.Append(wxT(","));
2578 if (TypePropertyName == wxT("home")){
2580 PropType = PROPERTY_HOME;
2582 } else if (TypePropertyName == wxT("work")){
2584 PropType = PROPERTY_WORK;
2589 if (TypePropertyName == wxT("text")){
2591 TelTypeUI.Append(_("text"));
2594 } else if (TypePropertyName == wxT("voice")){
2596 TelTypeUI.Append(_("voice"));
2599 } else if (TypePropertyName == wxT("fax")){
2601 TelTypeUI.Append(_("fax"));
2604 } else if (TypePropertyName == wxT("cell")){
2606 TelTypeUI.Append(_("mobile"));
2609 } else if (TypePropertyName == wxT("video")){
2611 TelTypeUI.Append(_("video"));
2614 } else if (TypePropertyName == wxT("pager")){
2616 TelTypeUI.Append(_("pager"));
2619 } else if (TypePropertyName == wxT("textphone")){
2621 TelTypeUI.Append(_("textphone"));
2632 std::map<int, wxString> *TelephoneList = NULL;
2633 std::map<int, wxString> *TelephoneListType = NULL;
2634 std::map<int, wxString> *TelephoneListAltID = NULL;
2635 std::map<int, wxString> *TelephoneListPID = NULL;
2636 std::map<int, wxString> *TelephoneListTokens = NULL;
2637 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2638 std::map<int, int> *TelephoneListPref = NULL;
2642 TelephoneList = &GeneralTelephoneList;
2643 TelephoneListType = &GeneralTelephoneListType;
2644 TelephoneListAltID = &GeneralTelephoneListAltID;
2645 TelephoneListPID = &GeneralTelephoneListPID;
2646 TelephoneListTokens = &GeneralTelephoneListTokens;
2647 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2648 TelephoneListPref = &GeneralTelephoneListPref;
2651 TelephoneList = &HomeTelephoneList;
2652 TelephoneListType = &HomeTelephoneListType;
2653 TelephoneListAltID = &HomeTelephoneListAltID;
2654 TelephoneListPID = &HomeTelephoneListPID;
2655 TelephoneListTokens = &HomeTelephoneListTokens;
2656 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2657 TelephoneListPref = &HomeTelephoneListPref;
2660 TelephoneList = &BusinessTelephoneList;
2661 TelephoneListType = &BusinessTelephoneListType;
2662 TelephoneListAltID = &BusinessTelephoneListAltID;
2663 TelephoneListPID = &BusinessTelephoneListPID;
2664 TelephoneListTokens = &BusinessTelephoneListTokens;
2665 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2666 TelephoneListPref = &BusinessTelephoneListPref;
2670 // Process the properties.
2672 bool FirstToken = TRUE;
2675 SplitPoints.clear();
2676 SplitLength.clear();
2678 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2682 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2683 intiter != SplitPoints.end(); ++intiter){
2685 SLiter = SplitLength.find(intiter->first);
2687 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2689 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2690 PropertyName = PropertyElement.GetNextToken();
2691 PropertyValue = PropertyElement.GetNextToken();
2693 intPrevValue = intiter->second;
2695 CaptureString(&PropertyValue, FALSE);
2697 // Process properties.
2699 if (PropertyName == wxT("ALTID")){
2701 TelephoneListAltID->erase(*TelephoneCount);
2702 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2704 } else if (PropertyName == wxT("PID")){
2706 TelephoneListPID->erase(*TelephoneCount);
2707 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2709 } else if (PropertyName == wxT("PREF")){
2711 int PriorityNumber = 0;
2712 bool ValidNumber = TRUE;
2715 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2718 catch(std::invalid_argument &e){
2719 ValidNumber = FALSE;
2722 if (ValidNumber == TRUE){
2724 TelephoneListPref->erase(*TelephoneCount);
2725 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2731 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2733 if (FirstToken == TRUE){
2735 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2740 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2750 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2751 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2753 // Add the name token data.
2755 if (!PropertyTokens.IsEmpty()){
2757 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2763 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2765 std::map<int, int> SplitPoints;
2766 std::map<int, int> SplitLength;
2768 int intPrevValue = 6;
2771 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2775 PropertyType PropType = PROPERTY_NONE;
2777 // Look for type before continuing.
2779 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2781 std::map<int, wxString> *LanguageList = NULL;
2782 std::map<int, wxString> *LanguageListType = NULL;
2783 std::map<int, wxString> *LanguageListAltID = NULL;
2784 std::map<int, wxString> *LanguageListPID = NULL;
2785 std::map<int, wxString> *LanguageListTokens = NULL;
2786 std::map<int, int> *LanguageListPref = NULL;
2790 LanguageList = &GeneralLanguageList;
2791 LanguageListType = &GeneralLanguageListType;
2792 LanguageListAltID = &GeneralLanguageListAltID;
2793 LanguageListPID = &GeneralLanguageListPID;
2794 LanguageListTokens = &GeneralLanguageListTokens;
2795 LanguageListPref = &GeneralLanguageListPref;
2798 LanguageList = &HomeLanguageList;
2799 LanguageListType = &HomeLanguageListType;
2800 LanguageListAltID = &HomeLanguageListAltID;
2801 LanguageListPID = &HomeLanguageListPID;
2802 LanguageListTokens = &HomeLanguageListTokens;
2803 LanguageListPref = &HomeLanguageListPref;
2806 LanguageList = &BusinessLanguageList;
2807 LanguageListType = &BusinessLanguageListType;
2808 LanguageListAltID = &BusinessLanguageListAltID;
2809 LanguageListPID = &BusinessLanguageListPID;
2810 LanguageListTokens = &BusinessLanguageListTokens;
2811 LanguageListPref = &BusinessLanguageListPref;
2817 std::map<int,int>::iterator SLiter;
2818 wxString PropertyData;
2819 wxString PropertyName;
2820 wxString PropertyValue;
2821 wxString PropertyTokens;
2822 bool FirstToken = TRUE;
2824 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2825 intiter != SplitPoints.end(); ++intiter){
2827 SLiter = SplitLength.find(intiter->first);
2829 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2831 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2832 PropertyName = PropertyElement.GetNextToken();
2833 PropertyValue = PropertyElement.GetNextToken();
2835 intPrevValue = intiter->second;
2837 CaptureString(&PropertyValue, FALSE);
2839 // Process properties.
2841 if (PropertyName == wxT("ALTID")){
2843 LanguageListAltID->erase(*LanguageCount);
2844 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2846 } else if (PropertyName == wxT("PID")){
2848 LanguageListPID->erase(*LanguageCount);
2849 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2851 } else if (PropertyName == wxT("PREF")){
2853 int PriorityNumber = 0;
2854 bool ValidNumber = TRUE;
2857 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2860 catch(std::invalid_argument &e){
2861 ValidNumber = FALSE;
2864 if (ValidNumber == TRUE){
2866 LanguageListPref->erase(*LanguageCount);
2867 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2873 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2875 if (FirstToken == TRUE){
2877 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2882 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2892 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2894 // Add the name token data.
2896 if (!PropertyTokens.IsEmpty()){
2898 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2904 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2906 std::map<int, int> SplitPoints;
2907 std::map<int, int> SplitLength;
2909 int intPrevValue = 5;
2912 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2916 PropertyType PropType = PROPERTY_NONE;
2918 // Look for type before continuing.
2920 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2922 std::map<int, wxString> *GeopositionList = NULL;
2923 std::map<int, wxString> *GeopositionListType = NULL;
2924 std::map<int, wxString> *GeopositionListAltID = NULL;
2925 std::map<int, wxString> *GeopositionListPID = NULL;
2926 std::map<int, wxString> *GeopositionListTokens = NULL;
2927 std::map<int, wxString> *GeopositionListMediatype = NULL;
2928 std::map<int, int> *GeopositionListPref = NULL;
2932 GeopositionList = &GeneralGeographyList;
2933 GeopositionListType = &GeneralGeographyListType;
2934 GeopositionListAltID = &GeneralGeographyListAltID;
2935 GeopositionListPID = &GeneralGeographyListPID;
2936 GeopositionListTokens = &GeneralGeographyListTokens;
2937 GeopositionListMediatype = &GeneralGeographyListMediatype;
2938 GeopositionListPref = &GeneralGeographyListPref;
2941 GeopositionList = &HomeGeographyList;
2942 GeopositionListType = &HomeGeographyListType;
2943 GeopositionListAltID = &HomeGeographyListAltID;
2944 GeopositionListPID = &HomeGeographyListPID;
2945 GeopositionListTokens = &HomeGeographyListTokens;
2946 GeopositionListMediatype = &HomeGeographyListMediatype;
2947 GeopositionListPref = &HomeGeographyListPref;
2950 GeopositionList = &BusinessGeographyList;
2951 GeopositionListType = &BusinessGeographyListType;
2952 GeopositionListAltID = &BusinessGeographyListAltID;
2953 GeopositionListPID = &BusinessGeographyListPID;
2954 GeopositionListTokens = &BusinessGeographyListTokens;
2955 GeopositionListMediatype = &BusinessGeographyListMediatype;
2956 GeopositionListPref = &BusinessGeographyListPref;
2962 std::map<int,int>::iterator SLiter;
2963 wxString PropertyData;
2964 wxString PropertyName;
2965 wxString PropertyValue;
2966 wxString PropertyTokens;
2967 bool FirstToken = TRUE;
2969 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2970 intiter != SplitPoints.end(); ++intiter){
2972 SLiter = SplitLength.find(intiter->first);
2974 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2976 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2977 PropertyName = PropertyElement.GetNextToken();
2978 PropertyValue = PropertyElement.GetNextToken();
2980 intPrevValue = intiter->second;
2982 CaptureString(&PropertyValue, FALSE);
2984 // Process properties.
2986 if (PropertyName == wxT("ALTID")){
2988 GeopositionListAltID->erase(*GeographicCount);
2989 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2991 } else if (PropertyName == wxT("PID")){
2993 GeopositionListPID->erase(*GeographicCount);
2994 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2996 } else if (PropertyName == wxT("MEDIATYPE")){
2998 GeopositionListMediatype->erase(*GeographicCount);
2999 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
3001 } else if (PropertyName == wxT("PREF")){
3003 int PriorityNumber = 0;
3004 bool ValidNumber = TRUE;
3007 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3010 catch(std::invalid_argument &e){
3011 ValidNumber = FALSE;
3014 if (ValidNumber == TRUE){
3016 GeopositionListPref->erase(*GeographicCount);
3017 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
3023 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3025 if (FirstToken == TRUE){
3027 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3032 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3042 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3044 // Add the name token data.
3046 if (!PropertyTokens.IsEmpty()){
3048 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3054 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3056 size_t intPropertyLen = PropertySeg1.Len();
3057 std::map<int, int> SplitPoints;
3058 std::map<int, int> SplitLength;
3059 std::map<int, int>::iterator SLiter;
3060 wxString PropertyData;
3061 wxString PropertyName;
3062 wxString PropertyValue;
3063 wxString PropertyTokens;
3064 wxString RelatedType;
3065 wxString RelatedTypeOriginal;
3066 wxString RelatedName;
3067 bool FirstToken = TRUE;
3068 int intSplitsFound = 0;
3069 int intSplitSize = 0;
3070 int intPrevValue = 9;
3074 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3078 // Look for type before continuing.
3080 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3081 intiter != SplitPoints.end(); ++intiter){
3083 SLiter = SplitLength.find(intiter->first);
3085 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3087 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3088 PropertyName = PropertyElement.GetNextToken();
3089 PropertyValue = PropertyElement.GetNextToken();
3091 intPrevValue = intiter->second;
3095 RelatedTypeOriginal = PropertyValue;
3097 if (PropertyName == wxT("TYPE")){
3099 if (PropertyValue == wxT("contact")){
3101 RelatedType = _("Contact");
3103 } else if (PropertyValue == wxT("acquaintance")){
3105 RelatedType = _("Acquaintance");
3107 } else if (PropertyValue == wxT("friend")){
3109 RelatedType = _("Friend");
3111 } else if (PropertyValue == wxT("met")){
3113 RelatedType = _("Met");
3115 } else if (PropertyValue == wxT("co-worker")){
3117 RelatedType = _("Co-worker");
3119 } else if (PropertyValue == wxT("colleague")){
3121 RelatedType = _("Colleague");
3123 } else if (PropertyValue == wxT("co-resident")){
3125 RelatedType = _("Co-resident");
3127 } else if (PropertyValue == wxT("neighbor")){
3129 RelatedType = _("Neighbour");
3131 } else if (PropertyValue == wxT("child")){
3133 RelatedType = _("Child");
3135 } else if (PropertyValue == wxT("parent")){
3137 RelatedType = _("Parent");
3139 } else if (PropertyValue == wxT("sibling")){
3141 RelatedType = _("Sibling");
3143 } else if (PropertyValue == wxT("spouse")){
3145 RelatedType = _("Spouse");
3147 } else if (PropertyValue == wxT("kin")){
3149 RelatedType = _("Kin");
3151 } else if (PropertyValue == wxT("muse")){
3153 RelatedType = _("Muse");
3155 } else if (PropertyValue == wxT("crush")){
3157 RelatedType = _("Crush");
3159 } else if (PropertyValue == wxT("date")){
3161 RelatedType = _("Date");
3163 } else if (PropertyValue == wxT("sweetheart")){
3165 RelatedType = _("Sweetheart");
3167 } else if (PropertyValue == wxT("me")){
3169 RelatedType = _("Me");
3171 } else if (PropertyValue == wxT("agent")){
3173 RelatedType = _("Agent");
3175 } else if (PropertyValue == wxT("emergency")){
3177 RelatedType = _("Emergency");
3181 RelatedType = PropertyValue;
3191 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3192 intiter != SplitPoints.end(); ++intiter){
3194 SLiter = SplitLength.find(intiter->first);
3196 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3198 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3199 PropertyName = PropertyElement.GetNextToken();
3200 PropertyValue = PropertyElement.GetNextToken();
3202 intPrevValue = intiter->second;
3204 // Process properties.
3206 size_t intPropertyValueLen = PropertyValue.Len();
3208 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3210 PropertyValue.Trim();
3211 PropertyValue.RemoveLast();
3215 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3217 PropertyValue.Remove(0, 1);
3221 CaptureString(&PropertyValue, FALSE);
3223 if (PropertyName == wxT("ALTID")){
3225 GeneralRelatedListAltID.erase(*RelatedCount);
3226 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3228 } else if (PropertyName == wxT("PID")){
3230 GeneralRelatedListPID.erase(*RelatedCount);
3231 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3233 } else if (PropertyName == wxT("PREF")){
3235 int PriorityNumber = 0;
3236 bool ValidNumber = TRUE;
3239 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3242 catch(std::invalid_argument &e){
3243 ValidNumber = FALSE;
3246 if (ValidNumber == TRUE){
3248 GeneralRelatedListPref.erase(*RelatedCount);
3249 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3253 } else if (PropertyName == wxT("LANGUAGE")){
3255 GeneralRelatedListLanguage.erase(*RelatedCount);
3256 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3258 } else if (PropertyName != wxT("TYPE")) {
3260 // Something else we don't know about so append
3261 // to the tokens variable.
3263 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3265 if (FirstToken == TRUE){
3267 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3272 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3282 // Add the data to the General/Home/Work address variables.
3284 GeneralRelatedList.erase(*RelatedCount);
3285 GeneralRelatedListRelType.erase(*RelatedCount);
3286 GeneralRelatedListType.erase(*RelatedCount);
3287 GeneralRelatedListTokens.erase(*RelatedCount);
3288 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3289 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3290 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3291 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3295 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3297 std::map<int, int> SplitPoints;
3298 std::map<int, int> SplitLength;
3299 std::map<int, int>::iterator SLiter;
3300 wxString PropertyData;
3301 wxString PropertyName;
3302 wxString PropertyValue;
3303 wxString PropertyTokens;
3304 bool FirstToken = TRUE;
3305 int intPrevValue = 5;
3310 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3314 PropertyType PropType = PROPERTY_NONE;
3316 // Look for type before continuing.
3318 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3320 // Setup the pointers.
3322 std::map<int, wxString> *WebsiteList = NULL;
3323 std::map<int, wxString> *WebsiteListAltID = NULL;
3324 std::map<int, wxString> *WebsiteListPID = NULL;
3325 std::map<int, wxString> *WebsiteListType = NULL;
3326 std::map<int, wxString> *WebsiteListTokens = NULL;
3327 std::map<int, wxString> *WebsiteListMediatype = NULL;
3328 std::map<int, int> *WebsiteListPref = NULL;
3330 // Setup blank lines for later on.
3334 WebsiteList = &GeneralWebsiteList;
3335 WebsiteListType = &GeneralWebsiteListType;
3336 WebsiteListAltID = &GeneralWebsiteListAltID;
3337 WebsiteListPID = &GeneralWebsiteListPID;
3338 WebsiteListTokens = &GeneralWebsiteListTokens;
3339 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3340 WebsiteListPref = &GeneralWebsiteListPref;
3343 WebsiteList = &HomeWebsiteList;
3344 WebsiteListType = &HomeWebsiteListType;
3345 WebsiteListAltID = &HomeWebsiteListAltID;
3346 WebsiteListPID = &HomeWebsiteListPID;
3347 WebsiteListTokens = &HomeWebsiteListTokens;
3348 WebsiteListMediatype = &HomeWebsiteListMediatype;
3349 WebsiteListPref = &HomeWebsiteListPref;
3352 WebsiteList = &BusinessWebsiteList;
3353 WebsiteListType = &BusinessWebsiteListType;
3354 WebsiteListAltID = &BusinessWebsiteListAltID;
3355 WebsiteListPID = &BusinessWebsiteListPID;
3356 WebsiteListTokens = &BusinessWebsiteListTokens;
3357 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3358 WebsiteListPref = &BusinessWebsiteListPref;
3364 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3365 intiter != SplitPoints.end(); ++intiter){
3367 SLiter = SplitLength.find(intiter->first);
3369 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3371 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3372 PropertyName = PropertyElement.GetNextToken();
3373 PropertyValue = PropertyElement.GetNextToken();
3375 intPrevValue = intiter->second;
3377 // Process properties.
3379 size_t intPropertyValueLen = PropertyValue.Len();
3381 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3383 PropertyValue.Trim();
3384 PropertyValue.RemoveLast();
3388 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3390 PropertyValue.Remove(0, 1);
3394 CaptureString(&PropertyValue, FALSE);
3396 if (PropertyName == wxT("ALTID")){
3398 WebsiteListAltID->erase(*URLCount);
3399 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3401 } else if (PropertyName == wxT("PID")){
3403 WebsiteListPID->erase(*URLCount);
3404 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3406 } else if (PropertyName == wxT("PREF")){
3408 int PriorityNumber = 0;
3409 bool ValidNumber = TRUE;
3412 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3415 catch(std::invalid_argument &e){
3416 ValidNumber = FALSE;
3419 if (ValidNumber == TRUE){
3421 WebsiteListPref->erase(*URLCount);
3422 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3426 } else if (PropertyName == wxT("MEDIATYPE")){
3428 WebsiteListMediatype->erase(*URLCount);
3429 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3433 // Something else we don't know about so append
3434 // to the tokens variable.
3436 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3438 if (FirstToken == TRUE){
3440 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3445 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3455 // Add the data to the General/Home/Work address variables.
3457 CaptureString(&PropertySeg2, FALSE);
3459 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3461 if (!PropertyTokens.IsEmpty()){
3463 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3469 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3471 std::map<int, int> SplitPoints;
3472 std::map<int, int> SplitLength;
3473 std::map<int, int>::iterator SLiter;
3474 wxString PropertyData;
3475 wxString PropertyName;
3476 wxString PropertyValue;
3477 wxString PropertyTokens;
3478 bool FirstToken = TRUE;
3479 int intPrevValue = 7;
3484 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3488 PropertyType PropType = PROPERTY_NONE;
3490 // Look for type before continuing.
3492 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3494 // Setup the pointers.
3496 std::map<int, wxString> *TitleList = NULL;
3497 std::map<int, wxString> *TitleListAltID = NULL;
3498 std::map<int, wxString> *TitleListPID = NULL;
3499 std::map<int, wxString> *TitleListType = NULL;
3500 std::map<int, wxString> *TitleListTokens = NULL;
3501 std::map<int, wxString> *TitleListLanguage = NULL;
3502 std::map<int, int> *TitleListPref = NULL;
3504 // Setup blank lines for later on.
3508 TitleList = &GeneralTitleList;
3509 TitleListType = &GeneralTitleListType;
3510 TitleListAltID = &GeneralTitleListAltID;
3511 TitleListPID = &GeneralTitleListPID;
3512 TitleListTokens = &GeneralTitleListTokens;
3513 TitleListLanguage = &GeneralTitleListLanguage;
3514 TitleListPref = &GeneralTitleListPref;
3517 TitleList = &HomeTitleList;
3518 TitleListType = &HomeTitleListType;
3519 TitleListAltID = &HomeTitleListAltID;
3520 TitleListPID = &HomeTitleListPID;
3521 TitleListTokens = &HomeTitleListTokens;
3522 TitleListLanguage = &HomeTitleListLanguage;
3523 TitleListPref = &HomeTitleListPref;
3526 TitleList = &BusinessTitleList;
3527 TitleListType = &BusinessTitleListType;
3528 TitleListAltID = &BusinessTitleListAltID;
3529 TitleListPID = &BusinessTitleListPID;
3530 TitleListTokens = &BusinessTitleListTokens;
3531 TitleListLanguage = &BusinessTitleListLanguage;
3532 TitleListPref = &BusinessTitleListPref;
3538 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3539 intiter != SplitPoints.end(); ++intiter){
3541 SLiter = SplitLength.find(intiter->first);
3543 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3545 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3546 PropertyName = PropertyElement.GetNextToken();
3547 PropertyValue = PropertyElement.GetNextToken();
3549 intPrevValue = intiter->second;
3551 // Process properties.
3553 size_t intPropertyValueLen = PropertyValue.Len();
3555 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3557 PropertyValue.Trim();
3558 PropertyValue.RemoveLast();
3562 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3564 PropertyValue.Remove(0, 1);
3568 CaptureString(&PropertyValue, FALSE);
3570 if (PropertyName == wxT("ALTID")){
3572 TitleListAltID->erase(*TitleCount);
3573 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3575 } else if (PropertyName == wxT("PID")){
3577 TitleListPID->erase(*TitleCount);
3578 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3580 } else if (PropertyName == wxT("PREF")){
3582 int PriorityNumber = 0;
3583 bool ValidNumber = TRUE;
3586 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3589 catch(std::invalid_argument &e){
3590 ValidNumber = FALSE;
3593 if (ValidNumber == TRUE){
3595 TitleListPref->erase(*TitleCount);
3596 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3600 } else if (PropertyName == wxT("LANGUAGE")){
3602 TitleListLanguage->erase(*TitleCount);
3603 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3607 // Something else we don't know about so append
3608 // to the tokens variable.
3610 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3612 if (FirstToken == TRUE){
3614 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3619 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3629 // Add the data to the General/Home/Work address variables.
3631 CaptureString(&PropertySeg2, FALSE);
3633 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3635 if (!PropertyTokens.IsEmpty()){
3637 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3643 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3645 std::map<int, int> SplitPoints;
3646 std::map<int, int> SplitLength;
3647 std::map<int, int>::iterator SLiter;
3648 wxString PropertyData;
3649 wxString PropertyName;
3650 wxString PropertyValue;
3651 wxString PropertyTokens;
3652 bool FirstToken = TRUE;
3653 int intPrevValue = 6;
3658 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3662 PropertyType PropType = PROPERTY_NONE;
3664 // Look for type before continuing.
3666 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3668 // Setup the pointers.
3670 std::map<int, wxString> *RoleList = NULL;
3671 std::map<int, wxString> *RoleListAltID = NULL;
3672 std::map<int, wxString> *RoleListPID = NULL;
3673 std::map<int, wxString> *RoleListType = NULL;
3674 std::map<int, wxString> *RoleListTokens = NULL;
3675 std::map<int, wxString> *RoleListLanguage = NULL;
3676 std::map<int, int> *RoleListPref = NULL;
3678 // Setup blank lines for later on.
3682 RoleList = &GeneralRoleList;
3683 RoleListType = &GeneralRoleListType;
3684 RoleListAltID = &GeneralRoleListAltID;
3685 RoleListPID = &GeneralRoleListPID;
3686 RoleListTokens = &GeneralRoleListTokens;
3687 RoleListLanguage = &GeneralRoleListLanguage;
3688 RoleListPref = &GeneralRoleListPref;
3691 RoleList = &HomeRoleList;
3692 RoleListType = &HomeRoleListType;
3693 RoleListAltID = &HomeRoleListAltID;
3694 RoleListPID = &HomeRoleListPID;
3695 RoleListTokens = &HomeRoleListTokens;
3696 RoleListLanguage = &HomeRoleListLanguage;
3697 RoleListPref = &HomeRoleListPref;
3700 RoleList = &BusinessRoleList;
3701 RoleListType = &BusinessRoleListType;
3702 RoleListAltID = &BusinessRoleListAltID;
3703 RoleListPID = &BusinessRoleListPID;
3704 RoleListTokens = &BusinessRoleListTokens;
3705 RoleListLanguage = &BusinessRoleListLanguage;
3706 RoleListPref = &BusinessRoleListPref;
3712 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3713 intiter != SplitPoints.end(); ++intiter){
3715 SLiter = SplitLength.find(intiter->first);
3717 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3719 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3720 PropertyName = PropertyElement.GetNextToken();
3721 PropertyValue = PropertyElement.GetNextToken();
3723 intPrevValue = intiter->second;
3725 // Process properties.
3727 size_t intPropertyValueLen = PropertyValue.Len();
3729 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3731 PropertyValue.Trim();
3732 PropertyValue.RemoveLast();
3736 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3738 PropertyValue.Remove(0, 1);
3742 CaptureString(&PropertyValue, FALSE);
3744 if (PropertyName == wxT("ALTID")){
3746 RoleListAltID->erase(*RoleCount);
3747 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3749 } else if (PropertyName == wxT("PID")){
3751 RoleListPID->erase(*RoleCount);
3752 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3754 } else if (PropertyName == wxT("PREF")){
3756 int PriorityNumber = 0;
3757 bool ValidNumber = TRUE;
3760 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3763 catch(std::invalid_argument &e){
3764 ValidNumber = FALSE;
3767 if (ValidNumber == TRUE){
3769 RoleListPref->erase(*RoleCount);
3770 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3774 } else if (PropertyName == wxT("LANGUAGE")){
3776 RoleListLanguage->erase(*RoleCount);
3777 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3781 // Something else we don't know about so append
3782 // to the tokens variable.
3784 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3786 if (FirstToken == TRUE){
3788 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3793 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3803 // Add the data to the General/Home/Work address variables.
3805 CaptureString(&PropertySeg2, FALSE);
3807 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3809 if (!PropertyTokens.IsEmpty()){
3811 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3817 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3819 std::map<int, int> SplitPoints;
3820 std::map<int, int> SplitLength;
3821 std::map<int, int>::iterator SLiter;
3822 wxString PropertyData;
3823 wxString PropertyName;
3824 wxString PropertyValue;
3825 wxString PropertyTokens;
3826 bool FirstToken = TRUE;
3827 int intPrevValue = 5;
3832 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3836 PropertyType PropType = PROPERTY_NONE;
3838 // Look for type before continuing.
3840 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3842 // Setup the pointers.
3844 std::map<int, wxString> *OrganisationsList = NULL;
3845 std::map<int, wxString> *OrganisationsListAltID = NULL;
3846 std::map<int, wxString> *OrganisationsListPID = NULL;
3847 std::map<int, wxString> *OrganisationsListType = NULL;
3848 std::map<int, wxString> *OrganisationsListTokens = NULL;
3849 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3850 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3851 std::map<int, int> *OrganisationsListPref = NULL;
3853 // Setup blank lines for later on.
3857 OrganisationsList = &GeneralOrganisationsList;
3858 OrganisationsListType = &GeneralOrganisationsListType;
3859 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3860 OrganisationsListPID = &GeneralOrganisationsListPID;
3861 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3862 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3863 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3864 OrganisationsListPref = &GeneralOrganisationsListPref;
3867 OrganisationsList = &HomeOrganisationsList;
3868 OrganisationsListType = &HomeOrganisationsListType;
3869 OrganisationsListAltID = &HomeOrganisationsListAltID;
3870 OrganisationsListPID = &HomeOrganisationsListPID;
3871 OrganisationsListTokens = &HomeOrganisationsListTokens;
3872 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3873 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3874 OrganisationsListPref = &HomeOrganisationsListPref;
3877 OrganisationsList = &BusinessOrganisationsList;
3878 OrganisationsListType = &BusinessOrganisationsListType;
3879 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3880 OrganisationsListPID = &BusinessOrganisationsListPID;
3881 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3882 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3883 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3884 OrganisationsListPref = &BusinessOrganisationsListPref;
3890 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3891 intiter != SplitPoints.end(); ++intiter){
3893 SLiter = SplitLength.find(intiter->first);
3895 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3897 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3898 PropertyName = PropertyElement.GetNextToken();
3899 PropertyValue = PropertyElement.GetNextToken();
3901 intPrevValue = intiter->second;
3903 // Process properties.
3905 size_t intPropertyValueLen = PropertyValue.Len();
3907 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3909 PropertyValue.Trim();
3910 PropertyValue.RemoveLast();
3914 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3916 PropertyValue.Remove(0, 1);
3920 CaptureString(&PropertyValue, FALSE);
3922 if (PropertyName == wxT("ALTID")){
3924 OrganisationsListAltID->erase(*OrganisationCount);
3925 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3927 } else if (PropertyName == wxT("PID")){
3929 OrganisationsListPID->erase(*OrganisationCount);
3930 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3932 } else if (PropertyName == wxT("SORT-AS")){
3934 OrganisationsListSortAs->erase(*OrganisationCount);
3935 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3937 } else if (PropertyName == wxT("PREF")){
3939 int PriorityNumber = 0;
3940 bool ValidNumber = TRUE;
3943 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3946 catch(std::invalid_argument &e){
3947 ValidNumber = FALSE;
3950 if (ValidNumber == TRUE){
3952 OrganisationsListPref->erase(*OrganisationCount);
3953 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3957 } else if (PropertyName == wxT("LANGUAGE")){
3959 OrganisationsListLanguage->erase(*OrganisationCount);
3960 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3964 // Something else we don't know about so append
3965 // to the tokens variable.
3967 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3969 if (FirstToken == TRUE){
3971 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3976 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3986 // Add the data to the General/Home/Work address variables.
3988 CaptureString(&PropertySeg2, FALSE);
3990 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3992 if (!PropertyTokens.IsEmpty()){
3994 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
4000 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
4002 std::map<int, int> SplitPoints;
4003 std::map<int, int> SplitLength;
4004 std::map<int, int>::iterator SLiter;
4005 wxString PropertyData;
4006 wxString PropertyName;
4007 wxString PropertyValue;
4008 wxString PropertyTokens;
4009 bool FirstToken = TRUE;
4010 int intPrevValue = 6;
4015 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4019 PropertyType PropType = PROPERTY_NONE;
4021 // Look for type before continuing.
4023 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4025 // Setup the pointers.
4027 std::map<int, wxString> *NoteList = NULL;
4028 std::map<int, wxString> *NoteListAltID = NULL;
4029 std::map<int, wxString> *NoteListPID = NULL;
4030 std::map<int, wxString> *NoteListType = NULL;
4031 std::map<int, wxString> *NoteListTokens = NULL;
4032 std::map<int, wxString> *NoteListLanguage = NULL;
4033 std::map<int, int> *NoteListPref = NULL;
4035 // Setup blank lines for later on.
4039 NoteList = &GeneralNoteList;
4040 NoteListType = &GeneralNoteListType;
4041 NoteListAltID = &GeneralNoteListAltID;
4042 NoteListPID = &GeneralNoteListPID;
4043 NoteListTokens = &GeneralNoteListTokens;
4044 NoteListLanguage = &GeneralNoteListLanguage;
4045 NoteListPref = &GeneralNoteListPref;
4048 NoteList = &HomeNoteList;
4049 NoteListType = &HomeNoteListType;
4050 NoteListAltID = &HomeNoteListAltID;
4051 NoteListPID = &HomeNoteListPID;
4052 NoteListTokens = &HomeNoteListTokens;
4053 NoteListLanguage = &HomeNoteListLanguage;
4054 NoteListPref = &HomeNoteListPref;
4057 NoteList = &BusinessNoteList;
4058 NoteListType = &BusinessNoteListType;
4059 NoteListAltID = &BusinessNoteListAltID;
4060 NoteListPID = &BusinessNoteListPID;
4061 NoteListTokens = &BusinessNoteListTokens;
4062 NoteListLanguage = &BusinessNoteListLanguage;
4063 NoteListPref = &BusinessNoteListPref;
4069 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4070 intiter != SplitPoints.end(); ++intiter){
4072 SLiter = SplitLength.find(intiter->first);
4074 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4076 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4077 PropertyName = PropertyElement.GetNextToken();
4078 PropertyValue = PropertyElement.GetNextToken();
4080 intPrevValue = intiter->second;
4082 // Process properties.
4084 size_t intPropertyValueLen = PropertyValue.Len();
4086 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4088 PropertyValue.Trim();
4089 PropertyValue.RemoveLast();
4093 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4095 PropertyValue.Remove(0, 1);
4099 CaptureString(&PropertyValue, FALSE);
4101 if (PropertyName == wxT("ALTID")){
4103 NoteListAltID->erase(*NoteCount);
4104 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4106 } else if (PropertyName == wxT("PID")){
4108 NoteListPID->erase(*NoteCount);
4109 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4111 } else if (PropertyName == wxT("PREF")){
4113 int PriorityNumber = 0;
4114 bool ValidNumber = TRUE;
4117 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4120 catch(std::invalid_argument &e){
4121 ValidNumber = FALSE;
4124 if (ValidNumber == TRUE){
4126 NoteListPref->erase(*NoteCount);
4127 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4131 } else if (PropertyName == wxT("LANGUAGE")){
4133 NoteListLanguage->erase(*NoteCount);
4134 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4138 // Something else we don't know about so append
4139 // to the tokens variable.
4141 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4143 if (FirstToken == TRUE){
4145 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4150 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4160 // Add the data to the General/Home/Work address variables.
4162 CaptureString(&PropertySeg2, FALSE);
4164 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4166 if (!PropertyTokens.IsEmpty()){
4168 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4174 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4176 std::map<int, int> SplitPoints;
4177 std::map<int, int> SplitLength;
4178 std::map<int, int>::iterator SLiter;
4179 wxString PropertyData;
4180 wxString PropertyName;
4181 wxString PropertyValue;
4182 wxString PropertyTokens;
4183 bool FirstToken = TRUE;
4184 int intPrevValue = 12;
4189 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4193 PropertyType PropType = PROPERTY_NONE;
4195 // Look for type before continuing.
4197 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4199 // Setup blank lines for later on.
4205 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4208 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4214 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4215 intiter != SplitPoints.end(); ++intiter){
4217 SLiter = SplitLength.find(intiter->first);
4219 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4221 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4222 PropertyName = PropertyElement.GetNextToken();
4223 PropertyValue = PropertyElement.GetNextToken();
4225 intPrevValue = intiter->second;
4227 // Process properties.
4229 size_t intPropertyValueLen = PropertyValue.Len();
4231 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4233 PropertyValue.Trim();
4234 PropertyValue.RemoveLast();
4238 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4240 PropertyValue.Remove(0, 1);
4244 CaptureString(&PropertyValue, FALSE);
4246 if (PropertyName == wxT("ALTID")){
4248 CategoriesListAltID.erase(*CategoryCount);
4249 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4251 } else if (PropertyName == wxT("PID")){
4253 CategoriesListPID.erase(*CategoryCount);
4254 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4256 } else if (PropertyName == wxT("PREF")){
4258 int PriorityNumber = 0;
4259 bool ValidNumber = TRUE;
4262 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4265 catch(std::invalid_argument &e){
4266 ValidNumber = FALSE;
4269 if (ValidNumber == TRUE){
4271 CategoriesListPref.erase(*CategoryCount);
4272 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4276 } else if (PropertyName == wxT("LANGUAGE")){
4278 CategoriesListLanguage.erase(*CategoryCount);
4279 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4283 // Something else we don't know about so append
4284 // to the tokens variable.
4286 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4288 if (FirstToken == TRUE){
4290 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4295 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4305 // Deal with multiple categories.
4307 int intOrigCatCount = *CategoryCount;
4308 bool FirstCategoryProcessed = TRUE;
4309 bool AfterFirstToken = FALSE;
4310 int intSplitSize = 0;
4311 int intSplitsFound = 0;
4312 int intSplitSeek = 0;
4313 int intPropertyLen = PropertySeg2.Len();
4315 SplitPoints.clear();
4316 SplitLength.clear();
4319 for (int i = 0; i <= intPropertyLen; i++){
4321 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4329 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4331 if (AfterFirstToken == TRUE){
4333 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4334 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4338 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4339 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4340 AfterFirstToken = TRUE;
4352 if (SplitPoints.size() > 0){
4354 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4355 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4359 if (SplitPoints.size() == 0){
4361 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4363 if (!PropertyTokens.IsEmpty()){
4365 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4371 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4372 intiter != SplitPoints.end(); ++intiter){
4374 SLiter = SplitLength.find(intiter->first);
4376 intPrevValue = intiter->second;
4378 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4380 // Add the data to the General/Home/Work address variables.
4382 // Trim any whitespace from the start and end.
4384 PropertyData = PropertyData.Trim(FALSE);
4385 PropertyData = PropertyData.Trim(TRUE);
4387 CaptureString(&PropertyData, FALSE);
4389 if (FirstCategoryProcessed == TRUE){
4391 FirstCategoryProcessed = FALSE;
4393 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4395 if (!PropertyTokens.IsEmpty()){
4397 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4407 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4409 if (!PropertyTokens.IsEmpty()){
4411 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4417 // Copy the properties to each of the categories (if it exists).
4419 if (!PropertyTokens.IsEmpty()){
4421 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4425 // Check if ALTID was used.
4427 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4429 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4433 // Check if PID was used.
4435 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4437 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4441 // Check if PREF was used.
4443 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4445 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4449 // Check if LANGUAGE was used.
4451 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4453 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4457 // Check if TYPE was used.
4463 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4466 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4474 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4476 size_t intPropertyLen = PropertySeg1.Len();
4477 std::map<int, int> SplitPoints;
4478 std::map<int, int> SplitLength;
4479 std::map<int, int>::iterator SLiter;
4480 wxString PropertyData;
4481 wxString PropertyName;
4482 wxString PropertyValue;
4483 wxString PropertyTokens;
4484 bool FirstToken = TRUE;
4485 int intSplitsFound = 0;
4486 int intSplitSize = 0;
4487 int intPrevValue = 7;
4491 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4495 PropertyType PropType = PROPERTY_NONE;
4497 // Look for type before continuing.
4499 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4503 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4504 intiter != SplitPoints.end(); ++intiter){
4506 SLiter = SplitLength.find(intiter->first);
4508 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4510 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4511 PropertyName = PropertyElement.GetNextToken();
4512 PropertyValue = PropertyElement.GetNextToken();
4514 intPrevValue = intiter->second;
4516 // Process properties.
4518 size_t intPropertyValueLen = PropertyValue.Len();
4520 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4522 PropertyValue.Trim();
4523 PropertyValue.RemoveLast();
4527 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4529 PropertyValue.Remove(0, 1);
4533 CaptureString(&PropertyValue, FALSE);
4535 if (PropertyName == wxT("ALTID")){
4537 PicturesListAltID.erase(*PhotoCount);
4538 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4540 } else if (PropertyName == wxT("PID")){
4542 PicturesListPID.erase(*PhotoCount);
4543 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4545 } else if (PropertyName == wxT("PREF")){
4547 int PriorityNumber = 0;
4548 bool ValidNumber = TRUE;
4551 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4554 catch(std::invalid_argument &e){
4555 ValidNumber = FALSE;
4558 if (ValidNumber == TRUE){
4560 PicturesListPref.erase(*PhotoCount);
4561 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4565 } else if (PropertyName == wxT("MEDIATYPE")){
4567 PicturesListMediatype.erase(*PhotoCount);
4568 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4572 // Something else we don't know about so append
4573 // to the tokens variable.
4575 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4577 if (FirstToken == TRUE){
4579 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4584 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4594 intPropertyLen = PropertySeg2.Len();
4595 SplitPoints.clear();
4596 SplitLength.clear();
4601 CaptureString(&PropertySeg2, FALSE);
4603 for (int i = 0; i <= intPropertyLen; i++){
4607 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4610 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4612 if (intSplitsFound == 6){
4614 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4619 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4629 wxString wxSPhotoURI;
4630 wxString wxSPhotoMIME;
4631 wxString wxSPhotoEncoding;
4632 wxString wxSPhotoData;
4633 std::string base64enc;
4635 if (intSplitsFound == 0){
4639 std::map<int, int>::iterator striter;
4641 striter = SplitLength.find(1);
4643 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4645 while (wSTDataType.HasMoreTokens() == TRUE){
4647 wxSPhotoURI = wSTDataType.GetNextToken();
4648 wxSPhotoMIME = wSTDataType.GetNextToken();
4653 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4655 while (wSTDataInfo.HasMoreTokens() == TRUE){
4657 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4658 wxSPhotoData = wSTDataInfo.GetNextToken();
4659 base64enc = wxSPhotoData.mb_str();
4666 // Add the data to the General/Home/Work address variables.
4668 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4669 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4670 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4676 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4679 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4683 if (!PropertyTokens.IsEmpty()){
4685 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4691 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4693 size_t intPropertyLen = PropertySeg1.Len();
4694 std::map<int, int> SplitPoints;
4695 std::map<int, int> SplitLength;
4696 std::map<int, int>::iterator SLiter;
4697 wxString PropertyData;
4698 wxString PropertyName;
4699 wxString PropertyValue;
4700 wxString PropertyTokens;
4701 bool FirstToken = TRUE;
4702 int intSplitsFound = 0;
4703 int intSplitSize = 0;
4704 int intPrevValue = 6;
4708 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4712 PropertyType PropType = PROPERTY_NONE;
4714 // Look for type before continuing.
4716 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4720 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4721 intiter != SplitPoints.end(); ++intiter){
4723 SLiter = SplitLength.find(intiter->first);
4725 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4727 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4728 PropertyName = PropertyElement.GetNextToken();
4729 PropertyValue = PropertyElement.GetNextToken();
4731 intPrevValue = intiter->second;
4733 // Process properties.
4735 size_t intPropertyValueLen = PropertyValue.Len();
4737 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4739 PropertyValue.Trim();
4740 PropertyValue.RemoveLast();
4744 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4746 PropertyValue.Remove(0, 1);
4750 CaptureString(&PropertyValue, FALSE);
4752 if (PropertyName == wxT("ALTID")){
4754 LogosListAltID.erase(*LogoCount);
4755 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4757 } else if (PropertyName == wxT("PID")){
4759 LogosListPID.erase(*LogoCount);
4760 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4762 } else if (PropertyName == wxT("PREF")){
4764 int PriorityNumber = 0;
4765 bool ValidNumber = TRUE;
4768 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4771 catch(std::invalid_argument &e){
4772 ValidNumber = FALSE;
4775 if (ValidNumber == TRUE){
4777 LogosListPref.erase(*LogoCount);
4778 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4782 } else if (PropertyName == wxT("MEDIATYPE")){
4784 LogosListMediatype.erase(*LogoCount);
4785 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4789 // Something else we don't know about so append
4790 // to the tokens variable.
4792 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4794 if (FirstToken == TRUE){
4796 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4801 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4811 intPropertyLen = PropertySeg2.Len();
4812 SplitPoints.clear();
4813 SplitLength.clear();
4818 CaptureString(&PropertySeg2, FALSE);
4820 for (int i = 0; i <= intPropertyLen; i++){
4824 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4827 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4829 if (intSplitsFound == 6){
4831 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4836 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4846 wxString wxSPhotoURI;
4847 wxString wxSPhotoMIME;
4848 wxString wxSPhotoEncoding;
4849 wxString wxSPhotoData;
4850 std::string base64enc;
4852 if (intSplitsFound == 0){
4856 std::map<int, int>::iterator striter;
4858 striter = SplitLength.find(1);
4860 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4862 while (wSTDataType.HasMoreTokens() == TRUE){
4864 wxSPhotoURI = wSTDataType.GetNextToken();
4865 wxSPhotoMIME = wSTDataType.GetNextToken();
4870 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4872 while (wSTDataInfo.HasMoreTokens() == TRUE){
4874 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4875 wxSPhotoData = wSTDataInfo.GetNextToken();
4876 base64enc = wxSPhotoData.mb_str();
4883 // Add the data to the General/Home/Work address variables.
4885 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4886 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4887 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4893 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4896 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4900 if (!PropertyTokens.IsEmpty()){
4902 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4908 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4910 size_t intPropertyLen = PropertySeg1.Len();
4911 std::map<int, int> SplitPoints;
4912 std::map<int, int> SplitLength;
4913 std::map<int, int>::iterator SLiter;
4914 wxString PropertyData;
4915 wxString PropertyName;
4916 wxString PropertyValue;
4917 wxString PropertyTokens;
4918 bool FirstToken = TRUE;
4919 int intSplitsFound = 0;
4920 int intSplitSize = 0;
4921 int intPrevValue = 7;
4925 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4929 PropertyType PropType = PROPERTY_NONE;
4931 // Look for type before continuing.
4933 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4937 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4938 intiter != SplitPoints.end(); ++intiter){
4940 SLiter = SplitLength.find(intiter->first);
4942 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4944 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4945 PropertyName = PropertyElement.GetNextToken();
4946 PropertyValue = PropertyElement.GetNextToken();
4948 intPrevValue = intiter->second;
4950 // Process properties.
4952 size_t intPropertyValueLen = PropertyValue.Len();
4954 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4956 PropertyValue.Trim();
4957 PropertyValue.RemoveLast();
4961 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4963 PropertyValue.Remove(0, 1);
4967 CaptureString(&PropertyValue, FALSE);
4969 if (PropertyName == wxT("ALTID")){
4971 SoundsListAltID.erase(*SoundCount);
4972 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4974 } else if (PropertyName == wxT("PID")){
4976 SoundsListPID.erase(*SoundCount);
4977 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4979 } else if (PropertyName == wxT("PREF")){
4981 int PriorityNumber = 0;
4982 bool ValidNumber = TRUE;
4985 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4988 catch(std::invalid_argument &e){
4989 ValidNumber = FALSE;
4992 if (ValidNumber == TRUE){
4994 SoundsListPref.erase(*SoundCount);
4995 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4999 } else if (PropertyName == wxT("MEDIATYPE")){
5001 SoundsListMediatype.erase(*SoundCount);
5002 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
5004 } else if (PropertyName == wxT("LANGUAGE")){
5006 SoundsListLanguage.erase(*SoundCount);
5007 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
5011 // Something else we don't know about so append
5012 // to the tokens variable.
5014 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5016 if (FirstToken == TRUE){
5018 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5023 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5033 intPropertyLen = PropertySeg2.Len();
5034 SplitPoints.clear();
5035 SplitLength.clear();
5040 CaptureString(&PropertySeg2, FALSE);
5042 for (int i = 0; i <= intPropertyLen; i++){
5046 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5049 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5051 if (intSplitsFound == 6){
5053 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5058 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5068 wxString wxSSoundURI;
5069 wxString wxSSoundMIME;
5070 wxString wxSSoundEncoding;
5071 wxString wxSSoundData;
5072 std::string base64enc;
5074 if (intSplitsFound == 0){
5078 std::map<int, int>::iterator striter;
5080 striter = SplitLength.find(1);
5082 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5084 while (wSTDataType.HasMoreTokens() == TRUE){
5086 wxSSoundURI = wSTDataType.GetNextToken();
5087 wxSSoundMIME = wSTDataType.GetNextToken();
5092 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5094 while (wSTDataInfo.HasMoreTokens() == TRUE){
5096 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5097 wxSSoundData = wSTDataInfo.GetNextToken();
5098 base64enc = wxSSoundData.mb_str();
5105 // Add the data to the General/Home/Work address variables.
5111 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5114 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5118 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5119 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5120 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5122 if (!PropertyTokens.IsEmpty()){
5124 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5130 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5132 size_t intPropertyLen = PropertySeg1.Len();
5133 std::map<int, int> SplitPoints;
5134 std::map<int, int> SplitLength;
5135 std::map<int, int>::iterator SLiter;
5136 wxString PropertyData;
5137 wxString PropertyName;
5138 wxString PropertyValue;
5139 wxString PropertyTokens;
5140 bool FirstToken = TRUE;
5141 int intSplitsFound = 0;
5142 int intSplitSize = 0;
5143 int intPrevValue = 8;
5147 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5151 PropertyType PropType = PROPERTY_NONE;
5153 // Look for type before continuing.
5155 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5159 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5160 intiter != SplitPoints.end(); ++intiter){
5162 SLiter = SplitLength.find(intiter->first);
5164 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5166 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5167 PropertyName = PropertyElement.GetNextToken();
5168 PropertyValue = PropertyElement.GetNextToken();
5170 intPrevValue = intiter->second;
5172 // Process properties.
5174 size_t intPropertyValueLen = PropertyValue.Len();
5176 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5178 PropertyValue.Trim();
5179 PropertyValue.RemoveLast();
5183 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5185 PropertyValue.Remove(0, 1);
5189 CaptureString(&PropertyValue, FALSE);
5191 if (PropertyName == wxT("ALTID")){
5193 CalendarListAltID.erase(*CalURICount);
5194 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5196 } else if (PropertyName == wxT("PID")){
5198 CalendarListPID.erase(*CalURICount);
5199 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5201 } else if (PropertyName == wxT("PREF")){
5203 int PriorityNumber = 0;
5204 bool ValidNumber = TRUE;
5207 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5210 catch(std::invalid_argument &e){
5211 ValidNumber = FALSE;
5214 if (ValidNumber == TRUE){
5216 CalendarListPref.erase(*CalURICount);
5217 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5221 } else if (PropertyName == wxT("MEDIATYPE")){
5223 CalendarListMediatype.erase(*CalURICount);
5224 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5228 // Something else we don't know about so append
5229 // to the tokens variable.
5231 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5233 if (FirstToken == TRUE){
5235 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5240 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5250 intPropertyLen = PropertySeg2.Len();
5251 SplitPoints.clear();
5252 SplitLength.clear();
5257 CaptureString(&PropertySeg2, FALSE);
5259 // Add the data to the General/Home/Work address variables.
5265 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5268 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5272 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5274 if (!PropertyTokens.IsEmpty()){
5276 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5282 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5284 size_t intPropertyLen = PropertySeg1.Len();
5285 std::map<int, int> SplitPoints;
5286 std::map<int, int> SplitLength;
5287 std::map<int, int>::iterator SLiter;
5288 wxString PropertyData;
5289 wxString PropertyName;
5290 wxString PropertyValue;
5291 wxString PropertyTokens;
5292 bool FirstToken = TRUE;
5293 int intSplitsFound = 0;
5294 int intSplitSize = 0;
5295 int intPrevValue = 8;
5299 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5303 PropertyType PropType = PROPERTY_NONE;
5305 // Look for type before continuing.
5307 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5311 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5312 intiter != SplitPoints.end(); ++intiter){
5314 SLiter = SplitLength.find(intiter->first);
5316 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5318 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5319 PropertyName = PropertyElement.GetNextToken();
5320 PropertyValue = PropertyElement.GetNextToken();
5322 intPrevValue = intiter->second;
5324 // Process properties.
5326 size_t intPropertyValueLen = PropertyValue.Len();
5328 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5330 PropertyValue.Trim();
5331 PropertyValue.RemoveLast();
5335 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5337 PropertyValue.Remove(0, 1);
5341 CaptureString(&PropertyValue, FALSE);
5343 if (PropertyName == wxT("ALTID")){
5345 CalendarRequestListAltID.erase(*CalAdrURICount);
5346 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5348 } else if (PropertyName == wxT("PID")){
5350 CalendarRequestListPID.erase(*CalAdrURICount);
5351 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5353 } else if (PropertyName == wxT("PREF")){
5355 int PriorityNumber = 0;
5356 bool ValidNumber = TRUE;
5359 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5362 catch(std::invalid_argument &e){
5363 ValidNumber = FALSE;
5366 if (ValidNumber == TRUE){
5368 CalendarRequestListPref.erase(*CalAdrURICount);
5369 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5373 } else if (PropertyName == wxT("MEDIATYPE")){
5375 CalendarRequestListMediatype.erase(*CalAdrURICount);
5376 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5380 // Something else we don't know about so append
5381 // to the tokens variable.
5383 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5385 if (FirstToken == TRUE){
5387 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5392 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5402 intPropertyLen = PropertySeg2.Len();
5403 SplitPoints.clear();
5404 SplitLength.clear();
5409 CaptureString(&PropertySeg2, FALSE);
5411 // Add the data to the General/Home/Work address variables.
5417 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5420 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5424 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5426 if (!PropertyTokens.IsEmpty()){
5428 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5434 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5436 size_t intPropertyLen = PropertySeg1.Len();
5437 std::map<int, int> SplitPoints;
5438 std::map<int, int> SplitLength;
5439 std::map<int, int>::iterator SLiter;
5440 wxString PropertyData;
5441 wxString PropertyName;
5442 wxString PropertyValue;
5443 wxString PropertyTokens;
5444 bool FirstToken = TRUE;
5445 int intSplitsFound = 0;
5446 int intSplitSize = 0;
5447 int intPrevValue = 7;
5451 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5455 PropertyType PropType = PROPERTY_NONE;
5457 // Look for type before continuing.
5459 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5463 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5464 intiter != SplitPoints.end(); ++intiter){
5466 SLiter = SplitLength.find(intiter->first);
5468 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5470 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5471 PropertyName = PropertyElement.GetNextToken();
5472 PropertyValue = PropertyElement.GetNextToken();
5474 intPrevValue = intiter->second;
5476 // Process properties.
5478 size_t intPropertyValueLen = PropertyValue.Len();
5480 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5482 PropertyValue.Trim();
5483 PropertyValue.RemoveLast();
5487 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5489 PropertyValue.Remove(0, 1);
5493 CaptureString(&PropertyValue, FALSE);
5495 if (PropertyName == wxT("ALTID")){
5497 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5498 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5500 } else if (PropertyName == wxT("PID")){
5502 FreeBusyListPID.erase(*FreeBusyAddressCount);
5503 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5505 } else if (PropertyName == wxT("PREF")){
5507 int PriorityNumber = 0;
5508 bool ValidNumber = TRUE;
5511 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5514 catch(std::invalid_argument &e){
5515 ValidNumber = FALSE;
5518 if (ValidNumber == TRUE){
5520 FreeBusyListPref.erase(*FreeBusyAddressCount);
5521 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5525 } else if (PropertyName == wxT("MEDIATYPE")){
5527 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5528 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5532 // Something else we don't know about so append
5533 // to the tokens variable.
5535 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5537 if (FirstToken == TRUE){
5539 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5544 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5554 intPropertyLen = PropertySeg2.Len();
5555 SplitPoints.clear();
5556 SplitLength.clear();
5561 CaptureString(&PropertySeg2, FALSE);
5563 // Add the data to the General/Home/Work address variables.
5569 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5572 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5576 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5578 if (!PropertyTokens.IsEmpty()){
5580 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5586 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5588 size_t intPropertyLen = PropertySeg1.Len();
5589 std::map<int, int> SplitPoints;
5590 std::map<int, int> SplitLength;
5591 std::map<int, int>::iterator SLiter;
5592 wxString PropertyData;
5593 wxString PropertyName;
5594 wxString PropertyValue;
5595 wxString PropertyTokens;
5596 bool FirstToken = TRUE;
5597 int intSplitsFound = 0;
5598 int intSplitSize = 0;
5599 int intPrevValue = 5;
5604 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5608 PropertyType PropType = PROPERTY_NONE;
5610 // Look for type before continuing.
5612 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5616 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5617 intiter != SplitPoints.end(); ++intiter){
5619 SLiter = SplitLength.find(intiter->first);
5621 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5623 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5624 PropertyName = PropertyElement.GetNextToken();
5625 PropertyValue = PropertyElement.GetNextToken();
5627 intPrevValue = intiter->second;
5629 // Process properties.
5631 size_t intPropertyValueLen = PropertyValue.Len();
5633 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5635 PropertyValue.Trim();
5636 PropertyValue.RemoveLast();
5640 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5642 PropertyValue.Remove(0, 1);
5646 if (PropertyName == wxT("ALTID")){
5648 KeyListAltID.erase(*KeyCount);
5649 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5651 } else if (PropertyName == wxT("PID")){
5653 KeyListPID.erase(*KeyCount);
5654 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5656 } else if (PropertyName == wxT("PREF")){
5658 int PriorityNumber = 0;
5659 bool ValidNumber = TRUE;
5662 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5665 catch(std::invalid_argument &e){
5666 ValidNumber = FALSE;
5669 if (ValidNumber == TRUE){
5671 KeyListPref.erase(*KeyCount);
5672 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5678 // Something else we don't know about so append
5679 // to the tokens variable.
5681 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5683 if (FirstToken == TRUE){
5685 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5690 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5700 intPropertyLen = PropertySeg2.Len();
5701 SplitPoints.clear();
5702 SplitLength.clear();
5707 for (int i = 0; i <= intPropertyLen; i++){
5711 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5714 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5716 if (intSplitsFound == 6){
5718 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5723 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5734 wxString wxSKeyMIME;
5735 wxString wxSKeyEncoding;
5736 wxString wxSKeyData;
5737 std::string base64enc;
5739 if (intSplitsFound == 0){
5743 std::map<int, int>::iterator striter;
5745 striter = SplitLength.find(1);
5747 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5749 while (wSTDataType.HasMoreTokens() == TRUE){
5751 wxSKeyURI = wSTDataType.GetNextToken();
5752 wxSKeyMIME = wSTDataType.GetNextToken();
5757 if (wxSKeyURI == wxT("data")){
5759 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5761 while (wSTDataInfo.HasMoreTokens() == TRUE){
5763 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5764 wxSKeyData = wSTDataInfo.GetNextToken();
5773 // Add the data to the General/Home/Work address variables.
5775 if (wxSKeyURI == wxT("data")){
5777 KeyListDataEncType.erase(*KeyCount);
5778 KeyListKeyType.erase(*KeyCount);
5779 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5780 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5782 KeyList.erase(*KeyCount);
5783 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5787 KeyList.erase(*KeyCount);
5788 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5792 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5798 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5801 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5805 if (!PropertyTokens.IsEmpty()){
5807 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5813 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5815 // Split the Vendor three ways.
5817 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5820 wxString wxSVNDPropName;
5823 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5825 wSTVendorDetails.GetNextToken();
5826 wxSVNDID = wSTVendorDetails.GetNextToken();
5827 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5832 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5834 // Add the data to the vendor variables.
5836 VendorList.erase(*VendorCount);
5837 VendorListPEN.erase(*VendorCount);
5838 VendorListElement.erase(*VendorCount);
5840 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5841 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5842 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5848 void ProcessIntegerValue(ContactDataObject *ContactData,
5849 std::map<int,int> *PrefPtr,
5850 wxString *PropertyValue,
5853 int PriorityNumber = 0;
5854 bool ValidNumber = TRUE;
5857 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5860 catch(std::invalid_argument &e){
5861 ValidNumber = FALSE;
5864 if (ValidNumber == TRUE){
5866 PrefPtr->erase(*ItemCount);
5867 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5873 void SplitValues(wxString *PropertyLine,
5874 std::map<int,int> *SplitPoints,
5875 std::map<int,int> *SplitLength,
5878 size_t intPropertyLen = PropertyLine->Len();
5879 int intSplitsFound = 0;
5880 int intSplitSize = 0;
5881 int intSplitSeek = 0;
5883 for (int i = intSize; i <= intPropertyLen; i++){
5887 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5888 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5890 if (intSplitsFound == 0){
5892 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5896 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5900 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5910 if (intSplitsFound == 0){
5912 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5913 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5917 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5918 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5924 void CheckType(wxString *PropertySeg1,
5925 std::map<int,int> *SplitPoints,
5926 std::map<int,int> *SplitLength,
5928 PropertyType *PropType){
5930 wxString PropertyData;
5931 wxString PropertyName;
5932 wxString PropertyValue;
5933 std::map<int,int>::iterator SLiter;
5935 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5936 intiter != SplitPoints->end(); ++intiter){
5938 SLiter = SplitLength->find(intiter->first);
5940 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5942 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5943 PropertyName = PropertyElement.GetNextToken();
5944 PropertyValue = PropertyElement.GetNextToken();
5946 *intPrevValue = intiter->second;
5948 if (PropertyName == wxT("TYPE")){
5950 if (PropertyValue == wxT("work")){
5952 *PropType = PROPERTY_WORK;
5954 } else if (PropertyValue == wxT("home")){
5956 *PropType = PROPERTY_HOME;
5960 *PropType = PROPERTY_NONE;