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 int PriorityNumber = 0;
773 bool ValidNumber = TRUE;
776 PriorityNumber = std::stoi(PropertyValue.ToStdString());
779 catch(std::invalid_argument &e){
783 if (ValidNumber == TRUE){
785 GroupsListPref.erase(*GroupCount);
786 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
790 } else if (PropertyName == wxT("MEDIATYPE")){
792 GroupsListMediaType.erase(*GroupCount);
793 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
795 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
797 if (FirstToken == TRUE){
799 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
804 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
812 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
814 if (!PropertyTokens.IsEmpty()){
816 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
823 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
825 std::map<int, int> SplitPoints;
826 std::map<int, int> SplitLength;
828 int intPrevValue = 4;
832 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
836 wxString PropertyName;
837 wxString PropertyValue;
838 wxString PropertyData;
839 wxString PropertyTokens;
840 std::map<int,int>::iterator SLiter;
841 bool FirstToken = TRUE;
843 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
844 intiter != SplitPoints.end(); ++intiter){
846 SLiter = SplitLength.find(intiter->first);
848 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
850 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
851 PropertyName = PropertyElement.GetNextToken();
852 PropertyValue = PropertyElement.GetNextToken();
854 intPrevValue = intiter->second;
856 CaptureString(&PropertyValue, FALSE);
858 if (PropertyName == wxT("TYPE")){
860 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
861 PropertyValue == wxT("work") ){
863 FullNamesListType.erase(*FNCount);
864 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
868 } else if (PropertyName == wxT("LANGUAGE")){
870 FullNamesListLanguage.erase(*FNCount);
871 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
873 } else if (PropertyName == wxT("ALTID")){
875 FullNamesListAltID.erase(*FNCount);
876 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
878 } else if (PropertyName == wxT("PID")){
880 FullNamesListPID.erase(*FNCount);
881 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
883 } else if (PropertyName == wxT("PREF")){
885 int PriorityNumber = 0;
886 bool ValidNumber = TRUE;
889 PriorityNumber = std::stoi(PropertyValue.ToStdString());
892 catch(std::invalid_argument &e){
896 if (ValidNumber == TRUE){
898 FullNamesListPref.erase(*FNCount);
899 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
903 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
905 if (FirstToken == TRUE){
907 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
912 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
920 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
922 if (!PropertyTokens.IsEmpty()){
924 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
930 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
932 std::map<int, int> SplitPoints;
933 std::map<int, int> SplitLength;
935 int intPrevValue = 3;
939 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
943 wxString PropertyName;
944 wxString PropertyValue;
945 wxString PropertyData;
946 wxString PropertyTokens;
947 std::map<int,int>::iterator SLiter;
948 bool FirstToken = TRUE;
950 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
951 intiter != SplitPoints.end(); ++intiter){
953 SLiter = SplitLength.find(intiter->first);
955 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
957 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
958 PropertyName = PropertyElement.GetNextToken();
959 PropertyValue = PropertyElement.GetNextToken();
961 intPrevValue = intiter->second;
963 CaptureString(&PropertyValue, FALSE);
965 if (PropertyName == wxT("ALTID")){
967 NameAltID = PropertyValue;
969 } else if (PropertyName == wxT("LANGUAGE")){
971 NameLanguage = PropertyValue;
973 } else if (PropertyName == wxT("SORT-AS")){
975 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
976 PropertyValue.Len() >= 3){
977 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
980 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
982 if (FirstToken == TRUE){
984 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
989 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
997 // Split the name data.
999 int intSplitSeek = 0;
1000 int intSplitsFound = 0;
1001 int intSplitSize = 0;
1002 int intPropertyLen = PropertySeg2.Len();
1004 std::map<int,wxString> NameValues;
1007 for (int i = 0; i <= intPropertyLen; i++){
1009 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1011 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
1016 if (intSplitsFound == 4){
1018 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1032 // Split the data into several parts.
1034 for (std::map<int, wxString>::iterator iter = NameValues.begin();
1035 iter != NameValues.end(); ++iter){
1037 if (iter->first == 1){
1039 // Deal with family name.
1041 NameSurname = iter->second;
1043 } else if (iter->first == 2){
1045 // Deal with given names.
1047 NameForename = iter->second;
1049 } else if (iter->first == 3){
1051 // Deal with additional names.
1053 NameOtherNames = iter->second;
1055 } else if (iter->first == 4){
1057 // Deal with honorifix prefixes and suffixes.
1059 NameTitle = iter->second;
1063 if (iter == NameValues.end()){
1069 NameSuffix = iter->second;
1075 // Add the name token data.
1077 if (!PropertyTokens.IsEmpty()){
1079 NameTokens = PropertyTokens;
1085 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1087 size_t intPropertyLen = PropertySeg1.Len();
1088 std::map<int, int> SplitPoints;
1089 std::map<int, int> SplitLength;
1090 std::map<int, int>::iterator SLiter;
1091 wxString PropertyData;
1092 wxString PropertyName;
1093 wxString PropertyValue;
1094 wxString PropertyTokens;
1095 bool FirstToken = TRUE;
1096 int intSplitsFound = 0;
1097 int intSplitSize = 0;
1098 int intPrevValue = 14;
1102 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1106 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1107 intiter != SplitPoints.end(); ++intiter){
1109 SLiter = SplitLength.find(intiter->first);
1111 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1113 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1114 PropertyName = PropertyElement.GetNextToken();
1115 PropertyValue = PropertyElement.GetNextToken();
1117 intPrevValue = intiter->second;
1119 // Process properties.
1121 size_t intPropertyValueLen = PropertyValue.Len();
1123 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1125 PropertyValue.Trim();
1126 PropertyValue.RemoveLast();
1130 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1132 PropertyValue.Remove(0, 1);
1136 CaptureString(&PropertyValue, FALSE);
1138 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1144 if (FirstToken == TRUE){
1146 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1151 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1157 CaptureString(&PropertySeg2, FALSE);
1159 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1161 if (!PropertyTokens.IsEmpty()){
1163 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1169 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1171 std::map<int, int> SplitPoints;
1172 std::map<int, int> SplitLength;
1174 int intPrevValue = 10;
1177 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1181 PropertyType PropType = PROPERTY_NONE;
1183 // Look for type before continuing.
1185 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1189 std::map<int, wxString> *NicknamesList = NULL;
1190 std::map<int, wxString> *NicknamesListType = NULL;
1191 std::map<int, wxString> *NicknamesListLanguage = NULL;
1192 std::map<int, wxString> *NicknamesListAltID = NULL;
1193 std::map<int, wxString> *NicknamesListPID = NULL;
1194 std::map<int, wxString> *NicknamesListTokens = NULL;
1195 std::map<int, int> *NicknamesListPref = NULL;
1199 NicknamesList = &GeneralNicknamesList;
1200 NicknamesListType = &GeneralNicknamesListType;
1201 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1202 NicknamesListAltID = &GeneralNicknamesListAltID;
1203 NicknamesListPID = &GeneralNicknamesListPID;
1204 NicknamesListTokens = &GeneralNicknamesListTokens;
1205 NicknamesListPref = &GeneralNicknamesListPref;
1208 NicknamesList = &HomeNicknamesList;
1209 NicknamesListType = &HomeNicknamesListType;
1210 NicknamesListLanguage = &HomeNicknamesListLanguage;
1211 NicknamesListAltID = &HomeNicknamesListAltID;
1212 NicknamesListPID = &HomeNicknamesListPID;
1213 NicknamesListTokens = &HomeNicknamesListTokens;
1214 NicknamesListPref = &HomeNicknamesListPref;
1217 NicknamesList = &BusinessNicknamesList;
1218 NicknamesListType = &BusinessNicknamesListType;
1219 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1220 NicknamesListAltID = &BusinessNicknamesListAltID;
1221 NicknamesListPID = &BusinessNicknamesListPID;
1222 NicknamesListTokens = &BusinessNicknamesListTokens;
1223 NicknamesListPref = &BusinessNicknamesListPref;
1227 std::map<int, int>::iterator SLiter;
1228 wxString PropertyData;
1229 wxString PropertyName;
1230 wxString PropertyValue;
1231 wxString PropertyTokens;
1232 bool FirstToken = TRUE;
1234 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1235 intiter != SplitPoints.end(); ++intiter){
1237 SLiter = SplitLength.find(intiter->first);
1239 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1241 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1242 PropertyName = PropertyElement.GetNextToken();
1243 PropertyValue = PropertyElement.GetNextToken();
1245 intPrevValue = intiter->second;
1247 CaptureString(&PropertyValue, FALSE);
1249 if (PropertyName == wxT("ALTID")){
1251 NicknamesListAltID->erase(*NicknameCount);
1252 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1254 } else if (PropertyName == wxT("PID")){
1256 NicknamesListPID->erase(*NicknameCount);
1257 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1259 } else if (PropertyName == wxT("PREF")){
1261 int PriorityNumber = 0;
1262 bool ValidNumber = TRUE;
1265 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1268 catch(std::invalid_argument &e){
1269 ValidNumber = FALSE;
1272 if (ValidNumber == TRUE){
1274 NicknamesListPref->erase(*NicknameCount);
1275 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1279 } else if (PropertyName == wxT("LANGUAGE")){
1281 NicknamesListLanguage->erase(*NicknameCount);
1282 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1286 // Something else we don't know about so append
1287 // to the tokens variable.
1289 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1291 if (FirstToken == TRUE){
1293 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1298 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1308 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1310 // Add the name token data.
1312 if (!PropertyTokens.IsEmpty()){
1314 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1320 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1322 std::map<int, int> SplitPoints;
1323 std::map<int, int> SplitLength;
1324 std::map<int, int>::iterator SLiter;
1325 wxString PropertyData;
1326 wxString PropertyName;
1327 wxString PropertyValue;
1328 wxString PropertyTokens;
1329 bool FirstToken = TRUE;
1330 int intPrevValue = 8;
1332 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1336 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1337 intiter != SplitPoints.end(); ++intiter){
1339 SLiter = SplitLength.find(intiter->first);
1341 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1343 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1344 PropertyName = PropertyElement.GetNextToken();
1345 PropertyValue = PropertyElement.GetNextToken();
1347 intPrevValue = intiter->second;
1349 // Process properties.
1351 size_t intPropertyValueLen = PropertyValue.Len();
1353 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1355 PropertyValue.Trim();
1356 PropertyValue.RemoveLast();
1360 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1362 PropertyValue.Remove(0, 1);
1366 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1368 if (FirstToken == TRUE){
1370 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1375 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1383 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1385 wxString GenderComponent;
1387 if (GenderData.CountTokens() >= 2){
1389 Gender = GenderData.GetNextToken();
1390 GenderDetails = GenderData.GetString();
1392 CaptureString(&GenderDetails, FALSE);
1396 Gender = GenderData.GetNextToken();
1400 if (!PropertyTokens.IsEmpty()){
1402 GenderTokens = PropertyTokens;
1408 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1410 // Process date. Preserve the remainder in the string.
1412 std::map<int, int> SplitPoints;
1413 std::map<int, int> SplitLength;
1414 std::map<int, int>::iterator SLiter;
1415 wxString PropertyData;
1416 wxString PropertyName;
1417 wxString PropertyValue;
1418 wxString PropertyTokens;
1419 bool BirthdayText = FALSE;
1420 int intPrevValue = 6;
1422 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1426 // Look for type before continuing.
1428 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1429 intiter != SplitPoints.end(); ++intiter){
1431 SLiter = SplitLength.find(intiter->first);
1433 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1435 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1436 PropertyName = PropertyElement.GetNextToken();
1437 PropertyValue = PropertyElement.GetNextToken();
1439 intPrevValue = intiter->second;
1441 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1443 CaptureString(&PropertySeg2, FALSE);
1444 Birthday = PropertySeg2;
1445 BirthdayText = TRUE;
1451 // Setup blank lines for later on.
1454 bool FirstToken = TRUE;
1456 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1457 intiter != SplitPoints.end(); ++intiter){
1459 SLiter = SplitLength.find(intiter->first);
1461 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1463 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1464 PropertyName = PropertyElement.GetNextToken();
1465 PropertyValue = PropertyElement.GetNextToken();
1467 intPrevValue = intiter->second;
1469 // Process properties.
1471 CaptureString(&PropertyValue, FALSE);
1473 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1475 PropertyValue.Trim();
1476 PropertyValue.RemoveLast();
1480 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1482 PropertyValue.Remove(0, 1);
1486 if (PropertyName == wxT("ALTID")){
1488 BirthdayAltID = PropertyValue;
1490 } else if (PropertyName == wxT("CALSCALE")){
1492 BirthdayCalScale = PropertyValue;
1494 } else if (PropertyName != wxT("VALUE")) {
1496 // Something else we don't know about so append
1497 // to the tokens variable.
1499 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1501 if (FirstToken == TRUE){
1503 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1508 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1518 // Add the data to the variables and form.
1520 if (BirthdayText == FALSE){
1522 Birthday = PropertySeg2;
1526 if (!PropertyTokens.IsEmpty()){
1528 BirthdayTokens = PropertyTokens;
1534 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1536 // Process date. Preserve the remainder in the string.
1538 std::map<int, int> SplitPoints;
1539 std::map<int, int> SplitLength;
1540 std::map<int, int>::iterator SLiter;
1541 wxString PropertyData;
1542 wxString PropertyName;
1543 wxString PropertyValue;
1544 wxString PropertyTokens;
1545 bool AnniversaryText = FALSE;
1546 int intPrevValue = 13;
1548 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1552 // Look for type before continuing.
1554 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1555 intiter != SplitPoints.end(); ++intiter){
1557 SLiter = SplitLength.find(intiter->first);
1559 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1561 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1562 PropertyName = PropertyElement.GetNextToken();
1563 PropertyValue = PropertyElement.GetNextToken();
1565 intPrevValue = intiter->second;
1567 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1569 CaptureString(&PropertySeg2, FALSE);
1570 Anniversary = PropertySeg2;
1571 AnniversaryText = TRUE;
1577 // Setup blank lines for later on.
1580 bool FirstToken = TRUE;
1582 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1583 intiter != SplitPoints.end(); ++intiter){
1585 SLiter = SplitLength.find(intiter->first);
1587 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1589 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1590 PropertyName = PropertyElement.GetNextToken();
1591 PropertyValue = PropertyElement.GetNextToken();
1593 intPrevValue = intiter->second;
1595 // Process properties.
1597 CaptureString(&PropertyValue, FALSE);
1599 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1601 PropertyValue.Trim();
1602 PropertyValue.RemoveLast();
1606 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1608 PropertyValue.Remove(0, 1);
1612 if (PropertyName == wxT("ALTID")){
1614 AnniversaryAltID = PropertyValue;
1616 } else if (PropertyName == wxT("CALSCALE")){
1618 AnniversaryCalScale = PropertyValue;
1620 } else if (PropertyName != wxT("VALUE")) {
1622 // Something else we don't know about so append
1623 // to the tokens variable.
1625 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1627 if (FirstToken == TRUE){
1629 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1634 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1644 // Add the data to the variables and form.
1646 if (AnniversaryText == FALSE){
1648 Anniversary = PropertySeg2;
1652 if (!PropertyTokens.IsEmpty()){
1654 AnniversaryTokens = PropertyTokens;
1660 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1662 std::map<int, int> SplitPoints;
1663 std::map<int, int> SplitLength;
1665 int intPrevValue = 4;
1668 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1672 PropertyType PropType = PROPERTY_NONE;
1674 // Look for type before continuing.
1676 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1680 std::map<int, wxString> *TZList = NULL;
1681 std::map<int, wxString> *TZListType = NULL;
1682 std::map<int, wxString> *TZListMediatype = NULL;
1683 std::map<int, wxString> *TZListAltID = NULL;
1684 std::map<int, wxString> *TZListPID = NULL;
1685 std::map<int, wxString> *TZListTokens = NULL;
1686 std::map<int, int> *TZListPref = NULL;
1690 TZList = &GeneralTZList;
1691 TZListType = &GeneralTZListType;
1692 TZListMediatype = &GeneralTZListMediatype;
1693 TZListAltID = &GeneralTZListAltID;
1694 TZListPID = &GeneralTZListPID;
1695 TZListTokens = &GeneralTZListTokens;
1696 TZListPref = &GeneralTZListPref;
1699 TZList = &HomeTZList;
1700 TZListType = &HomeTZListType;
1701 TZListMediatype = &HomeTZListMediatype;
1702 TZListAltID = &HomeTZListAltID;
1703 TZListPID = &HomeTZListPID;
1704 TZListTokens = &HomeTZListTokens;
1705 TZListPref = &HomeTZListPref;
1708 TZList = &BusinessTZList;
1709 TZListType = &BusinessTZListType;
1710 TZListMediatype = &BusinessTZListMediatype;
1711 TZListAltID = &BusinessTZListAltID;
1712 TZListPID = &BusinessTZListPID;
1713 TZListTokens = &BusinessTZListTokens;
1714 TZListPref = &BusinessTZListPref;
1718 std::map<int, int>::iterator SLiter;
1719 wxString PropertyData;
1720 wxString PropertyName;
1721 wxString PropertyValue;
1722 wxString PropertyTokens;
1723 bool FirstToken = TRUE;
1725 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1726 intiter != SplitPoints.end(); ++intiter){
1728 SLiter = SplitLength.find(intiter->first);
1730 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1732 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1733 PropertyName = PropertyElement.GetNextToken();
1734 PropertyValue = PropertyElement.GetNextToken();
1736 intPrevValue = intiter->second;
1738 CaptureString(&PropertyValue, FALSE);
1740 if (PropertyName == wxT("ALTID")){
1742 TZListAltID->erase(*TimeZoneCount);
1743 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1745 } else if (PropertyName == wxT("PID")){
1747 TZListPID->erase(*TimeZoneCount);
1748 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1750 } else if (PropertyName == wxT("PREF")){
1752 int PriorityNumber = 0;
1753 bool ValidNumber = TRUE;
1756 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1759 catch(std::invalid_argument &e){
1760 ValidNumber = FALSE;
1763 if (ValidNumber == TRUE){
1765 TZListPref->erase(*TimeZoneCount);
1766 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1770 } else if (PropertyName == wxT("MEDIATYPE")){
1772 TZListMediatype->erase(*TimeZoneCount);
1773 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1777 // Something else we don't know about so append
1778 // to the tokens variable.
1780 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1782 if (FirstToken == TRUE){
1784 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1789 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1799 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1801 // Add the name token data.
1803 if (!PropertyTokens.IsEmpty()){
1805 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1812 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1814 size_t intPropertyLen = PropertySeg1.Len();
1815 std::map<int, int> SplitPoints;
1816 std::map<int, int> SplitLength;
1817 std::map<int, int>::iterator SLiter;
1818 wxString PropertyData;
1819 wxString PropertyName;
1820 wxString PropertyValue;
1821 wxString PropertyTokens;
1822 wxString AddressLabel;
1823 wxString AddressLang;
1824 wxString AddressAltID;
1825 wxString AddressPID;
1826 wxString AddressTokens;
1827 wxString AddressGeo;
1828 wxString AddressTimezone;
1829 wxString AddressType;
1830 wxString AddressMediatype;
1831 wxString AddressPOBox;
1832 wxString AddressExtended;
1833 wxString AddressStreet;
1834 wxString AddressLocality;
1835 wxString AddressCity;
1836 wxString AddressRegion;
1837 wxString AddressPostalCode;
1838 wxString AddressCountry;
1839 bool FirstToken = TRUE;
1840 int intSplitsFound = 0;
1841 int intSplitSize = 0;
1842 int intPrevValue = 5;
1847 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1851 PropertyType PropType = PROPERTY_NONE;
1853 // Look for type before continuing.
1855 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1859 std::map<int, wxString> *AddressList = NULL;
1860 std::map<int, wxString> *AddressListTown = NULL;
1861 std::map<int, wxString> *AddressListCounty = NULL;
1862 std::map<int, wxString> *AddressListPostCode = NULL;
1863 std::map<int, wxString> *AddressListCountry = NULL;
1864 std::map<int, wxString> *AddressListLabel = NULL;
1865 std::map<int, wxString> *AddressListLang = NULL;
1866 std::map<int, wxString> *AddressListAltID = NULL;
1867 std::map<int, wxString> *AddressListPID = NULL;
1868 std::map<int, wxString> *AddressListTokens = NULL;
1869 std::map<int, wxString> *AddressListGeo = NULL;
1870 std::map<int, wxString> *AddressListTimezone = NULL;
1871 std::map<int, wxString> *AddressListType = NULL;
1872 std::map<int, wxString> *AddressListMediatype = NULL;
1873 std::map<int, int> *AddressListPref = NULL;
1877 AddressList = &GeneralAddressList;
1878 AddressListTown = &GeneralAddressListTown;
1879 AddressListCounty = &GeneralAddressListCounty;
1880 AddressListPostCode = &GeneralAddressListPostCode;
1881 AddressListCountry = &GeneralAddressListCountry;
1882 AddressListLabel = &GeneralAddressListLabel;
1883 AddressListLang = &GeneralAddressListLang;
1884 AddressListAltID = &GeneralAddressListAltID;
1885 AddressListPID = &GeneralAddressListPID;
1886 AddressListTokens = &GeneralAddressListTokens;
1887 AddressListGeo = &GeneralAddressListGeo;
1888 AddressListTimezone = &GeneralAddressListTimezone;
1889 AddressListType = &GeneralAddressListType;
1890 AddressListMediatype = &GeneralAddressListMediatype;
1891 AddressListPref = &GeneralAddressListPref;
1894 AddressList = &HomeAddressList;
1895 AddressListTown = &HomeAddressListTown;
1896 AddressListCounty = &HomeAddressListCounty;
1897 AddressListPostCode = &HomeAddressListPostCode;
1898 AddressListCountry = &HomeAddressListCountry;
1899 AddressListLabel = &HomeAddressListLabel;
1900 AddressListLang = &HomeAddressListLang;
1901 AddressListAltID = &HomeAddressListAltID;
1902 AddressListPID = &HomeAddressListPID;
1903 AddressListTokens = &HomeAddressListTokens;
1904 AddressListGeo = &HomeAddressListGeo;
1905 AddressListTimezone = &HomeAddressListTimezone;
1906 AddressListType = &HomeAddressListType;
1907 AddressListMediatype = &HomeAddressListMediatype;
1908 AddressListPref = &HomeAddressListPref;
1911 AddressList = &BusinessAddressList;
1912 AddressListTown = &BusinessAddressListTown;
1913 AddressListCounty = &BusinessAddressListCounty;
1914 AddressListPostCode = &BusinessAddressListPostCode;
1915 AddressListCountry = &BusinessAddressListCountry;
1916 AddressListLabel = &BusinessAddressListLabel;
1917 AddressListLang = &BusinessAddressListLang;
1918 AddressListAltID = &BusinessAddressListAltID;
1919 AddressListPID = &BusinessAddressListPID;
1920 AddressListTokens = &BusinessAddressListTokens;
1921 AddressListGeo = &BusinessAddressListGeo;
1922 AddressListTimezone = &BusinessAddressListTimezone;
1923 AddressListType = &BusinessAddressListType;
1924 AddressListMediatype = &BusinessAddressListMediatype;
1925 AddressListPref = &BusinessAddressListPref;
1931 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1932 intiter != SplitPoints.end(); ++intiter){
1934 SLiter = SplitLength.find(intiter->first);
1936 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1938 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1939 PropertyName = PropertyElement.GetNextToken();
1940 PropertyValue = PropertyElement.GetNextToken();
1942 intPrevValue = intiter->second;
1944 CaptureString(&PropertyValue, FALSE);
1946 // Process properties.
1948 if (PropertyName == wxT("LABEL")){
1950 AddressListLabel->erase(*AddressCount);
1951 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1953 } else if (PropertyName == wxT("LANGUAGE")){
1955 AddressListLang->erase(*AddressCount);
1956 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1958 } else if (PropertyName == wxT("ALTID")){
1960 AddressListAltID->erase(*AddressCount);
1961 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1963 } else if (PropertyName == wxT("PID")){
1965 AddressListPID->erase(*AddressCount);
1966 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1968 } else if (PropertyName == wxT("GEO")){
1970 AddressListGeo->erase(*AddressCount);
1971 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1973 } else if (PropertyName == wxT("TZ")){
1975 AddressListTimezone->erase(*AddressCount);
1976 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1978 } else if (PropertyName == wxT("MEDIATYPE")){
1980 AddressListMediatype->erase(*AddressCount);
1981 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1983 } else if (PropertyName == wxT("PREF")){
1985 int PriorityNumber = 0;
1986 bool ValidNumber = TRUE;
1989 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1992 catch(std::invalid_argument &e){
1993 ValidNumber = FALSE;
1996 if (ValidNumber == TRUE){
1998 AddressListPref->erase(*AddressCount);
1999 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
2005 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2007 if (FirstToken == TRUE){
2009 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2014 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2024 // Split the address.
2026 //std::map<int, int>::iterator SLiter;
2027 intPropertyLen = PropertySeg2.Len();
2028 SplitPoints.clear();
2029 SplitLength.clear();
2034 for (int i = 0; i <= intPropertyLen; i++){
2038 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2041 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2043 if (intSplitsFound == 6){
2045 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2050 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2060 // Split the data into several parts.
2062 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2063 intiter != SplitPoints.end(); ++intiter){
2065 if (intiter->first == 1){
2067 // Deal with PO Box.
2069 SLiter = SplitLength.find(1);
2071 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2072 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2073 intPrevValue = intiter->second;
2075 } else if (intiter->first == 2){
2077 // Deal with extended address.
2079 SLiter = SplitLength.find(2);
2081 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2082 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2083 intPrevValue = intiter->second;
2085 } else if (intiter->first == 3){
2087 // Deal with street address.
2089 SLiter = SplitLength.find(3);
2091 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2092 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2093 intPrevValue = intiter->second;
2095 } else if (intiter->first == 4){
2097 // Deal with locality
2099 SLiter = SplitLength.find(4);
2101 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2102 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2103 intPrevValue = intiter->second;
2105 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2107 } else if (intiter->first == 5){
2109 // Deal with region.
2111 SLiter = SplitLength.find(5);
2113 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2114 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2115 intPrevValue = intiter->second;
2117 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2119 } else if (intiter->first == 6){
2121 // Deal with post code.
2123 SLiter = SplitLength.find(6);
2125 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2126 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2127 intPrevValue = intiter->second;
2129 // Deal with country.
2131 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2132 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2140 // Add the data to the General/Home/Work address variables.
2142 CaptureString(&AddressStreet, FALSE);
2143 CaptureString(&AddressLocality, FALSE);
2144 CaptureString(&AddressRegion, FALSE);
2145 CaptureString(&AddressPostalCode, FALSE);
2146 CaptureString(&AddressCountry, FALSE);
2148 if (!PropertyTokens.IsEmpty()){
2150 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2154 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2155 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2156 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2157 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2158 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2162 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2165 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2168 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2172 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2176 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2178 std::map<int, int> SplitPoints;
2179 std::map<int, int> SplitLength;
2181 int intPrevValue = 7;
2184 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2188 PropertyType PropType = PROPERTY_NONE;
2190 // Look for type before continuing.
2192 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2194 std::map<int, wxString> *EmailList = NULL;
2195 std::map<int, wxString> *EmailListType = NULL;
2196 std::map<int, wxString> *EmailListAltID = NULL;
2197 std::map<int, wxString> *EmailListPID = NULL;
2198 std::map<int, wxString> *EmailListTokens = NULL;
2199 std::map<int, int> *EmailListPref = NULL;
2203 EmailList = &GeneralEmailList;
2204 EmailListType = &GeneralEmailListType;
2205 EmailListAltID = &GeneralEmailListAltID;
2206 EmailListPID = &GeneralEmailListPID;
2207 EmailListTokens = &GeneralEmailListTokens;
2208 EmailListPref = &GeneralEmailListPref;
2211 EmailList = &HomeEmailList;
2212 EmailListType = &HomeEmailListType;
2213 EmailListAltID = &HomeEmailListAltID;
2214 EmailListPID = &HomeEmailListPID;
2215 EmailListTokens = &HomeEmailListTokens;
2216 EmailListPref = &HomeEmailListPref;
2219 EmailList = &BusinessEmailList;
2220 EmailListType = &BusinessEmailListType;
2221 EmailListAltID = &BusinessEmailListAltID;
2222 EmailListPID = &BusinessEmailListPID;
2223 EmailListTokens = &BusinessEmailListTokens;
2224 EmailListPref = &BusinessEmailListPref;
2230 std::map<int,int>::iterator SLiter;
2231 wxString PropertyData;
2232 wxString PropertyName;
2233 wxString PropertyValue;
2234 wxString PropertyTokens;
2235 bool FirstToken = TRUE;
2237 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2238 intiter != SplitPoints.end(); ++intiter){
2240 SLiter = SplitLength.find(intiter->first);
2242 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2244 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2245 PropertyName = PropertyElement.GetNextToken();
2246 PropertyValue = PropertyElement.GetNextToken();
2248 intPrevValue = intiter->second;
2250 CaptureString(&PropertyValue, FALSE);
2252 // Process properties.
2254 if (PropertyName == wxT("ALTID")){
2256 EmailListAltID->erase(*EmailCount);
2257 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2259 } else if (PropertyName == wxT("PID")){
2261 EmailListPID->erase(*EmailCount);
2262 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2264 } else if (PropertyName == wxT("PREF")){
2266 int PriorityNumber = 0;
2267 bool ValidNumber = TRUE;
2270 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2273 catch(std::invalid_argument &e){
2274 ValidNumber = FALSE;
2277 if (ValidNumber == TRUE){
2279 EmailListPref->erase(*EmailCount);
2280 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2286 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2288 if (FirstToken == TRUE){
2290 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2295 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2305 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2307 // Add the name token data.
2309 if (!PropertyTokens.IsEmpty()){
2311 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2318 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2320 std::map<int, int> SplitPoints;
2321 std::map<int, int> SplitLength;
2323 int intPrevValue = 6;
2326 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2330 PropertyType PropType = PROPERTY_NONE;
2332 // Look for type before continuing.
2334 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2336 std::map<int, wxString> *IMList = NULL;
2337 std::map<int, wxString> *IMListType = NULL;
2338 std::map<int, wxString> *IMListAltID = NULL;
2339 std::map<int, wxString> *IMListPID = NULL;
2340 std::map<int, wxString> *IMListTokens = NULL;
2341 std::map<int, wxString> *IMListMediatype = NULL;
2342 std::map<int, int> *IMListPref = NULL;
2346 IMList = &GeneralIMList;
2347 IMListType = &GeneralIMListType;
2348 IMListAltID = &GeneralIMListAltID;
2349 IMListPID = &GeneralIMListPID;
2350 IMListTokens = &GeneralIMListTokens;
2351 IMListMediatype = &GeneralIMListMediatype;
2352 IMListPref = &GeneralIMListPref;
2355 IMList = &HomeIMList;
2356 IMListType = &HomeIMListType;
2357 IMListAltID = &HomeIMListAltID;
2358 IMListPID = &HomeIMListPID;
2359 IMListTokens = &HomeIMListTokens;
2360 IMListMediatype = &HomeIMListMediatype;
2361 IMListPref = &HomeIMListPref;
2364 IMList = &BusinessIMList;
2365 IMListType = &BusinessIMListType;
2366 IMListAltID = &BusinessIMListAltID;
2367 IMListPID = &BusinessIMListPID;
2368 IMListTokens = &BusinessIMListTokens;
2369 IMListMediatype = &BusinessIMListMediatype;
2370 IMListPref = &BusinessIMListPref;
2376 std::map<int,int>::iterator SLiter;
2377 wxString PropertyData;
2378 wxString PropertyName;
2379 wxString PropertyValue;
2380 wxString PropertyTokens;
2381 bool FirstToken = TRUE;
2383 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2384 intiter != SplitPoints.end(); ++intiter){
2386 SLiter = SplitLength.find(intiter->first);
2388 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2390 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2391 PropertyName = PropertyElement.GetNextToken();
2392 PropertyValue = PropertyElement.GetNextToken();
2394 intPrevValue = intiter->second;
2396 CaptureString(&PropertyValue, FALSE);
2398 // Process properties.
2400 if (PropertyName == wxT("ALTID")){
2402 IMListAltID->erase(*IMCount);
2403 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2405 } else if (PropertyName == wxT("PID")){
2407 IMListPID->erase(*IMCount);
2408 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2410 } else if (PropertyName == wxT("MEDIATYPE")){
2412 IMListMediatype->erase(*IMCount);
2413 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2415 } else if (PropertyName == wxT("PREF")){
2417 int PriorityNumber = 0;
2418 bool ValidNumber = TRUE;
2421 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2424 catch(std::invalid_argument &e){
2425 ValidNumber = FALSE;
2428 if (ValidNumber == TRUE){
2430 IMListPref->erase(*IMCount);
2431 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2437 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2439 if (FirstToken == TRUE){
2441 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2446 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2456 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2458 // Add the name token data.
2460 if (!PropertyTokens.IsEmpty()){
2462 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2468 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2470 std::map<int, int> SplitPoints;
2471 std::map<int, int> SplitLength;
2472 std::map<int, int>::iterator SLiter;
2476 PropertyType PropType = PROPERTY_NONE;
2478 // Look for type before continuing.
2481 wxString TelTypeDetail;
2482 wxString PropertyData;
2483 wxString PropertyName;
2484 wxString PropertyValue;
2485 wxString PropertyTokens;
2487 std::map<int,int> TypeSplitPoints;
2488 std::map<int,int> TypeSplitLength;
2489 std::map<int,int>::iterator TSLiter;
2491 int intSplitSize = 0;
2492 int intSplitsFound = 0;
2493 int intSplitPoint = 0;
2495 int intPrevValue = 5;
2497 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2501 // Look for type before continuing.
2503 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2504 intiter != SplitPoints.end(); ++intiter){
2506 SLiter = SplitLength.find(intiter->first);
2508 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2510 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2511 PropertyName = PropertyElement.GetNextToken();
2512 PropertyValue = PropertyElement.GetNextToken();
2514 intPrevValue = intiter->second;
2516 if (PropertyName == wxT("TYPE")){
2518 // Process each value in type and translate each
2521 // Strip out the quotes if they are there.
2523 size_t intPropertyValueLen = PropertyValue.Len();
2525 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2527 PropertyValue.Trim();
2528 PropertyValue.RemoveLast();
2532 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2534 PropertyValue.Remove(0, 1);
2538 TelTypeDetail = PropertyValue;
2544 for (int i = 0; i <= intPropertyValueLen; i++){
2548 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2550 if (intSplitsFound == 0){
2552 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2553 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2557 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2558 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2571 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2572 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2574 int intTypeSeek = 0;
2576 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2577 typeiter != TypeSplitPoints.end(); ++typeiter){
2579 wxString TypePropertyName;
2581 TSLiter = TypeSplitLength.find(typeiter->first);
2583 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2585 if (intTypeSeek == 0){
2590 TelTypeUI.Append(wxT(","));
2594 if (TypePropertyName == wxT("home")){
2596 PropType = PROPERTY_HOME;
2598 } else if (TypePropertyName == wxT("work")){
2600 PropType = PROPERTY_WORK;
2605 if (TypePropertyName == wxT("text")){
2607 TelTypeUI.Append(_("text"));
2610 } else if (TypePropertyName == wxT("voice")){
2612 TelTypeUI.Append(_("voice"));
2615 } else if (TypePropertyName == wxT("fax")){
2617 TelTypeUI.Append(_("fax"));
2620 } else if (TypePropertyName == wxT("cell")){
2622 TelTypeUI.Append(_("mobile"));
2625 } else if (TypePropertyName == wxT("video")){
2627 TelTypeUI.Append(_("video"));
2630 } else if (TypePropertyName == wxT("pager")){
2632 TelTypeUI.Append(_("pager"));
2635 } else if (TypePropertyName == wxT("textphone")){
2637 TelTypeUI.Append(_("textphone"));
2648 std::map<int, wxString> *TelephoneList = NULL;
2649 std::map<int, wxString> *TelephoneListType = NULL;
2650 std::map<int, wxString> *TelephoneListAltID = NULL;
2651 std::map<int, wxString> *TelephoneListPID = NULL;
2652 std::map<int, wxString> *TelephoneListTokens = NULL;
2653 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2654 std::map<int, int> *TelephoneListPref = NULL;
2658 TelephoneList = &GeneralTelephoneList;
2659 TelephoneListType = &GeneralTelephoneListType;
2660 TelephoneListAltID = &GeneralTelephoneListAltID;
2661 TelephoneListPID = &GeneralTelephoneListPID;
2662 TelephoneListTokens = &GeneralTelephoneListTokens;
2663 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2664 TelephoneListPref = &GeneralTelephoneListPref;
2667 TelephoneList = &HomeTelephoneList;
2668 TelephoneListType = &HomeTelephoneListType;
2669 TelephoneListAltID = &HomeTelephoneListAltID;
2670 TelephoneListPID = &HomeTelephoneListPID;
2671 TelephoneListTokens = &HomeTelephoneListTokens;
2672 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2673 TelephoneListPref = &HomeTelephoneListPref;
2676 TelephoneList = &BusinessTelephoneList;
2677 TelephoneListType = &BusinessTelephoneListType;
2678 TelephoneListAltID = &BusinessTelephoneListAltID;
2679 TelephoneListPID = &BusinessTelephoneListPID;
2680 TelephoneListTokens = &BusinessTelephoneListTokens;
2681 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2682 TelephoneListPref = &BusinessTelephoneListPref;
2686 // Process the properties.
2688 bool FirstToken = TRUE;
2691 SplitPoints.clear();
2692 SplitLength.clear();
2694 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2698 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2699 intiter != SplitPoints.end(); ++intiter){
2701 SLiter = SplitLength.find(intiter->first);
2703 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2705 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2706 PropertyName = PropertyElement.GetNextToken();
2707 PropertyValue = PropertyElement.GetNextToken();
2709 intPrevValue = intiter->second;
2711 CaptureString(&PropertyValue, FALSE);
2713 // Process properties.
2715 if (PropertyName == wxT("ALTID")){
2717 TelephoneListAltID->erase(*TelephoneCount);
2718 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2720 } else if (PropertyName == wxT("PID")){
2722 TelephoneListPID->erase(*TelephoneCount);
2723 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2725 } else if (PropertyName == wxT("PREF")){
2727 int PriorityNumber = 0;
2728 bool ValidNumber = TRUE;
2731 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2734 catch(std::invalid_argument &e){
2735 ValidNumber = FALSE;
2738 if (ValidNumber == TRUE){
2740 TelephoneListPref->erase(*TelephoneCount);
2741 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2747 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2749 if (FirstToken == TRUE){
2751 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2756 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2766 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2767 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2769 // Add the name token data.
2771 if (!PropertyTokens.IsEmpty()){
2773 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2779 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2781 std::map<int, int> SplitPoints;
2782 std::map<int, int> SplitLength;
2784 int intPrevValue = 6;
2787 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2791 PropertyType PropType = PROPERTY_NONE;
2793 // Look for type before continuing.
2795 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2797 std::map<int, wxString> *LanguageList = NULL;
2798 std::map<int, wxString> *LanguageListType = NULL;
2799 std::map<int, wxString> *LanguageListAltID = NULL;
2800 std::map<int, wxString> *LanguageListPID = NULL;
2801 std::map<int, wxString> *LanguageListTokens = NULL;
2802 std::map<int, int> *LanguageListPref = NULL;
2806 LanguageList = &GeneralLanguageList;
2807 LanguageListType = &GeneralLanguageListType;
2808 LanguageListAltID = &GeneralLanguageListAltID;
2809 LanguageListPID = &GeneralLanguageListPID;
2810 LanguageListTokens = &GeneralLanguageListTokens;
2811 LanguageListPref = &GeneralLanguageListPref;
2814 LanguageList = &HomeLanguageList;
2815 LanguageListType = &HomeLanguageListType;
2816 LanguageListAltID = &HomeLanguageListAltID;
2817 LanguageListPID = &HomeLanguageListPID;
2818 LanguageListTokens = &HomeLanguageListTokens;
2819 LanguageListPref = &HomeLanguageListPref;
2822 LanguageList = &BusinessLanguageList;
2823 LanguageListType = &BusinessLanguageListType;
2824 LanguageListAltID = &BusinessLanguageListAltID;
2825 LanguageListPID = &BusinessLanguageListPID;
2826 LanguageListTokens = &BusinessLanguageListTokens;
2827 LanguageListPref = &BusinessLanguageListPref;
2833 std::map<int,int>::iterator SLiter;
2834 wxString PropertyData;
2835 wxString PropertyName;
2836 wxString PropertyValue;
2837 wxString PropertyTokens;
2838 bool FirstToken = TRUE;
2840 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2841 intiter != SplitPoints.end(); ++intiter){
2843 SLiter = SplitLength.find(intiter->first);
2845 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2847 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2848 PropertyName = PropertyElement.GetNextToken();
2849 PropertyValue = PropertyElement.GetNextToken();
2851 intPrevValue = intiter->second;
2853 CaptureString(&PropertyValue, FALSE);
2855 // Process properties.
2857 if (PropertyName == wxT("ALTID")){
2859 LanguageListAltID->erase(*LanguageCount);
2860 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2862 } else if (PropertyName == wxT("PID")){
2864 LanguageListPID->erase(*LanguageCount);
2865 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2867 } else if (PropertyName == wxT("PREF")){
2869 int PriorityNumber = 0;
2870 bool ValidNumber = TRUE;
2873 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2876 catch(std::invalid_argument &e){
2877 ValidNumber = FALSE;
2880 if (ValidNumber == TRUE){
2882 LanguageListPref->erase(*LanguageCount);
2883 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2889 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2891 if (FirstToken == TRUE){
2893 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2898 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2908 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2910 // Add the name token data.
2912 if (!PropertyTokens.IsEmpty()){
2914 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2920 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2922 std::map<int, int> SplitPoints;
2923 std::map<int, int> SplitLength;
2925 int intPrevValue = 5;
2928 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2932 PropertyType PropType = PROPERTY_NONE;
2934 // Look for type before continuing.
2936 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2938 std::map<int, wxString> *GeopositionList = NULL;
2939 std::map<int, wxString> *GeopositionListType = NULL;
2940 std::map<int, wxString> *GeopositionListAltID = NULL;
2941 std::map<int, wxString> *GeopositionListPID = NULL;
2942 std::map<int, wxString> *GeopositionListTokens = NULL;
2943 std::map<int, wxString> *GeopositionListMediatype = NULL;
2944 std::map<int, int> *GeopositionListPref = NULL;
2948 GeopositionList = &GeneralGeographyList;
2949 GeopositionListType = &GeneralGeographyListType;
2950 GeopositionListAltID = &GeneralGeographyListAltID;
2951 GeopositionListPID = &GeneralGeographyListPID;
2952 GeopositionListTokens = &GeneralGeographyListTokens;
2953 GeopositionListMediatype = &GeneralGeographyListMediatype;
2954 GeopositionListPref = &GeneralGeographyListPref;
2957 GeopositionList = &HomeGeographyList;
2958 GeopositionListType = &HomeGeographyListType;
2959 GeopositionListAltID = &HomeGeographyListAltID;
2960 GeopositionListPID = &HomeGeographyListPID;
2961 GeopositionListTokens = &HomeGeographyListTokens;
2962 GeopositionListMediatype = &HomeGeographyListMediatype;
2963 GeopositionListPref = &HomeGeographyListPref;
2966 GeopositionList = &BusinessGeographyList;
2967 GeopositionListType = &BusinessGeographyListType;
2968 GeopositionListAltID = &BusinessGeographyListAltID;
2969 GeopositionListPID = &BusinessGeographyListPID;
2970 GeopositionListTokens = &BusinessGeographyListTokens;
2971 GeopositionListMediatype = &BusinessGeographyListMediatype;
2972 GeopositionListPref = &BusinessGeographyListPref;
2978 std::map<int,int>::iterator SLiter;
2979 wxString PropertyData;
2980 wxString PropertyName;
2981 wxString PropertyValue;
2982 wxString PropertyTokens;
2983 bool FirstToken = TRUE;
2985 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2986 intiter != SplitPoints.end(); ++intiter){
2988 SLiter = SplitLength.find(intiter->first);
2990 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2992 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2993 PropertyName = PropertyElement.GetNextToken();
2994 PropertyValue = PropertyElement.GetNextToken();
2996 intPrevValue = intiter->second;
2998 CaptureString(&PropertyValue, FALSE);
3000 // Process properties.
3002 if (PropertyName == wxT("ALTID")){
3004 GeopositionListAltID->erase(*GeographicCount);
3005 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
3007 } else if (PropertyName == wxT("PID")){
3009 GeopositionListPID->erase(*GeographicCount);
3010 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
3012 } else if (PropertyName == wxT("MEDIATYPE")){
3014 GeopositionListMediatype->erase(*GeographicCount);
3015 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
3017 } else if (PropertyName == wxT("PREF")){
3019 int PriorityNumber = 0;
3020 bool ValidNumber = TRUE;
3023 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3026 catch(std::invalid_argument &e){
3027 ValidNumber = FALSE;
3030 if (ValidNumber == TRUE){
3032 GeopositionListPref->erase(*GeographicCount);
3033 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
3039 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3041 if (FirstToken == TRUE){
3043 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3048 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3058 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3060 // Add the name token data.
3062 if (!PropertyTokens.IsEmpty()){
3064 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3070 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3072 size_t intPropertyLen = PropertySeg1.Len();
3073 std::map<int, int> SplitPoints;
3074 std::map<int, int> SplitLength;
3075 std::map<int, int>::iterator SLiter;
3076 wxString PropertyData;
3077 wxString PropertyName;
3078 wxString PropertyValue;
3079 wxString PropertyTokens;
3080 wxString RelatedType;
3081 wxString RelatedTypeOriginal;
3082 wxString RelatedName;
3083 bool FirstToken = TRUE;
3084 int intSplitsFound = 0;
3085 int intSplitSize = 0;
3086 int intPrevValue = 9;
3090 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3094 // Look for type before continuing.
3096 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3097 intiter != SplitPoints.end(); ++intiter){
3099 SLiter = SplitLength.find(intiter->first);
3101 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3103 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3104 PropertyName = PropertyElement.GetNextToken();
3105 PropertyValue = PropertyElement.GetNextToken();
3107 intPrevValue = intiter->second;
3111 RelatedTypeOriginal = PropertyValue;
3113 if (PropertyName == wxT("TYPE")){
3115 if (PropertyValue == wxT("contact")){
3117 RelatedType = _("Contact");
3119 } else if (PropertyValue == wxT("acquaintance")){
3121 RelatedType = _("Acquaintance");
3123 } else if (PropertyValue == wxT("friend")){
3125 RelatedType = _("Friend");
3127 } else if (PropertyValue == wxT("met")){
3129 RelatedType = _("Met");
3131 } else if (PropertyValue == wxT("co-worker")){
3133 RelatedType = _("Co-worker");
3135 } else if (PropertyValue == wxT("colleague")){
3137 RelatedType = _("Colleague");
3139 } else if (PropertyValue == wxT("co-resident")){
3141 RelatedType = _("Co-resident");
3143 } else if (PropertyValue == wxT("neighbor")){
3145 RelatedType = _("Neighbour");
3147 } else if (PropertyValue == wxT("child")){
3149 RelatedType = _("Child");
3151 } else if (PropertyValue == wxT("parent")){
3153 RelatedType = _("Parent");
3155 } else if (PropertyValue == wxT("sibling")){
3157 RelatedType = _("Sibling");
3159 } else if (PropertyValue == wxT("spouse")){
3161 RelatedType = _("Spouse");
3163 } else if (PropertyValue == wxT("kin")){
3165 RelatedType = _("Kin");
3167 } else if (PropertyValue == wxT("muse")){
3169 RelatedType = _("Muse");
3171 } else if (PropertyValue == wxT("crush")){
3173 RelatedType = _("Crush");
3175 } else if (PropertyValue == wxT("date")){
3177 RelatedType = _("Date");
3179 } else if (PropertyValue == wxT("sweetheart")){
3181 RelatedType = _("Sweetheart");
3183 } else if (PropertyValue == wxT("me")){
3185 RelatedType = _("Me");
3187 } else if (PropertyValue == wxT("agent")){
3189 RelatedType = _("Agent");
3191 } else if (PropertyValue == wxT("emergency")){
3193 RelatedType = _("Emergency");
3197 RelatedType = PropertyValue;
3207 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3208 intiter != SplitPoints.end(); ++intiter){
3210 SLiter = SplitLength.find(intiter->first);
3212 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3214 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3215 PropertyName = PropertyElement.GetNextToken();
3216 PropertyValue = PropertyElement.GetNextToken();
3218 intPrevValue = intiter->second;
3220 // Process properties.
3222 size_t intPropertyValueLen = PropertyValue.Len();
3224 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3226 PropertyValue.Trim();
3227 PropertyValue.RemoveLast();
3231 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3233 PropertyValue.Remove(0, 1);
3237 CaptureString(&PropertyValue, FALSE);
3239 if (PropertyName == wxT("ALTID")){
3241 GeneralRelatedListAltID.erase(*RelatedCount);
3242 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3244 } else if (PropertyName == wxT("PID")){
3246 GeneralRelatedListPID.erase(*RelatedCount);
3247 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3249 } else if (PropertyName == wxT("PREF")){
3251 int PriorityNumber = 0;
3252 bool ValidNumber = TRUE;
3255 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3258 catch(std::invalid_argument &e){
3259 ValidNumber = FALSE;
3262 if (ValidNumber == TRUE){
3264 GeneralRelatedListPref.erase(*RelatedCount);
3265 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3269 } else if (PropertyName == wxT("LANGUAGE")){
3271 GeneralRelatedListLanguage.erase(*RelatedCount);
3272 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3274 } else if (PropertyName != wxT("TYPE")) {
3276 // Something else we don't know about so append
3277 // to the tokens variable.
3279 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3281 if (FirstToken == TRUE){
3283 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3288 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3298 // Add the data to the General/Home/Work address variables.
3300 GeneralRelatedList.erase(*RelatedCount);
3301 GeneralRelatedListRelType.erase(*RelatedCount);
3302 GeneralRelatedListType.erase(*RelatedCount);
3303 GeneralRelatedListTokens.erase(*RelatedCount);
3304 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3305 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3306 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3307 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3311 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3313 std::map<int, int> SplitPoints;
3314 std::map<int, int> SplitLength;
3315 std::map<int, int>::iterator SLiter;
3316 wxString PropertyData;
3317 wxString PropertyName;
3318 wxString PropertyValue;
3319 wxString PropertyTokens;
3320 bool FirstToken = TRUE;
3321 int intPrevValue = 5;
3326 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3330 PropertyType PropType = PROPERTY_NONE;
3332 // Look for type before continuing.
3334 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3336 // Setup the pointers.
3338 std::map<int, wxString> *WebsiteList = NULL;
3339 std::map<int, wxString> *WebsiteListAltID = NULL;
3340 std::map<int, wxString> *WebsiteListPID = NULL;
3341 std::map<int, wxString> *WebsiteListType = NULL;
3342 std::map<int, wxString> *WebsiteListTokens = NULL;
3343 std::map<int, wxString> *WebsiteListMediatype = NULL;
3344 std::map<int, int> *WebsiteListPref = NULL;
3346 // Setup blank lines for later on.
3350 WebsiteList = &GeneralWebsiteList;
3351 WebsiteListType = &GeneralWebsiteListType;
3352 WebsiteListAltID = &GeneralWebsiteListAltID;
3353 WebsiteListPID = &GeneralWebsiteListPID;
3354 WebsiteListTokens = &GeneralWebsiteListTokens;
3355 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3356 WebsiteListPref = &GeneralWebsiteListPref;
3359 WebsiteList = &HomeWebsiteList;
3360 WebsiteListType = &HomeWebsiteListType;
3361 WebsiteListAltID = &HomeWebsiteListAltID;
3362 WebsiteListPID = &HomeWebsiteListPID;
3363 WebsiteListTokens = &HomeWebsiteListTokens;
3364 WebsiteListMediatype = &HomeWebsiteListMediatype;
3365 WebsiteListPref = &HomeWebsiteListPref;
3368 WebsiteList = &BusinessWebsiteList;
3369 WebsiteListType = &BusinessWebsiteListType;
3370 WebsiteListAltID = &BusinessWebsiteListAltID;
3371 WebsiteListPID = &BusinessWebsiteListPID;
3372 WebsiteListTokens = &BusinessWebsiteListTokens;
3373 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3374 WebsiteListPref = &BusinessWebsiteListPref;
3380 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3381 intiter != SplitPoints.end(); ++intiter){
3383 SLiter = SplitLength.find(intiter->first);
3385 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3387 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3388 PropertyName = PropertyElement.GetNextToken();
3389 PropertyValue = PropertyElement.GetNextToken();
3391 intPrevValue = intiter->second;
3393 // Process properties.
3395 size_t intPropertyValueLen = PropertyValue.Len();
3397 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3399 PropertyValue.Trim();
3400 PropertyValue.RemoveLast();
3404 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3406 PropertyValue.Remove(0, 1);
3410 CaptureString(&PropertyValue, FALSE);
3412 if (PropertyName == wxT("ALTID")){
3414 WebsiteListAltID->erase(*URLCount);
3415 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3417 } else if (PropertyName == wxT("PID")){
3419 WebsiteListPID->erase(*URLCount);
3420 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3422 } else if (PropertyName == wxT("PREF")){
3424 int PriorityNumber = 0;
3425 bool ValidNumber = TRUE;
3428 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3431 catch(std::invalid_argument &e){
3432 ValidNumber = FALSE;
3435 if (ValidNumber == TRUE){
3437 WebsiteListPref->erase(*URLCount);
3438 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3442 } else if (PropertyName == wxT("MEDIATYPE")){
3444 WebsiteListMediatype->erase(*URLCount);
3445 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3449 // Something else we don't know about so append
3450 // to the tokens variable.
3452 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3454 if (FirstToken == TRUE){
3456 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3461 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3471 // Add the data to the General/Home/Work address variables.
3473 CaptureString(&PropertySeg2, FALSE);
3475 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3477 if (!PropertyTokens.IsEmpty()){
3479 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3485 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3487 std::map<int, int> SplitPoints;
3488 std::map<int, int> SplitLength;
3489 std::map<int, int>::iterator SLiter;
3490 wxString PropertyData;
3491 wxString PropertyName;
3492 wxString PropertyValue;
3493 wxString PropertyTokens;
3494 bool FirstToken = TRUE;
3495 int intPrevValue = 7;
3500 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3504 PropertyType PropType = PROPERTY_NONE;
3506 // Look for type before continuing.
3508 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3510 // Setup the pointers.
3512 std::map<int, wxString> *TitleList = NULL;
3513 std::map<int, wxString> *TitleListAltID = NULL;
3514 std::map<int, wxString> *TitleListPID = NULL;
3515 std::map<int, wxString> *TitleListType = NULL;
3516 std::map<int, wxString> *TitleListTokens = NULL;
3517 std::map<int, wxString> *TitleListLanguage = NULL;
3518 std::map<int, int> *TitleListPref = NULL;
3520 // Setup blank lines for later on.
3524 TitleList = &GeneralTitleList;
3525 TitleListType = &GeneralTitleListType;
3526 TitleListAltID = &GeneralTitleListAltID;
3527 TitleListPID = &GeneralTitleListPID;
3528 TitleListTokens = &GeneralTitleListTokens;
3529 TitleListLanguage = &GeneralTitleListLanguage;
3530 TitleListPref = &GeneralTitleListPref;
3533 TitleList = &HomeTitleList;
3534 TitleListType = &HomeTitleListType;
3535 TitleListAltID = &HomeTitleListAltID;
3536 TitleListPID = &HomeTitleListPID;
3537 TitleListTokens = &HomeTitleListTokens;
3538 TitleListLanguage = &HomeTitleListLanguage;
3539 TitleListPref = &HomeTitleListPref;
3542 TitleList = &BusinessTitleList;
3543 TitleListType = &BusinessTitleListType;
3544 TitleListAltID = &BusinessTitleListAltID;
3545 TitleListPID = &BusinessTitleListPID;
3546 TitleListTokens = &BusinessTitleListTokens;
3547 TitleListLanguage = &BusinessTitleListLanguage;
3548 TitleListPref = &BusinessTitleListPref;
3554 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3555 intiter != SplitPoints.end(); ++intiter){
3557 SLiter = SplitLength.find(intiter->first);
3559 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3561 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3562 PropertyName = PropertyElement.GetNextToken();
3563 PropertyValue = PropertyElement.GetNextToken();
3565 intPrevValue = intiter->second;
3567 // Process properties.
3569 size_t intPropertyValueLen = PropertyValue.Len();
3571 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3573 PropertyValue.Trim();
3574 PropertyValue.RemoveLast();
3578 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3580 PropertyValue.Remove(0, 1);
3584 CaptureString(&PropertyValue, FALSE);
3586 if (PropertyName == wxT("ALTID")){
3588 TitleListAltID->erase(*TitleCount);
3589 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3591 } else if (PropertyName == wxT("PID")){
3593 TitleListPID->erase(*TitleCount);
3594 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3596 } else if (PropertyName == wxT("PREF")){
3598 int PriorityNumber = 0;
3599 bool ValidNumber = TRUE;
3602 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3605 catch(std::invalid_argument &e){
3606 ValidNumber = FALSE;
3609 if (ValidNumber == TRUE){
3611 TitleListPref->erase(*TitleCount);
3612 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3616 } else if (PropertyName == wxT("LANGUAGE")){
3618 TitleListLanguage->erase(*TitleCount);
3619 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3623 // Something else we don't know about so append
3624 // to the tokens variable.
3626 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3628 if (FirstToken == TRUE){
3630 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3635 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3645 // Add the data to the General/Home/Work address variables.
3647 CaptureString(&PropertySeg2, FALSE);
3649 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3651 if (!PropertyTokens.IsEmpty()){
3653 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3659 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3661 std::map<int, int> SplitPoints;
3662 std::map<int, int> SplitLength;
3663 std::map<int, int>::iterator SLiter;
3664 wxString PropertyData;
3665 wxString PropertyName;
3666 wxString PropertyValue;
3667 wxString PropertyTokens;
3668 bool FirstToken = TRUE;
3669 int intPrevValue = 6;
3674 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3678 PropertyType PropType = PROPERTY_NONE;
3680 // Look for type before continuing.
3682 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3684 // Setup the pointers.
3686 std::map<int, wxString> *RoleList = NULL;
3687 std::map<int, wxString> *RoleListAltID = NULL;
3688 std::map<int, wxString> *RoleListPID = NULL;
3689 std::map<int, wxString> *RoleListType = NULL;
3690 std::map<int, wxString> *RoleListTokens = NULL;
3691 std::map<int, wxString> *RoleListLanguage = NULL;
3692 std::map<int, int> *RoleListPref = NULL;
3694 // Setup blank lines for later on.
3698 RoleList = &GeneralRoleList;
3699 RoleListType = &GeneralRoleListType;
3700 RoleListAltID = &GeneralRoleListAltID;
3701 RoleListPID = &GeneralRoleListPID;
3702 RoleListTokens = &GeneralRoleListTokens;
3703 RoleListLanguage = &GeneralRoleListLanguage;
3704 RoleListPref = &GeneralRoleListPref;
3707 RoleList = &HomeRoleList;
3708 RoleListType = &HomeRoleListType;
3709 RoleListAltID = &HomeRoleListAltID;
3710 RoleListPID = &HomeRoleListPID;
3711 RoleListTokens = &HomeRoleListTokens;
3712 RoleListLanguage = &HomeRoleListLanguage;
3713 RoleListPref = &HomeRoleListPref;
3716 RoleList = &BusinessRoleList;
3717 RoleListType = &BusinessRoleListType;
3718 RoleListAltID = &BusinessRoleListAltID;
3719 RoleListPID = &BusinessRoleListPID;
3720 RoleListTokens = &BusinessRoleListTokens;
3721 RoleListLanguage = &BusinessRoleListLanguage;
3722 RoleListPref = &BusinessRoleListPref;
3728 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3729 intiter != SplitPoints.end(); ++intiter){
3731 SLiter = SplitLength.find(intiter->first);
3733 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3735 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3736 PropertyName = PropertyElement.GetNextToken();
3737 PropertyValue = PropertyElement.GetNextToken();
3739 intPrevValue = intiter->second;
3741 // Process properties.
3743 size_t intPropertyValueLen = PropertyValue.Len();
3745 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3747 PropertyValue.Trim();
3748 PropertyValue.RemoveLast();
3752 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3754 PropertyValue.Remove(0, 1);
3758 CaptureString(&PropertyValue, FALSE);
3760 if (PropertyName == wxT("ALTID")){
3762 RoleListAltID->erase(*RoleCount);
3763 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3765 } else if (PropertyName == wxT("PID")){
3767 RoleListPID->erase(*RoleCount);
3768 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3770 } else if (PropertyName == wxT("PREF")){
3772 int PriorityNumber = 0;
3773 bool ValidNumber = TRUE;
3776 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3779 catch(std::invalid_argument &e){
3780 ValidNumber = FALSE;
3783 if (ValidNumber == TRUE){
3785 RoleListPref->erase(*RoleCount);
3786 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3790 } else if (PropertyName == wxT("LANGUAGE")){
3792 RoleListLanguage->erase(*RoleCount);
3793 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3797 // Something else we don't know about so append
3798 // to the tokens variable.
3800 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3802 if (FirstToken == TRUE){
3804 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3809 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3819 // Add the data to the General/Home/Work address variables.
3821 CaptureString(&PropertySeg2, FALSE);
3823 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3825 if (!PropertyTokens.IsEmpty()){
3827 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3833 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3835 std::map<int, int> SplitPoints;
3836 std::map<int, int> SplitLength;
3837 std::map<int, int>::iterator SLiter;
3838 wxString PropertyData;
3839 wxString PropertyName;
3840 wxString PropertyValue;
3841 wxString PropertyTokens;
3842 bool FirstToken = TRUE;
3843 int intPrevValue = 5;
3848 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3852 PropertyType PropType = PROPERTY_NONE;
3854 // Look for type before continuing.
3856 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3858 // Setup the pointers.
3860 std::map<int, wxString> *OrganisationsList = NULL;
3861 std::map<int, wxString> *OrganisationsListAltID = NULL;
3862 std::map<int, wxString> *OrganisationsListPID = NULL;
3863 std::map<int, wxString> *OrganisationsListType = NULL;
3864 std::map<int, wxString> *OrganisationsListTokens = NULL;
3865 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3866 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3867 std::map<int, int> *OrganisationsListPref = NULL;
3869 // Setup blank lines for later on.
3873 OrganisationsList = &GeneralOrganisationsList;
3874 OrganisationsListType = &GeneralOrganisationsListType;
3875 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3876 OrganisationsListPID = &GeneralOrganisationsListPID;
3877 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3878 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3879 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3880 OrganisationsListPref = &GeneralOrganisationsListPref;
3883 OrganisationsList = &HomeOrganisationsList;
3884 OrganisationsListType = &HomeOrganisationsListType;
3885 OrganisationsListAltID = &HomeOrganisationsListAltID;
3886 OrganisationsListPID = &HomeOrganisationsListPID;
3887 OrganisationsListTokens = &HomeOrganisationsListTokens;
3888 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3889 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3890 OrganisationsListPref = &HomeOrganisationsListPref;
3893 OrganisationsList = &BusinessOrganisationsList;
3894 OrganisationsListType = &BusinessOrganisationsListType;
3895 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3896 OrganisationsListPID = &BusinessOrganisationsListPID;
3897 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3898 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3899 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3900 OrganisationsListPref = &BusinessOrganisationsListPref;
3906 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3907 intiter != SplitPoints.end(); ++intiter){
3909 SLiter = SplitLength.find(intiter->first);
3911 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3913 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3914 PropertyName = PropertyElement.GetNextToken();
3915 PropertyValue = PropertyElement.GetNextToken();
3917 intPrevValue = intiter->second;
3919 // Process properties.
3921 size_t intPropertyValueLen = PropertyValue.Len();
3923 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3925 PropertyValue.Trim();
3926 PropertyValue.RemoveLast();
3930 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3932 PropertyValue.Remove(0, 1);
3936 CaptureString(&PropertyValue, FALSE);
3938 if (PropertyName == wxT("ALTID")){
3940 OrganisationsListAltID->erase(*OrganisationCount);
3941 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3943 } else if (PropertyName == wxT("PID")){
3945 OrganisationsListPID->erase(*OrganisationCount);
3946 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3948 } else if (PropertyName == wxT("SORT-AS")){
3950 OrganisationsListSortAs->erase(*OrganisationCount);
3951 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3953 } else if (PropertyName == wxT("PREF")){
3955 int PriorityNumber = 0;
3956 bool ValidNumber = TRUE;
3959 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3962 catch(std::invalid_argument &e){
3963 ValidNumber = FALSE;
3966 if (ValidNumber == TRUE){
3968 OrganisationsListPref->erase(*OrganisationCount);
3969 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3973 } else if (PropertyName == wxT("LANGUAGE")){
3975 OrganisationsListLanguage->erase(*OrganisationCount);
3976 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3980 // Something else we don't know about so append
3981 // to the tokens variable.
3983 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3985 if (FirstToken == TRUE){
3987 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3992 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4002 // Add the data to the General/Home/Work address variables.
4004 CaptureString(&PropertySeg2, FALSE);
4006 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
4008 if (!PropertyTokens.IsEmpty()){
4010 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
4016 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
4018 std::map<int, int> SplitPoints;
4019 std::map<int, int> SplitLength;
4020 std::map<int, int>::iterator SLiter;
4021 wxString PropertyData;
4022 wxString PropertyName;
4023 wxString PropertyValue;
4024 wxString PropertyTokens;
4025 bool FirstToken = TRUE;
4026 int intPrevValue = 6;
4031 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4035 PropertyType PropType = PROPERTY_NONE;
4037 // Look for type before continuing.
4039 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4041 // Setup the pointers.
4043 std::map<int, wxString> *NoteList = NULL;
4044 std::map<int, wxString> *NoteListAltID = NULL;
4045 std::map<int, wxString> *NoteListPID = NULL;
4046 std::map<int, wxString> *NoteListType = NULL;
4047 std::map<int, wxString> *NoteListTokens = NULL;
4048 std::map<int, wxString> *NoteListLanguage = NULL;
4049 std::map<int, int> *NoteListPref = NULL;
4051 // Setup blank lines for later on.
4055 NoteList = &GeneralNoteList;
4056 NoteListType = &GeneralNoteListType;
4057 NoteListAltID = &GeneralNoteListAltID;
4058 NoteListPID = &GeneralNoteListPID;
4059 NoteListTokens = &GeneralNoteListTokens;
4060 NoteListLanguage = &GeneralNoteListLanguage;
4061 NoteListPref = &GeneralNoteListPref;
4064 NoteList = &HomeNoteList;
4065 NoteListType = &HomeNoteListType;
4066 NoteListAltID = &HomeNoteListAltID;
4067 NoteListPID = &HomeNoteListPID;
4068 NoteListTokens = &HomeNoteListTokens;
4069 NoteListLanguage = &HomeNoteListLanguage;
4070 NoteListPref = &HomeNoteListPref;
4073 NoteList = &BusinessNoteList;
4074 NoteListType = &BusinessNoteListType;
4075 NoteListAltID = &BusinessNoteListAltID;
4076 NoteListPID = &BusinessNoteListPID;
4077 NoteListTokens = &BusinessNoteListTokens;
4078 NoteListLanguage = &BusinessNoteListLanguage;
4079 NoteListPref = &BusinessNoteListPref;
4085 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4086 intiter != SplitPoints.end(); ++intiter){
4088 SLiter = SplitLength.find(intiter->first);
4090 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4092 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4093 PropertyName = PropertyElement.GetNextToken();
4094 PropertyValue = PropertyElement.GetNextToken();
4096 intPrevValue = intiter->second;
4098 // Process properties.
4100 size_t intPropertyValueLen = PropertyValue.Len();
4102 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4104 PropertyValue.Trim();
4105 PropertyValue.RemoveLast();
4109 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4111 PropertyValue.Remove(0, 1);
4115 CaptureString(&PropertyValue, FALSE);
4117 if (PropertyName == wxT("ALTID")){
4119 NoteListAltID->erase(*NoteCount);
4120 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4122 } else if (PropertyName == wxT("PID")){
4124 NoteListPID->erase(*NoteCount);
4125 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4127 } else if (PropertyName == wxT("PREF")){
4129 int PriorityNumber = 0;
4130 bool ValidNumber = TRUE;
4133 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4136 catch(std::invalid_argument &e){
4137 ValidNumber = FALSE;
4140 if (ValidNumber == TRUE){
4142 NoteListPref->erase(*NoteCount);
4143 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4147 } else if (PropertyName == wxT("LANGUAGE")){
4149 NoteListLanguage->erase(*NoteCount);
4150 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4154 // Something else we don't know about so append
4155 // to the tokens variable.
4157 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4159 if (FirstToken == TRUE){
4161 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4166 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4176 // Add the data to the General/Home/Work address variables.
4178 CaptureString(&PropertySeg2, FALSE);
4180 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4182 if (!PropertyTokens.IsEmpty()){
4184 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4190 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4192 std::map<int, int> SplitPoints;
4193 std::map<int, int> SplitLength;
4194 std::map<int, int>::iterator SLiter;
4195 wxString PropertyData;
4196 wxString PropertyName;
4197 wxString PropertyValue;
4198 wxString PropertyTokens;
4199 bool FirstToken = TRUE;
4200 int intPrevValue = 12;
4205 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4209 PropertyType PropType = PROPERTY_NONE;
4211 // Look for type before continuing.
4213 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4215 // Setup blank lines for later on.
4221 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4224 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4230 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4231 intiter != SplitPoints.end(); ++intiter){
4233 SLiter = SplitLength.find(intiter->first);
4235 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4237 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4238 PropertyName = PropertyElement.GetNextToken();
4239 PropertyValue = PropertyElement.GetNextToken();
4241 intPrevValue = intiter->second;
4243 // Process properties.
4245 size_t intPropertyValueLen = PropertyValue.Len();
4247 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4249 PropertyValue.Trim();
4250 PropertyValue.RemoveLast();
4254 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4256 PropertyValue.Remove(0, 1);
4260 CaptureString(&PropertyValue, FALSE);
4262 if (PropertyName == wxT("ALTID")){
4264 CategoriesListAltID.erase(*CategoryCount);
4265 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4267 } else if (PropertyName == wxT("PID")){
4269 CategoriesListPID.erase(*CategoryCount);
4270 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4272 } else if (PropertyName == wxT("PREF")){
4274 int PriorityNumber = 0;
4275 bool ValidNumber = TRUE;
4278 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4281 catch(std::invalid_argument &e){
4282 ValidNumber = FALSE;
4285 if (ValidNumber == TRUE){
4287 CategoriesListPref.erase(*CategoryCount);
4288 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4292 } else if (PropertyName == wxT("LANGUAGE")){
4294 CategoriesListLanguage.erase(*CategoryCount);
4295 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4299 // Something else we don't know about so append
4300 // to the tokens variable.
4302 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4304 if (FirstToken == TRUE){
4306 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4311 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4321 // Deal with multiple categories.
4323 int intOrigCatCount = *CategoryCount;
4324 bool FirstCategoryProcessed = TRUE;
4325 bool AfterFirstToken = FALSE;
4326 int intSplitSize = 0;
4327 int intSplitsFound = 0;
4328 int intSplitSeek = 0;
4329 int intPropertyLen = PropertySeg2.Len();
4331 SplitPoints.clear();
4332 SplitLength.clear();
4335 for (int i = 0; i <= intPropertyLen; i++){
4337 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4345 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4347 if (AfterFirstToken == TRUE){
4349 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4350 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4354 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4355 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4356 AfterFirstToken = TRUE;
4368 if (SplitPoints.size() > 0){
4370 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4371 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4375 if (SplitPoints.size() == 0){
4377 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4379 if (!PropertyTokens.IsEmpty()){
4381 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4387 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4388 intiter != SplitPoints.end(); ++intiter){
4390 SLiter = SplitLength.find(intiter->first);
4392 intPrevValue = intiter->second;
4394 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4396 // Add the data to the General/Home/Work address variables.
4398 // Trim any whitespace from the start and end.
4400 PropertyData = PropertyData.Trim(FALSE);
4401 PropertyData = PropertyData.Trim(TRUE);
4403 CaptureString(&PropertyData, FALSE);
4405 if (FirstCategoryProcessed == TRUE){
4407 FirstCategoryProcessed = FALSE;
4409 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4411 if (!PropertyTokens.IsEmpty()){
4413 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4423 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4425 if (!PropertyTokens.IsEmpty()){
4427 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4433 // Copy the properties to each of the categories (if it exists).
4435 if (!PropertyTokens.IsEmpty()){
4437 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4441 // Check if ALTID was used.
4443 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4445 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4449 // Check if PID was used.
4451 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4453 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4457 // Check if PREF was used.
4459 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4461 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4465 // Check if LANGUAGE was used.
4467 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4469 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4473 // Check if TYPE was used.
4479 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4482 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4490 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4492 size_t intPropertyLen = PropertySeg1.Len();
4493 std::map<int, int> SplitPoints;
4494 std::map<int, int> SplitLength;
4495 std::map<int, int>::iterator SLiter;
4496 wxString PropertyData;
4497 wxString PropertyName;
4498 wxString PropertyValue;
4499 wxString PropertyTokens;
4500 bool FirstToken = TRUE;
4501 int intSplitsFound = 0;
4502 int intSplitSize = 0;
4503 int intPrevValue = 7;
4507 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4511 PropertyType PropType = PROPERTY_NONE;
4513 // Look for type before continuing.
4515 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4519 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4520 intiter != SplitPoints.end(); ++intiter){
4522 SLiter = SplitLength.find(intiter->first);
4524 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4526 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4527 PropertyName = PropertyElement.GetNextToken();
4528 PropertyValue = PropertyElement.GetNextToken();
4530 intPrevValue = intiter->second;
4532 // Process properties.
4534 size_t intPropertyValueLen = PropertyValue.Len();
4536 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4538 PropertyValue.Trim();
4539 PropertyValue.RemoveLast();
4543 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4545 PropertyValue.Remove(0, 1);
4549 CaptureString(&PropertyValue, FALSE);
4551 if (PropertyName == wxT("ALTID")){
4553 PicturesListAltID.erase(*PhotoCount);
4554 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4556 } else if (PropertyName == wxT("PID")){
4558 PicturesListPID.erase(*PhotoCount);
4559 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4561 } else if (PropertyName == wxT("PREF")){
4563 int PriorityNumber = 0;
4564 bool ValidNumber = TRUE;
4567 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4570 catch(std::invalid_argument &e){
4571 ValidNumber = FALSE;
4574 if (ValidNumber == TRUE){
4576 PicturesListPref.erase(*PhotoCount);
4577 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4581 } else if (PropertyName == wxT("MEDIATYPE")){
4583 PicturesListMediatype.erase(*PhotoCount);
4584 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4588 // Something else we don't know about so append
4589 // to the tokens variable.
4591 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4593 if (FirstToken == TRUE){
4595 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4600 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4610 intPropertyLen = PropertySeg2.Len();
4611 SplitPoints.clear();
4612 SplitLength.clear();
4617 CaptureString(&PropertySeg2, FALSE);
4619 for (int i = 0; i <= intPropertyLen; i++){
4623 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4626 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4628 if (intSplitsFound == 6){
4630 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4635 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4645 wxString wxSPhotoURI;
4646 wxString wxSPhotoMIME;
4647 wxString wxSPhotoEncoding;
4648 wxString wxSPhotoData;
4649 std::string base64enc;
4651 if (intSplitsFound == 0){
4655 std::map<int, int>::iterator striter;
4657 striter = SplitLength.find(1);
4659 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4661 while (wSTDataType.HasMoreTokens() == TRUE){
4663 wxSPhotoURI = wSTDataType.GetNextToken();
4664 wxSPhotoMIME = wSTDataType.GetNextToken();
4669 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4671 while (wSTDataInfo.HasMoreTokens() == TRUE){
4673 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4674 wxSPhotoData = wSTDataInfo.GetNextToken();
4675 base64enc = wxSPhotoData.mb_str();
4682 // Add the data to the General/Home/Work address variables.
4684 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4685 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4686 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4692 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4695 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4699 if (!PropertyTokens.IsEmpty()){
4701 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4707 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4709 size_t intPropertyLen = PropertySeg1.Len();
4710 std::map<int, int> SplitPoints;
4711 std::map<int, int> SplitLength;
4712 std::map<int, int>::iterator SLiter;
4713 wxString PropertyData;
4714 wxString PropertyName;
4715 wxString PropertyValue;
4716 wxString PropertyTokens;
4717 bool FirstToken = TRUE;
4718 int intSplitsFound = 0;
4719 int intSplitSize = 0;
4720 int intPrevValue = 6;
4724 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4728 PropertyType PropType = PROPERTY_NONE;
4730 // Look for type before continuing.
4732 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4736 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4737 intiter != SplitPoints.end(); ++intiter){
4739 SLiter = SplitLength.find(intiter->first);
4741 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4743 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4744 PropertyName = PropertyElement.GetNextToken();
4745 PropertyValue = PropertyElement.GetNextToken();
4747 intPrevValue = intiter->second;
4749 // Process properties.
4751 size_t intPropertyValueLen = PropertyValue.Len();
4753 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4755 PropertyValue.Trim();
4756 PropertyValue.RemoveLast();
4760 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4762 PropertyValue.Remove(0, 1);
4766 CaptureString(&PropertyValue, FALSE);
4768 if (PropertyName == wxT("ALTID")){
4770 LogosListAltID.erase(*LogoCount);
4771 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4773 } else if (PropertyName == wxT("PID")){
4775 LogosListPID.erase(*LogoCount);
4776 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4778 } else if (PropertyName == wxT("PREF")){
4780 int PriorityNumber = 0;
4781 bool ValidNumber = TRUE;
4784 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4787 catch(std::invalid_argument &e){
4788 ValidNumber = FALSE;
4791 if (ValidNumber == TRUE){
4793 LogosListPref.erase(*LogoCount);
4794 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4798 } else if (PropertyName == wxT("MEDIATYPE")){
4800 LogosListMediatype.erase(*LogoCount);
4801 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4805 // Something else we don't know about so append
4806 // to the tokens variable.
4808 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4810 if (FirstToken == TRUE){
4812 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4817 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4827 intPropertyLen = PropertySeg2.Len();
4828 SplitPoints.clear();
4829 SplitLength.clear();
4834 CaptureString(&PropertySeg2, FALSE);
4836 for (int i = 0; i <= intPropertyLen; i++){
4840 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4843 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4845 if (intSplitsFound == 6){
4847 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4852 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4862 wxString wxSPhotoURI;
4863 wxString wxSPhotoMIME;
4864 wxString wxSPhotoEncoding;
4865 wxString wxSPhotoData;
4866 std::string base64enc;
4868 if (intSplitsFound == 0){
4872 std::map<int, int>::iterator striter;
4874 striter = SplitLength.find(1);
4876 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4878 while (wSTDataType.HasMoreTokens() == TRUE){
4880 wxSPhotoURI = wSTDataType.GetNextToken();
4881 wxSPhotoMIME = wSTDataType.GetNextToken();
4886 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4888 while (wSTDataInfo.HasMoreTokens() == TRUE){
4890 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4891 wxSPhotoData = wSTDataInfo.GetNextToken();
4892 base64enc = wxSPhotoData.mb_str();
4899 // Add the data to the General/Home/Work address variables.
4901 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4902 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4903 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4909 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4912 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4916 if (!PropertyTokens.IsEmpty()){
4918 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4924 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4926 size_t intPropertyLen = PropertySeg1.Len();
4927 std::map<int, int> SplitPoints;
4928 std::map<int, int> SplitLength;
4929 std::map<int, int>::iterator SLiter;
4930 wxString PropertyData;
4931 wxString PropertyName;
4932 wxString PropertyValue;
4933 wxString PropertyTokens;
4934 bool FirstToken = TRUE;
4935 int intSplitsFound = 0;
4936 int intSplitSize = 0;
4937 int intPrevValue = 7;
4941 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4945 PropertyType PropType = PROPERTY_NONE;
4947 // Look for type before continuing.
4949 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4953 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4954 intiter != SplitPoints.end(); ++intiter){
4956 SLiter = SplitLength.find(intiter->first);
4958 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4960 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4961 PropertyName = PropertyElement.GetNextToken();
4962 PropertyValue = PropertyElement.GetNextToken();
4964 intPrevValue = intiter->second;
4966 // Process properties.
4968 size_t intPropertyValueLen = PropertyValue.Len();
4970 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4972 PropertyValue.Trim();
4973 PropertyValue.RemoveLast();
4977 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4979 PropertyValue.Remove(0, 1);
4983 CaptureString(&PropertyValue, FALSE);
4985 if (PropertyName == wxT("ALTID")){
4987 SoundsListAltID.erase(*SoundCount);
4988 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4990 } else if (PropertyName == wxT("PID")){
4992 SoundsListPID.erase(*SoundCount);
4993 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4995 } else if (PropertyName == wxT("PREF")){
4997 int PriorityNumber = 0;
4998 bool ValidNumber = TRUE;
5001 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5004 catch(std::invalid_argument &e){
5005 ValidNumber = FALSE;
5008 if (ValidNumber == TRUE){
5010 SoundsListPref.erase(*SoundCount);
5011 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
5015 } else if (PropertyName == wxT("MEDIATYPE")){
5017 SoundsListMediatype.erase(*SoundCount);
5018 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
5020 } else if (PropertyName == wxT("LANGUAGE")){
5022 SoundsListLanguage.erase(*SoundCount);
5023 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
5027 // Something else we don't know about so append
5028 // to the tokens variable.
5030 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5032 if (FirstToken == TRUE){
5034 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5039 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5049 intPropertyLen = PropertySeg2.Len();
5050 SplitPoints.clear();
5051 SplitLength.clear();
5056 CaptureString(&PropertySeg2, FALSE);
5058 for (int i = 0; i <= intPropertyLen; i++){
5062 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5065 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5067 if (intSplitsFound == 6){
5069 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5074 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5084 wxString wxSSoundURI;
5085 wxString wxSSoundMIME;
5086 wxString wxSSoundEncoding;
5087 wxString wxSSoundData;
5088 std::string base64enc;
5090 if (intSplitsFound == 0){
5094 std::map<int, int>::iterator striter;
5096 striter = SplitLength.find(1);
5098 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5100 while (wSTDataType.HasMoreTokens() == TRUE){
5102 wxSSoundURI = wSTDataType.GetNextToken();
5103 wxSSoundMIME = wSTDataType.GetNextToken();
5108 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5110 while (wSTDataInfo.HasMoreTokens() == TRUE){
5112 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5113 wxSSoundData = wSTDataInfo.GetNextToken();
5114 base64enc = wxSSoundData.mb_str();
5121 // Add the data to the General/Home/Work address variables.
5127 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5130 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5134 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5135 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5136 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5138 if (!PropertyTokens.IsEmpty()){
5140 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5146 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5148 size_t intPropertyLen = PropertySeg1.Len();
5149 std::map<int, int> SplitPoints;
5150 std::map<int, int> SplitLength;
5151 std::map<int, int>::iterator SLiter;
5152 wxString PropertyData;
5153 wxString PropertyName;
5154 wxString PropertyValue;
5155 wxString PropertyTokens;
5156 bool FirstToken = TRUE;
5157 int intSplitsFound = 0;
5158 int intSplitSize = 0;
5159 int intPrevValue = 8;
5163 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5167 PropertyType PropType = PROPERTY_NONE;
5169 // Look for type before continuing.
5171 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5175 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5176 intiter != SplitPoints.end(); ++intiter){
5178 SLiter = SplitLength.find(intiter->first);
5180 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5182 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5183 PropertyName = PropertyElement.GetNextToken();
5184 PropertyValue = PropertyElement.GetNextToken();
5186 intPrevValue = intiter->second;
5188 // Process properties.
5190 size_t intPropertyValueLen = PropertyValue.Len();
5192 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5194 PropertyValue.Trim();
5195 PropertyValue.RemoveLast();
5199 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5201 PropertyValue.Remove(0, 1);
5205 CaptureString(&PropertyValue, FALSE);
5207 if (PropertyName == wxT("ALTID")){
5209 CalendarListAltID.erase(*CalURICount);
5210 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5212 } else if (PropertyName == wxT("PID")){
5214 CalendarListPID.erase(*CalURICount);
5215 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5217 } else if (PropertyName == wxT("PREF")){
5219 int PriorityNumber = 0;
5220 bool ValidNumber = TRUE;
5223 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5226 catch(std::invalid_argument &e){
5227 ValidNumber = FALSE;
5230 if (ValidNumber == TRUE){
5232 CalendarListPref.erase(*CalURICount);
5233 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5237 } else if (PropertyName == wxT("MEDIATYPE")){
5239 CalendarListMediatype.erase(*CalURICount);
5240 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5244 // Something else we don't know about so append
5245 // to the tokens variable.
5247 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5249 if (FirstToken == TRUE){
5251 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5256 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5266 intPropertyLen = PropertySeg2.Len();
5267 SplitPoints.clear();
5268 SplitLength.clear();
5273 CaptureString(&PropertySeg2, FALSE);
5275 // Add the data to the General/Home/Work address variables.
5281 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5284 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5288 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5290 if (!PropertyTokens.IsEmpty()){
5292 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5298 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5300 size_t intPropertyLen = PropertySeg1.Len();
5301 std::map<int, int> SplitPoints;
5302 std::map<int, int> SplitLength;
5303 std::map<int, int>::iterator SLiter;
5304 wxString PropertyData;
5305 wxString PropertyName;
5306 wxString PropertyValue;
5307 wxString PropertyTokens;
5308 bool FirstToken = TRUE;
5309 int intSplitsFound = 0;
5310 int intSplitSize = 0;
5311 int intPrevValue = 8;
5315 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5319 PropertyType PropType = PROPERTY_NONE;
5321 // Look for type before continuing.
5323 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5327 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5328 intiter != SplitPoints.end(); ++intiter){
5330 SLiter = SplitLength.find(intiter->first);
5332 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5334 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5335 PropertyName = PropertyElement.GetNextToken();
5336 PropertyValue = PropertyElement.GetNextToken();
5338 intPrevValue = intiter->second;
5340 // Process properties.
5342 size_t intPropertyValueLen = PropertyValue.Len();
5344 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5346 PropertyValue.Trim();
5347 PropertyValue.RemoveLast();
5351 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5353 PropertyValue.Remove(0, 1);
5357 CaptureString(&PropertyValue, FALSE);
5359 if (PropertyName == wxT("ALTID")){
5361 CalendarRequestListAltID.erase(*CalAdrURICount);
5362 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5364 } else if (PropertyName == wxT("PID")){
5366 CalendarRequestListPID.erase(*CalAdrURICount);
5367 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5369 } else if (PropertyName == wxT("PREF")){
5371 int PriorityNumber = 0;
5372 bool ValidNumber = TRUE;
5375 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5378 catch(std::invalid_argument &e){
5379 ValidNumber = FALSE;
5382 if (ValidNumber == TRUE){
5384 CalendarRequestListPref.erase(*CalAdrURICount);
5385 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5389 } else if (PropertyName == wxT("MEDIATYPE")){
5391 CalendarRequestListMediatype.erase(*CalAdrURICount);
5392 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5396 // Something else we don't know about so append
5397 // to the tokens variable.
5399 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5401 if (FirstToken == TRUE){
5403 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5408 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5418 intPropertyLen = PropertySeg2.Len();
5419 SplitPoints.clear();
5420 SplitLength.clear();
5425 CaptureString(&PropertySeg2, FALSE);
5427 // Add the data to the General/Home/Work address variables.
5433 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5436 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5440 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5442 if (!PropertyTokens.IsEmpty()){
5444 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5450 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5452 size_t intPropertyLen = PropertySeg1.Len();
5453 std::map<int, int> SplitPoints;
5454 std::map<int, int> SplitLength;
5455 std::map<int, int>::iterator SLiter;
5456 wxString PropertyData;
5457 wxString PropertyName;
5458 wxString PropertyValue;
5459 wxString PropertyTokens;
5460 bool FirstToken = TRUE;
5461 int intSplitsFound = 0;
5462 int intSplitSize = 0;
5463 int intPrevValue = 7;
5467 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5471 PropertyType PropType = PROPERTY_NONE;
5473 // Look for type before continuing.
5475 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5479 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5480 intiter != SplitPoints.end(); ++intiter){
5482 SLiter = SplitLength.find(intiter->first);
5484 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5486 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5487 PropertyName = PropertyElement.GetNextToken();
5488 PropertyValue = PropertyElement.GetNextToken();
5490 intPrevValue = intiter->second;
5492 // Process properties.
5494 size_t intPropertyValueLen = PropertyValue.Len();
5496 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5498 PropertyValue.Trim();
5499 PropertyValue.RemoveLast();
5503 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5505 PropertyValue.Remove(0, 1);
5509 CaptureString(&PropertyValue, FALSE);
5511 if (PropertyName == wxT("ALTID")){
5513 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5514 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5516 } else if (PropertyName == wxT("PID")){
5518 FreeBusyListPID.erase(*FreeBusyAddressCount);
5519 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5521 } else if (PropertyName == wxT("PREF")){
5523 int PriorityNumber = 0;
5524 bool ValidNumber = TRUE;
5527 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5530 catch(std::invalid_argument &e){
5531 ValidNumber = FALSE;
5534 if (ValidNumber == TRUE){
5536 FreeBusyListPref.erase(*FreeBusyAddressCount);
5537 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5541 } else if (PropertyName == wxT("MEDIATYPE")){
5543 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5544 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5548 // Something else we don't know about so append
5549 // to the tokens variable.
5551 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5553 if (FirstToken == TRUE){
5555 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5560 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5570 intPropertyLen = PropertySeg2.Len();
5571 SplitPoints.clear();
5572 SplitLength.clear();
5577 CaptureString(&PropertySeg2, FALSE);
5579 // Add the data to the General/Home/Work address variables.
5585 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5588 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5592 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5594 if (!PropertyTokens.IsEmpty()){
5596 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5602 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5604 size_t intPropertyLen = PropertySeg1.Len();
5605 std::map<int, int> SplitPoints;
5606 std::map<int, int> SplitLength;
5607 std::map<int, int>::iterator SLiter;
5608 wxString PropertyData;
5609 wxString PropertyName;
5610 wxString PropertyValue;
5611 wxString PropertyTokens;
5612 bool FirstToken = TRUE;
5613 int intSplitsFound = 0;
5614 int intSplitSize = 0;
5615 int intPrevValue = 5;
5620 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5624 PropertyType PropType = PROPERTY_NONE;
5626 // Look for type before continuing.
5628 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5632 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5633 intiter != SplitPoints.end(); ++intiter){
5635 SLiter = SplitLength.find(intiter->first);
5637 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5639 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5640 PropertyName = PropertyElement.GetNextToken();
5641 PropertyValue = PropertyElement.GetNextToken();
5643 intPrevValue = intiter->second;
5645 // Process properties.
5647 size_t intPropertyValueLen = PropertyValue.Len();
5649 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5651 PropertyValue.Trim();
5652 PropertyValue.RemoveLast();
5656 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5658 PropertyValue.Remove(0, 1);
5662 if (PropertyName == wxT("ALTID")){
5664 KeyListAltID.erase(*KeyCount);
5665 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5667 } else if (PropertyName == wxT("PID")){
5669 KeyListPID.erase(*KeyCount);
5670 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5672 } else if (PropertyName == wxT("PREF")){
5674 int PriorityNumber = 0;
5675 bool ValidNumber = TRUE;
5678 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5681 catch(std::invalid_argument &e){
5682 ValidNumber = FALSE;
5685 if (ValidNumber == TRUE){
5687 KeyListPref.erase(*KeyCount);
5688 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5694 // Something else we don't know about so append
5695 // to the tokens variable.
5697 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5699 if (FirstToken == TRUE){
5701 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5706 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5716 intPropertyLen = PropertySeg2.Len();
5717 SplitPoints.clear();
5718 SplitLength.clear();
5723 for (int i = 0; i <= intPropertyLen; i++){
5727 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5730 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5732 if (intSplitsFound == 6){
5734 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5739 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5750 wxString wxSKeyMIME;
5751 wxString wxSKeyEncoding;
5752 wxString wxSKeyData;
5753 std::string base64enc;
5755 if (intSplitsFound == 0){
5759 std::map<int, int>::iterator striter;
5761 striter = SplitLength.find(1);
5763 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5765 while (wSTDataType.HasMoreTokens() == TRUE){
5767 wxSKeyURI = wSTDataType.GetNextToken();
5768 wxSKeyMIME = wSTDataType.GetNextToken();
5773 if (wxSKeyURI == wxT("data")){
5775 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5777 while (wSTDataInfo.HasMoreTokens() == TRUE){
5779 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5780 wxSKeyData = wSTDataInfo.GetNextToken();
5789 // Add the data to the General/Home/Work address variables.
5791 if (wxSKeyURI == wxT("data")){
5793 KeyListDataEncType.erase(*KeyCount);
5794 KeyListKeyType.erase(*KeyCount);
5795 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5796 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5798 KeyList.erase(*KeyCount);
5799 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5803 KeyList.erase(*KeyCount);
5804 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5808 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5814 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5817 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5821 if (!PropertyTokens.IsEmpty()){
5823 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5829 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5831 // Split the Vendor three ways.
5833 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5836 wxString wxSVNDPropName;
5839 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5841 wSTVendorDetails.GetNextToken();
5842 wxSVNDID = wSTVendorDetails.GetNextToken();
5843 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5848 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5850 // Add the data to the vendor variables.
5852 VendorList.erase(*VendorCount);
5853 VendorListPEN.erase(*VendorCount);
5854 VendorListElement.erase(*VendorCount);
5856 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5857 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5858 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5864 void ProcessIntegerValue(ContactDataObject *ContactData,
5865 std::map<int,int> *PrefPtr,
5866 wxString *PropertyValue,
5869 int PriorityNumber = 0;
5870 bool ValidNumber = TRUE;
5873 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5876 catch(std::invalid_argument &e){
5877 ValidNumber = FALSE;
5880 if (ValidNumber == TRUE){
5882 PrefPtr->erase(*ItemCount);
5883 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5889 void SplitValues(wxString *PropertyLine,
5890 std::map<int,int> *SplitPoints,
5891 std::map<int,int> *SplitLength,
5894 size_t intPropertyLen = PropertyLine->Len();
5895 int intSplitsFound = 0;
5896 int intSplitSize = 0;
5897 int intSplitSeek = 0;
5899 for (int i = intSize; i <= intPropertyLen; i++){
5903 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5904 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5906 if (intSplitsFound == 0){
5908 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5912 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5916 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5926 if (intSplitsFound == 0){
5928 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5929 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5933 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5934 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5940 void CheckType(wxString *PropertySeg1,
5941 std::map<int,int> *SplitPoints,
5942 std::map<int,int> *SplitLength,
5944 PropertyType *PropType){
5946 wxString PropertyData;
5947 wxString PropertyName;
5948 wxString PropertyValue;
5949 std::map<int,int>::iterator SLiter;
5951 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5952 intiter != SplitPoints->end(); ++intiter){
5954 SLiter = SplitLength->find(intiter->first);
5956 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5958 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5959 PropertyName = PropertyElement.GetNextToken();
5960 PropertyValue = PropertyElement.GetNextToken();
5962 *intPrevValue = intiter->second;
5964 if (PropertyName == wxT("TYPE")){
5966 if (PropertyValue == wxT("work")){
5968 *PropType = PROPERTY_WORK;
5970 } else if (PropertyValue == wxT("home")){
5972 *PropType = PROPERTY_HOME;
5976 *PropType = PROPERTY_NONE;