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 int PriorityNumber = 0;
615 bool ValidNumber = TRUE;
618 PriorityNumber = std::stoi(PropertyValue.ToStdString());
621 catch(std::invalid_argument &e){
625 if (ValidNumber == TRUE){
627 SourceListPref.erase(*SourceCount);
628 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
632 } else if (PropertyName == wxT("MEDIATYPE")){
634 SourceListMediatype.erase(*SourceCount);
635 SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
639 // Something else we don't know about so append
640 // to the tokens variable.
642 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
644 if (FirstToken == TRUE){
646 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
651 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
661 intPropertyLen = PropertySeg2.Len();
668 CaptureString(&PropertySeg2, FALSE);
670 // Add the data to the General/Home/Work address variables.
676 SourceListType.insert(std::make_pair(*SourceCount, "home"));
679 SourceListType.insert(std::make_pair(*SourceCount, "work"));
683 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
685 if (!PropertyTokens.IsEmpty()){
687 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
693 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
695 std::map<int, int> SplitPoints;
696 std::map<int, int> SplitLength;
698 int intPrevValue = 5;
702 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
706 wxString PropertyName;
707 wxString PropertyValue;
708 wxString PropertyData;
709 wxString PropertyTokens;
710 std::map<int,int>::iterator SLiter;
711 bool FirstToken = TRUE;
713 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
714 intiter != SplitPoints.end(); ++intiter){
716 SLiter = SplitLength.find(intiter->first);
718 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
720 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
721 PropertyName = PropertyElement.GetNextToken();
722 PropertyValue = PropertyElement.GetNextToken();
724 intPrevValue = intiter->second;
726 CaptureString(&PropertyValue, FALSE);
728 if (PropertyName == wxT("ALTID")){
730 XMLListAltID.erase(*XMLCount);
731 XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
737 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
741 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
743 std::map<int, int> SplitPoints;
744 std::map<int, int> SplitLength;
746 int intPrevValue = 8;
750 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
754 wxString PropertyName;
755 wxString PropertyValue;
756 wxString PropertyData;
757 wxString PropertyTokens;
758 std::map<int,int>::iterator SLiter;
759 bool FirstToken = TRUE;
761 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
762 intiter != SplitPoints.end(); ++intiter){
764 SLiter = SplitLength.find(intiter->first);
766 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
768 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
769 PropertyName = PropertyElement.GetNextToken();
770 PropertyValue = PropertyElement.GetNextToken();
772 intPrevValue = intiter->second;
774 CaptureString(&PropertyValue, FALSE);
776 if (PropertyName == wxT("ALTID")){
778 GroupsListAltID.erase(*GroupCount);
779 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
781 } else if (PropertyName == wxT("PID")){
783 GroupsListPID.erase(*GroupCount);
784 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
786 } else if (PropertyName == wxT("PREF")){
788 int PriorityNumber = 0;
789 bool ValidNumber = TRUE;
792 PriorityNumber = std::stoi(PropertyValue.ToStdString());
795 catch(std::invalid_argument &e){
799 if (ValidNumber == TRUE){
801 GroupsListPref.erase(*GroupCount);
802 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
806 } else if (PropertyName == wxT("MEDIATYPE")){
808 GroupsListMediaType.erase(*GroupCount);
809 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
811 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
813 if (FirstToken == TRUE){
815 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
820 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
828 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
830 if (!PropertyTokens.IsEmpty()){
832 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
839 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
841 std::map<int, int> SplitPoints;
842 std::map<int, int> SplitLength;
844 int intPrevValue = 4;
848 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
852 wxString PropertyName;
853 wxString PropertyValue;
854 wxString PropertyData;
855 wxString PropertyTokens;
856 std::map<int,int>::iterator SLiter;
857 bool FirstToken = TRUE;
859 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
860 intiter != SplitPoints.end(); ++intiter){
862 SLiter = SplitLength.find(intiter->first);
864 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
866 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
867 PropertyName = PropertyElement.GetNextToken();
868 PropertyValue = PropertyElement.GetNextToken();
870 intPrevValue = intiter->second;
872 CaptureString(&PropertyValue, FALSE);
874 if (PropertyName == wxT("TYPE")){
876 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
877 PropertyValue == wxT("work") ){
879 FullNamesListType.erase(*FNCount);
880 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
884 } else if (PropertyName == wxT("LANGUAGE")){
886 FullNamesListLanguage.erase(*FNCount);
887 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
889 } else if (PropertyName == wxT("ALTID")){
891 FullNamesListAltID.erase(*FNCount);
892 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
894 } else if (PropertyName == wxT("PID")){
896 FullNamesListPID.erase(*FNCount);
897 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
899 } else if (PropertyName == wxT("PREF")){
901 int PriorityNumber = 0;
902 bool ValidNumber = TRUE;
905 PriorityNumber = std::stoi(PropertyValue.ToStdString());
908 catch(std::invalid_argument &e){
912 if (ValidNumber == TRUE){
914 FullNamesListPref.erase(*FNCount);
915 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
919 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
921 if (FirstToken == TRUE){
923 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
928 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
936 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
938 if (!PropertyTokens.IsEmpty()){
940 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
946 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
948 std::map<int, int> SplitPoints;
949 std::map<int, int> SplitLength;
951 int intPrevValue = 3;
955 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
959 wxString PropertyName;
960 wxString PropertyValue;
961 wxString PropertyData;
962 wxString PropertyTokens;
963 std::map<int,int>::iterator SLiter;
964 bool FirstToken = TRUE;
966 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
967 intiter != SplitPoints.end(); ++intiter){
969 SLiter = SplitLength.find(intiter->first);
971 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
973 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
974 PropertyName = PropertyElement.GetNextToken();
975 PropertyValue = PropertyElement.GetNextToken();
977 intPrevValue = intiter->second;
979 CaptureString(&PropertyValue, FALSE);
981 if (PropertyName == wxT("ALTID")){
983 NameAltID = PropertyValue;
985 } else if (PropertyName == wxT("LANGUAGE")){
987 NameLanguage = PropertyValue;
989 } else if (PropertyName == wxT("SORT-AS")){
991 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
992 PropertyValue.Len() >= 3){
993 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
996 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
998 if (FirstToken == TRUE){
1000 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1005 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1013 // Split the name data.
1015 int intSplitSeek = 0;
1016 int intSplitsFound = 0;
1017 int intSplitSize = 0;
1018 int intPropertyLen = PropertySeg2.Len();
1020 std::map<int,wxString> NameValues;
1023 for (int i = 0; i <= intPropertyLen; i++){
1025 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1027 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
1032 if (intSplitsFound == 4){
1034 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1048 // Split the data into several parts.
1050 for (std::map<int, wxString>::iterator iter = NameValues.begin();
1051 iter != NameValues.end(); ++iter){
1053 if (iter->first == 1){
1055 // Deal with family name.
1057 NameSurname = iter->second;
1059 } else if (iter->first == 2){
1061 // Deal with given names.
1063 NameForename = iter->second;
1065 } else if (iter->first == 3){
1067 // Deal with additional names.
1069 NameOtherNames = iter->second;
1071 } else if (iter->first == 4){
1073 // Deal with honorifix prefixes and suffixes.
1075 NameTitle = iter->second;
1079 if (iter == NameValues.end()){
1085 NameSuffix = iter->second;
1091 // Add the name token data.
1093 if (!PropertyTokens.IsEmpty()){
1095 NameTokens = PropertyTokens;
1101 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1103 size_t intPropertyLen = PropertySeg1.Len();
1104 std::map<int, int> SplitPoints;
1105 std::map<int, int> SplitLength;
1106 std::map<int, int>::iterator SLiter;
1107 wxString PropertyData;
1108 wxString PropertyName;
1109 wxString PropertyValue;
1110 wxString PropertyTokens;
1111 bool FirstToken = TRUE;
1112 int intSplitsFound = 0;
1113 int intSplitSize = 0;
1114 int intPrevValue = 14;
1118 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1122 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1123 intiter != SplitPoints.end(); ++intiter){
1125 SLiter = SplitLength.find(intiter->first);
1127 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1129 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1130 PropertyName = PropertyElement.GetNextToken();
1131 PropertyValue = PropertyElement.GetNextToken();
1133 intPrevValue = intiter->second;
1135 // Process properties.
1137 size_t intPropertyValueLen = PropertyValue.Len();
1139 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1141 PropertyValue.Trim();
1142 PropertyValue.RemoveLast();
1146 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1148 PropertyValue.Remove(0, 1);
1152 CaptureString(&PropertyValue, FALSE);
1154 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1160 if (FirstToken == TRUE){
1162 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1167 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1173 CaptureString(&PropertySeg2, FALSE);
1175 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1177 if (!PropertyTokens.IsEmpty()){
1179 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1185 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1187 std::map<int, int> SplitPoints;
1188 std::map<int, int> SplitLength;
1190 int intPrevValue = 10;
1193 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1197 PropertyType PropType = PROPERTY_NONE;
1199 // Look for type before continuing.
1201 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1205 std::map<int, wxString> *NicknamesList = NULL;
1206 std::map<int, wxString> *NicknamesListType = NULL;
1207 std::map<int, wxString> *NicknamesListLanguage = NULL;
1208 std::map<int, wxString> *NicknamesListAltID = NULL;
1209 std::map<int, wxString> *NicknamesListPID = NULL;
1210 std::map<int, wxString> *NicknamesListTokens = NULL;
1211 std::map<int, int> *NicknamesListPref = NULL;
1215 NicknamesList = &GeneralNicknamesList;
1216 NicknamesListType = &GeneralNicknamesListType;
1217 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1218 NicknamesListAltID = &GeneralNicknamesListAltID;
1219 NicknamesListPID = &GeneralNicknamesListPID;
1220 NicknamesListTokens = &GeneralNicknamesListTokens;
1221 NicknamesListPref = &GeneralNicknamesListPref;
1224 NicknamesList = &HomeNicknamesList;
1225 NicknamesListType = &HomeNicknamesListType;
1226 NicknamesListLanguage = &HomeNicknamesListLanguage;
1227 NicknamesListAltID = &HomeNicknamesListAltID;
1228 NicknamesListPID = &HomeNicknamesListPID;
1229 NicknamesListTokens = &HomeNicknamesListTokens;
1230 NicknamesListPref = &HomeNicknamesListPref;
1233 NicknamesList = &BusinessNicknamesList;
1234 NicknamesListType = &BusinessNicknamesListType;
1235 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1236 NicknamesListAltID = &BusinessNicknamesListAltID;
1237 NicknamesListPID = &BusinessNicknamesListPID;
1238 NicknamesListTokens = &BusinessNicknamesListTokens;
1239 NicknamesListPref = &BusinessNicknamesListPref;
1243 std::map<int, int>::iterator SLiter;
1244 wxString PropertyData;
1245 wxString PropertyName;
1246 wxString PropertyValue;
1247 wxString PropertyTokens;
1248 bool FirstToken = TRUE;
1250 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1251 intiter != SplitPoints.end(); ++intiter){
1253 SLiter = SplitLength.find(intiter->first);
1255 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1257 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1258 PropertyName = PropertyElement.GetNextToken();
1259 PropertyValue = PropertyElement.GetNextToken();
1261 intPrevValue = intiter->second;
1263 CaptureString(&PropertyValue, FALSE);
1265 if (PropertyName == wxT("ALTID")){
1267 NicknamesListAltID->erase(*NicknameCount);
1268 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1270 } else if (PropertyName == wxT("PID")){
1272 NicknamesListPID->erase(*NicknameCount);
1273 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1275 } else if (PropertyName == wxT("PREF")){
1277 int PriorityNumber = 0;
1278 bool ValidNumber = TRUE;
1281 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1284 catch(std::invalid_argument &e){
1285 ValidNumber = FALSE;
1288 if (ValidNumber == TRUE){
1290 NicknamesListPref->erase(*NicknameCount);
1291 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1295 } else if (PropertyName == wxT("LANGUAGE")){
1297 NicknamesListLanguage->erase(*NicknameCount);
1298 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1302 // Something else we don't know about so append
1303 // to the tokens variable.
1305 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1307 if (FirstToken == TRUE){
1309 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1314 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1324 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1326 // Add the name token data.
1328 if (!PropertyTokens.IsEmpty()){
1330 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1336 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1338 std::map<int, int> SplitPoints;
1339 std::map<int, int> SplitLength;
1340 std::map<int, int>::iterator SLiter;
1341 wxString PropertyData;
1342 wxString PropertyName;
1343 wxString PropertyValue;
1344 wxString PropertyTokens;
1345 bool FirstToken = TRUE;
1346 int intPrevValue = 8;
1348 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1352 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1353 intiter != SplitPoints.end(); ++intiter){
1355 SLiter = SplitLength.find(intiter->first);
1357 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1359 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1360 PropertyName = PropertyElement.GetNextToken();
1361 PropertyValue = PropertyElement.GetNextToken();
1363 intPrevValue = intiter->second;
1365 // Process properties.
1367 size_t intPropertyValueLen = PropertyValue.Len();
1369 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1371 PropertyValue.Trim();
1372 PropertyValue.RemoveLast();
1376 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1378 PropertyValue.Remove(0, 1);
1382 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1384 if (FirstToken == TRUE){
1386 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1391 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1399 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1401 wxString GenderComponent;
1403 if (GenderData.CountTokens() >= 2){
1405 Gender = GenderData.GetNextToken();
1406 GenderDetails = GenderData.GetString();
1408 CaptureString(&GenderDetails, FALSE);
1412 Gender = GenderData.GetNextToken();
1416 if (!PropertyTokens.IsEmpty()){
1418 GenderTokens = PropertyTokens;
1424 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1426 // Process date. Preserve the remainder in the string.
1428 std::map<int, int> SplitPoints;
1429 std::map<int, int> SplitLength;
1430 std::map<int, int>::iterator SLiter;
1431 wxString PropertyData;
1432 wxString PropertyName;
1433 wxString PropertyValue;
1434 wxString PropertyTokens;
1435 bool BirthdayText = FALSE;
1436 int intPrevValue = 6;
1438 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1442 // Look for type before continuing.
1444 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1445 intiter != SplitPoints.end(); ++intiter){
1447 SLiter = SplitLength.find(intiter->first);
1449 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1451 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1452 PropertyName = PropertyElement.GetNextToken();
1453 PropertyValue = PropertyElement.GetNextToken();
1455 intPrevValue = intiter->second;
1457 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1459 CaptureString(&PropertySeg2, FALSE);
1460 Birthday = PropertySeg2;
1461 BirthdayText = TRUE;
1467 // Setup blank lines for later on.
1470 bool FirstToken = TRUE;
1472 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1473 intiter != SplitPoints.end(); ++intiter){
1475 SLiter = SplitLength.find(intiter->first);
1477 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1479 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1480 PropertyName = PropertyElement.GetNextToken();
1481 PropertyValue = PropertyElement.GetNextToken();
1483 intPrevValue = intiter->second;
1485 // Process properties.
1487 CaptureString(&PropertyValue, FALSE);
1489 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1491 PropertyValue.Trim();
1492 PropertyValue.RemoveLast();
1496 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1498 PropertyValue.Remove(0, 1);
1502 if (PropertyName == wxT("ALTID")){
1504 BirthdayAltID = PropertyValue;
1506 } else if (PropertyName == wxT("CALSCALE")){
1508 BirthdayCalScale = PropertyValue;
1510 } else if (PropertyName != wxT("VALUE")) {
1512 // Something else we don't know about so append
1513 // to the tokens variable.
1515 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1517 if (FirstToken == TRUE){
1519 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1524 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1534 // Add the data to the variables and form.
1536 if (BirthdayText == FALSE){
1538 Birthday = PropertySeg2;
1542 if (!PropertyTokens.IsEmpty()){
1544 BirthdayTokens = PropertyTokens;
1550 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1552 // Process date. Preserve the remainder in the string.
1554 std::map<int, int> SplitPoints;
1555 std::map<int, int> SplitLength;
1556 std::map<int, int>::iterator SLiter;
1557 wxString PropertyData;
1558 wxString PropertyName;
1559 wxString PropertyValue;
1560 wxString PropertyTokens;
1561 bool AnniversaryText = FALSE;
1562 int intPrevValue = 13;
1564 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1568 // Look for type before continuing.
1570 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1571 intiter != SplitPoints.end(); ++intiter){
1573 SLiter = SplitLength.find(intiter->first);
1575 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1577 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1578 PropertyName = PropertyElement.GetNextToken();
1579 PropertyValue = PropertyElement.GetNextToken();
1581 intPrevValue = intiter->second;
1583 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1585 CaptureString(&PropertySeg2, FALSE);
1586 Anniversary = PropertySeg2;
1587 AnniversaryText = TRUE;
1593 // Setup blank lines for later on.
1596 bool FirstToken = TRUE;
1598 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1599 intiter != SplitPoints.end(); ++intiter){
1601 SLiter = SplitLength.find(intiter->first);
1603 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1605 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1606 PropertyName = PropertyElement.GetNextToken();
1607 PropertyValue = PropertyElement.GetNextToken();
1609 intPrevValue = intiter->second;
1611 // Process properties.
1613 CaptureString(&PropertyValue, FALSE);
1615 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1617 PropertyValue.Trim();
1618 PropertyValue.RemoveLast();
1622 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1624 PropertyValue.Remove(0, 1);
1628 if (PropertyName == wxT("ALTID")){
1630 AnniversaryAltID = PropertyValue;
1632 } else if (PropertyName == wxT("CALSCALE")){
1634 AnniversaryCalScale = PropertyValue;
1636 } else if (PropertyName != wxT("VALUE")) {
1638 // Something else we don't know about so append
1639 // to the tokens variable.
1641 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1643 if (FirstToken == TRUE){
1645 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1650 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1660 // Add the data to the variables and form.
1662 if (AnniversaryText == FALSE){
1664 Anniversary = PropertySeg2;
1668 if (!PropertyTokens.IsEmpty()){
1670 AnniversaryTokens = PropertyTokens;
1676 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1678 std::map<int, int> SplitPoints;
1679 std::map<int, int> SplitLength;
1681 int intPrevValue = 4;
1684 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1688 PropertyType PropType = PROPERTY_NONE;
1690 // Look for type before continuing.
1692 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1696 std::map<int, wxString> *TZList = NULL;
1697 std::map<int, wxString> *TZListType = NULL;
1698 std::map<int, wxString> *TZListMediatype = NULL;
1699 std::map<int, wxString> *TZListAltID = NULL;
1700 std::map<int, wxString> *TZListPID = NULL;
1701 std::map<int, wxString> *TZListTokens = NULL;
1702 std::map<int, int> *TZListPref = NULL;
1706 TZList = &GeneralTZList;
1707 TZListType = &GeneralTZListType;
1708 TZListMediatype = &GeneralTZListMediatype;
1709 TZListAltID = &GeneralTZListAltID;
1710 TZListPID = &GeneralTZListPID;
1711 TZListTokens = &GeneralTZListTokens;
1712 TZListPref = &GeneralTZListPref;
1715 TZList = &HomeTZList;
1716 TZListType = &HomeTZListType;
1717 TZListMediatype = &HomeTZListMediatype;
1718 TZListAltID = &HomeTZListAltID;
1719 TZListPID = &HomeTZListPID;
1720 TZListTokens = &HomeTZListTokens;
1721 TZListPref = &HomeTZListPref;
1724 TZList = &BusinessTZList;
1725 TZListType = &BusinessTZListType;
1726 TZListMediatype = &BusinessTZListMediatype;
1727 TZListAltID = &BusinessTZListAltID;
1728 TZListPID = &BusinessTZListPID;
1729 TZListTokens = &BusinessTZListTokens;
1730 TZListPref = &BusinessTZListPref;
1734 std::map<int, int>::iterator SLiter;
1735 wxString PropertyData;
1736 wxString PropertyName;
1737 wxString PropertyValue;
1738 wxString PropertyTokens;
1739 bool FirstToken = TRUE;
1741 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1742 intiter != SplitPoints.end(); ++intiter){
1744 SLiter = SplitLength.find(intiter->first);
1746 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1748 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1749 PropertyName = PropertyElement.GetNextToken();
1750 PropertyValue = PropertyElement.GetNextToken();
1752 intPrevValue = intiter->second;
1754 CaptureString(&PropertyValue, FALSE);
1756 if (PropertyName == wxT("ALTID")){
1758 TZListAltID->erase(*TimeZoneCount);
1759 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1761 } else if (PropertyName == wxT("PID")){
1763 TZListPID->erase(*TimeZoneCount);
1764 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1766 } else if (PropertyName == wxT("PREF")){
1768 int PriorityNumber = 0;
1769 bool ValidNumber = TRUE;
1772 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1775 catch(std::invalid_argument &e){
1776 ValidNumber = FALSE;
1779 if (ValidNumber == TRUE){
1781 TZListPref->erase(*TimeZoneCount);
1782 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1786 } else if (PropertyName == wxT("MEDIATYPE")){
1788 TZListMediatype->erase(*TimeZoneCount);
1789 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1793 // Something else we don't know about so append
1794 // to the tokens variable.
1796 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1798 if (FirstToken == TRUE){
1800 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1805 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1815 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1817 // Add the name token data.
1819 if (!PropertyTokens.IsEmpty()){
1821 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1828 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1830 size_t intPropertyLen = PropertySeg1.Len();
1831 std::map<int, int> SplitPoints;
1832 std::map<int, int> SplitLength;
1833 std::map<int, int>::iterator SLiter;
1834 wxString PropertyData;
1835 wxString PropertyName;
1836 wxString PropertyValue;
1837 wxString PropertyTokens;
1838 wxString AddressLabel;
1839 wxString AddressLang;
1840 wxString AddressAltID;
1841 wxString AddressPID;
1842 wxString AddressTokens;
1843 wxString AddressGeo;
1844 wxString AddressTimezone;
1845 wxString AddressType;
1846 wxString AddressMediatype;
1847 wxString AddressPOBox;
1848 wxString AddressExtended;
1849 wxString AddressStreet;
1850 wxString AddressLocality;
1851 wxString AddressCity;
1852 wxString AddressRegion;
1853 wxString AddressPostalCode;
1854 wxString AddressCountry;
1855 bool FirstToken = TRUE;
1856 int intSplitsFound = 0;
1857 int intSplitSize = 0;
1858 int intPrevValue = 5;
1863 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1867 PropertyType PropType = PROPERTY_NONE;
1869 // Look for type before continuing.
1871 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1875 std::map<int, wxString> *AddressList = NULL;
1876 std::map<int, wxString> *AddressListTown = NULL;
1877 std::map<int, wxString> *AddressListCounty = NULL;
1878 std::map<int, wxString> *AddressListPostCode = NULL;
1879 std::map<int, wxString> *AddressListCountry = NULL;
1880 std::map<int, wxString> *AddressListLabel = NULL;
1881 std::map<int, wxString> *AddressListLang = NULL;
1882 std::map<int, wxString> *AddressListAltID = NULL;
1883 std::map<int, wxString> *AddressListPID = NULL;
1884 std::map<int, wxString> *AddressListTokens = NULL;
1885 std::map<int, wxString> *AddressListGeo = NULL;
1886 std::map<int, wxString> *AddressListTimezone = NULL;
1887 std::map<int, wxString> *AddressListType = NULL;
1888 std::map<int, wxString> *AddressListMediatype = NULL;
1889 std::map<int, int> *AddressListPref = NULL;
1893 AddressList = &GeneralAddressList;
1894 AddressListTown = &GeneralAddressListTown;
1895 AddressListCounty = &GeneralAddressListCounty;
1896 AddressListPostCode = &GeneralAddressListPostCode;
1897 AddressListCountry = &GeneralAddressListCountry;
1898 AddressListLabel = &GeneralAddressListLabel;
1899 AddressListLang = &GeneralAddressListLang;
1900 AddressListAltID = &GeneralAddressListAltID;
1901 AddressListPID = &GeneralAddressListPID;
1902 AddressListTokens = &GeneralAddressListTokens;
1903 AddressListGeo = &GeneralAddressListGeo;
1904 AddressListTimezone = &GeneralAddressListTimezone;
1905 AddressListType = &GeneralAddressListType;
1906 AddressListMediatype = &GeneralAddressListMediatype;
1907 AddressListPref = &GeneralAddressListPref;
1910 AddressList = &HomeAddressList;
1911 AddressListTown = &HomeAddressListTown;
1912 AddressListCounty = &HomeAddressListCounty;
1913 AddressListPostCode = &HomeAddressListPostCode;
1914 AddressListCountry = &HomeAddressListCountry;
1915 AddressListLabel = &HomeAddressListLabel;
1916 AddressListLang = &HomeAddressListLang;
1917 AddressListAltID = &HomeAddressListAltID;
1918 AddressListPID = &HomeAddressListPID;
1919 AddressListTokens = &HomeAddressListTokens;
1920 AddressListGeo = &HomeAddressListGeo;
1921 AddressListTimezone = &HomeAddressListTimezone;
1922 AddressListType = &HomeAddressListType;
1923 AddressListMediatype = &HomeAddressListMediatype;
1924 AddressListPref = &HomeAddressListPref;
1927 AddressList = &BusinessAddressList;
1928 AddressListTown = &BusinessAddressListTown;
1929 AddressListCounty = &BusinessAddressListCounty;
1930 AddressListPostCode = &BusinessAddressListPostCode;
1931 AddressListCountry = &BusinessAddressListCountry;
1932 AddressListLabel = &BusinessAddressListLabel;
1933 AddressListLang = &BusinessAddressListLang;
1934 AddressListAltID = &BusinessAddressListAltID;
1935 AddressListPID = &BusinessAddressListPID;
1936 AddressListTokens = &BusinessAddressListTokens;
1937 AddressListGeo = &BusinessAddressListGeo;
1938 AddressListTimezone = &BusinessAddressListTimezone;
1939 AddressListType = &BusinessAddressListType;
1940 AddressListMediatype = &BusinessAddressListMediatype;
1941 AddressListPref = &BusinessAddressListPref;
1947 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1948 intiter != SplitPoints.end(); ++intiter){
1950 SLiter = SplitLength.find(intiter->first);
1952 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1954 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1955 PropertyName = PropertyElement.GetNextToken();
1956 PropertyValue = PropertyElement.GetNextToken();
1958 intPrevValue = intiter->second;
1960 CaptureString(&PropertyValue, FALSE);
1962 // Process properties.
1964 if (PropertyName == wxT("LABEL")){
1966 AddressListLabel->erase(*AddressCount);
1967 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1969 } else if (PropertyName == wxT("LANGUAGE")){
1971 AddressListLang->erase(*AddressCount);
1972 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1974 } else if (PropertyName == wxT("ALTID")){
1976 AddressListAltID->erase(*AddressCount);
1977 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1979 } else if (PropertyName == wxT("PID")){
1981 AddressListPID->erase(*AddressCount);
1982 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1984 } else if (PropertyName == wxT("GEO")){
1986 AddressListGeo->erase(*AddressCount);
1987 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1989 } else if (PropertyName == wxT("TZ")){
1991 AddressListTimezone->erase(*AddressCount);
1992 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1994 } else if (PropertyName == wxT("MEDIATYPE")){
1996 AddressListMediatype->erase(*AddressCount);
1997 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1999 } else if (PropertyName == wxT("PREF")){
2001 int PriorityNumber = 0;
2002 bool ValidNumber = TRUE;
2005 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2008 catch(std::invalid_argument &e){
2009 ValidNumber = FALSE;
2012 if (ValidNumber == TRUE){
2014 AddressListPref->erase(*AddressCount);
2015 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
2021 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2023 if (FirstToken == TRUE){
2025 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2030 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2040 // Split the address.
2042 //std::map<int, int>::iterator SLiter;
2043 intPropertyLen = PropertySeg2.Len();
2044 SplitPoints.clear();
2045 SplitLength.clear();
2050 for (int i = 0; i <= intPropertyLen; i++){
2054 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2057 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2059 if (intSplitsFound == 6){
2061 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2066 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2076 // Split the data into several parts.
2078 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2079 intiter != SplitPoints.end(); ++intiter){
2081 if (intiter->first == 1){
2083 // Deal with PO Box.
2085 SLiter = SplitLength.find(1);
2087 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2088 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2089 intPrevValue = intiter->second;
2091 } else if (intiter->first == 2){
2093 // Deal with extended address.
2095 SLiter = SplitLength.find(2);
2097 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2098 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2099 intPrevValue = intiter->second;
2101 } else if (intiter->first == 3){
2103 // Deal with street address.
2105 SLiter = SplitLength.find(3);
2107 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2108 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2109 intPrevValue = intiter->second;
2111 } else if (intiter->first == 4){
2113 // Deal with locality
2115 SLiter = SplitLength.find(4);
2117 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2118 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2119 intPrevValue = intiter->second;
2121 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2123 } else if (intiter->first == 5){
2125 // Deal with region.
2127 SLiter = SplitLength.find(5);
2129 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2130 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2131 intPrevValue = intiter->second;
2133 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2135 } else if (intiter->first == 6){
2137 // Deal with post code.
2139 SLiter = SplitLength.find(6);
2141 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2142 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2143 intPrevValue = intiter->second;
2145 // Deal with country.
2147 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2148 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2156 // Add the data to the General/Home/Work address variables.
2158 CaptureString(&AddressStreet, FALSE);
2159 CaptureString(&AddressLocality, FALSE);
2160 CaptureString(&AddressRegion, FALSE);
2161 CaptureString(&AddressPostalCode, FALSE);
2162 CaptureString(&AddressCountry, FALSE);
2164 if (!PropertyTokens.IsEmpty()){
2166 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2170 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2171 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2172 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2173 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2174 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2178 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2181 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2184 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2188 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2192 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2194 std::map<int, int> SplitPoints;
2195 std::map<int, int> SplitLength;
2197 int intPrevValue = 7;
2200 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2204 PropertyType PropType = PROPERTY_NONE;
2206 // Look for type before continuing.
2208 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2210 std::map<int, wxString> *EmailList = NULL;
2211 std::map<int, wxString> *EmailListType = NULL;
2212 std::map<int, wxString> *EmailListAltID = NULL;
2213 std::map<int, wxString> *EmailListPID = NULL;
2214 std::map<int, wxString> *EmailListTokens = NULL;
2215 std::map<int, int> *EmailListPref = NULL;
2219 EmailList = &GeneralEmailList;
2220 EmailListType = &GeneralEmailListType;
2221 EmailListAltID = &GeneralEmailListAltID;
2222 EmailListPID = &GeneralEmailListPID;
2223 EmailListTokens = &GeneralEmailListTokens;
2224 EmailListPref = &GeneralEmailListPref;
2227 EmailList = &HomeEmailList;
2228 EmailListType = &HomeEmailListType;
2229 EmailListAltID = &HomeEmailListAltID;
2230 EmailListPID = &HomeEmailListPID;
2231 EmailListTokens = &HomeEmailListTokens;
2232 EmailListPref = &HomeEmailListPref;
2235 EmailList = &BusinessEmailList;
2236 EmailListType = &BusinessEmailListType;
2237 EmailListAltID = &BusinessEmailListAltID;
2238 EmailListPID = &BusinessEmailListPID;
2239 EmailListTokens = &BusinessEmailListTokens;
2240 EmailListPref = &BusinessEmailListPref;
2246 std::map<int,int>::iterator SLiter;
2247 wxString PropertyData;
2248 wxString PropertyName;
2249 wxString PropertyValue;
2250 wxString PropertyTokens;
2251 bool FirstToken = TRUE;
2253 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2254 intiter != SplitPoints.end(); ++intiter){
2256 SLiter = SplitLength.find(intiter->first);
2258 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2260 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2261 PropertyName = PropertyElement.GetNextToken();
2262 PropertyValue = PropertyElement.GetNextToken();
2264 intPrevValue = intiter->second;
2266 CaptureString(&PropertyValue, FALSE);
2268 // Process properties.
2270 if (PropertyName == wxT("ALTID")){
2272 EmailListAltID->erase(*EmailCount);
2273 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2275 } else if (PropertyName == wxT("PID")){
2277 EmailListPID->erase(*EmailCount);
2278 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2280 } else if (PropertyName == wxT("PREF")){
2282 int PriorityNumber = 0;
2283 bool ValidNumber = TRUE;
2286 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2289 catch(std::invalid_argument &e){
2290 ValidNumber = FALSE;
2293 if (ValidNumber == TRUE){
2295 EmailListPref->erase(*EmailCount);
2296 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2302 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2304 if (FirstToken == TRUE){
2306 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2311 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2321 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2323 // Add the name token data.
2325 if (!PropertyTokens.IsEmpty()){
2327 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2334 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2336 std::map<int, int> SplitPoints;
2337 std::map<int, int> SplitLength;
2339 int intPrevValue = 6;
2342 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2346 PropertyType PropType = PROPERTY_NONE;
2348 // Look for type before continuing.
2350 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2352 std::map<int, wxString> *IMList = NULL;
2353 std::map<int, wxString> *IMListType = NULL;
2354 std::map<int, wxString> *IMListAltID = NULL;
2355 std::map<int, wxString> *IMListPID = NULL;
2356 std::map<int, wxString> *IMListTokens = NULL;
2357 std::map<int, wxString> *IMListMediatype = NULL;
2358 std::map<int, int> *IMListPref = NULL;
2362 IMList = &GeneralIMList;
2363 IMListType = &GeneralIMListType;
2364 IMListAltID = &GeneralIMListAltID;
2365 IMListPID = &GeneralIMListPID;
2366 IMListTokens = &GeneralIMListTokens;
2367 IMListMediatype = &GeneralIMListMediatype;
2368 IMListPref = &GeneralIMListPref;
2371 IMList = &HomeIMList;
2372 IMListType = &HomeIMListType;
2373 IMListAltID = &HomeIMListAltID;
2374 IMListPID = &HomeIMListPID;
2375 IMListTokens = &HomeIMListTokens;
2376 IMListMediatype = &HomeIMListMediatype;
2377 IMListPref = &HomeIMListPref;
2380 IMList = &BusinessIMList;
2381 IMListType = &BusinessIMListType;
2382 IMListAltID = &BusinessIMListAltID;
2383 IMListPID = &BusinessIMListPID;
2384 IMListTokens = &BusinessIMListTokens;
2385 IMListMediatype = &BusinessIMListMediatype;
2386 IMListPref = &BusinessIMListPref;
2392 std::map<int,int>::iterator SLiter;
2393 wxString PropertyData;
2394 wxString PropertyName;
2395 wxString PropertyValue;
2396 wxString PropertyTokens;
2397 bool FirstToken = TRUE;
2399 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2400 intiter != SplitPoints.end(); ++intiter){
2402 SLiter = SplitLength.find(intiter->first);
2404 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2406 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2407 PropertyName = PropertyElement.GetNextToken();
2408 PropertyValue = PropertyElement.GetNextToken();
2410 intPrevValue = intiter->second;
2412 CaptureString(&PropertyValue, FALSE);
2414 // Process properties.
2416 if (PropertyName == wxT("ALTID")){
2418 IMListAltID->erase(*IMCount);
2419 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2421 } else if (PropertyName == wxT("PID")){
2423 IMListPID->erase(*IMCount);
2424 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2426 } else if (PropertyName == wxT("MEDIATYPE")){
2428 IMListMediatype->erase(*IMCount);
2429 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2431 } else if (PropertyName == wxT("PREF")){
2433 int PriorityNumber = 0;
2434 bool ValidNumber = TRUE;
2437 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2440 catch(std::invalid_argument &e){
2441 ValidNumber = FALSE;
2444 if (ValidNumber == TRUE){
2446 IMListPref->erase(*IMCount);
2447 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2453 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2455 if (FirstToken == TRUE){
2457 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2462 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2472 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2474 // Add the name token data.
2476 if (!PropertyTokens.IsEmpty()){
2478 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2484 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2486 std::map<int, int> SplitPoints;
2487 std::map<int, int> SplitLength;
2488 std::map<int, int>::iterator SLiter;
2492 PropertyType PropType = PROPERTY_NONE;
2494 // Look for type before continuing.
2497 wxString TelTypeDetail;
2498 wxString PropertyData;
2499 wxString PropertyName;
2500 wxString PropertyValue;
2501 wxString PropertyTokens;
2503 std::map<int,int> TypeSplitPoints;
2504 std::map<int,int> TypeSplitLength;
2505 std::map<int,int>::iterator TSLiter;
2507 int intSplitSize = 0;
2508 int intSplitsFound = 0;
2509 int intSplitPoint = 0;
2511 int intPrevValue = 5;
2513 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2517 // Look for type before continuing.
2519 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2520 intiter != SplitPoints.end(); ++intiter){
2522 SLiter = SplitLength.find(intiter->first);
2524 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2526 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2527 PropertyName = PropertyElement.GetNextToken();
2528 PropertyValue = PropertyElement.GetNextToken();
2530 intPrevValue = intiter->second;
2532 if (PropertyName == wxT("TYPE")){
2534 // Process each value in type and translate each
2537 // Strip out the quotes if they are there.
2539 size_t intPropertyValueLen = PropertyValue.Len();
2541 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2543 PropertyValue.Trim();
2544 PropertyValue.RemoveLast();
2548 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2550 PropertyValue.Remove(0, 1);
2554 TelTypeDetail = PropertyValue;
2560 for (int i = 0; i <= intPropertyValueLen; i++){
2564 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2566 if (intSplitsFound == 0){
2568 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2569 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2573 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2574 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2587 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2588 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2590 int intTypeSeek = 0;
2592 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2593 typeiter != TypeSplitPoints.end(); ++typeiter){
2595 wxString TypePropertyName;
2597 TSLiter = TypeSplitLength.find(typeiter->first);
2599 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2601 if (intTypeSeek == 0){
2606 TelTypeUI.Append(wxT(","));
2610 if (TypePropertyName == wxT("home")){
2612 PropType = PROPERTY_HOME;
2614 } else if (TypePropertyName == wxT("work")){
2616 PropType = PROPERTY_WORK;
2621 if (TypePropertyName == wxT("text")){
2623 TelTypeUI.Append(_("text"));
2626 } else if (TypePropertyName == wxT("voice")){
2628 TelTypeUI.Append(_("voice"));
2631 } else if (TypePropertyName == wxT("fax")){
2633 TelTypeUI.Append(_("fax"));
2636 } else if (TypePropertyName == wxT("cell")){
2638 TelTypeUI.Append(_("mobile"));
2641 } else if (TypePropertyName == wxT("video")){
2643 TelTypeUI.Append(_("video"));
2646 } else if (TypePropertyName == wxT("pager")){
2648 TelTypeUI.Append(_("pager"));
2651 } else if (TypePropertyName == wxT("textphone")){
2653 TelTypeUI.Append(_("textphone"));
2664 std::map<int, wxString> *TelephoneList = NULL;
2665 std::map<int, wxString> *TelephoneListType = NULL;
2666 std::map<int, wxString> *TelephoneListAltID = NULL;
2667 std::map<int, wxString> *TelephoneListPID = NULL;
2668 std::map<int, wxString> *TelephoneListTokens = NULL;
2669 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2670 std::map<int, int> *TelephoneListPref = NULL;
2674 TelephoneList = &GeneralTelephoneList;
2675 TelephoneListType = &GeneralTelephoneListType;
2676 TelephoneListAltID = &GeneralTelephoneListAltID;
2677 TelephoneListPID = &GeneralTelephoneListPID;
2678 TelephoneListTokens = &GeneralTelephoneListTokens;
2679 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2680 TelephoneListPref = &GeneralTelephoneListPref;
2683 TelephoneList = &HomeTelephoneList;
2684 TelephoneListType = &HomeTelephoneListType;
2685 TelephoneListAltID = &HomeTelephoneListAltID;
2686 TelephoneListPID = &HomeTelephoneListPID;
2687 TelephoneListTokens = &HomeTelephoneListTokens;
2688 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2689 TelephoneListPref = &HomeTelephoneListPref;
2692 TelephoneList = &BusinessTelephoneList;
2693 TelephoneListType = &BusinessTelephoneListType;
2694 TelephoneListAltID = &BusinessTelephoneListAltID;
2695 TelephoneListPID = &BusinessTelephoneListPID;
2696 TelephoneListTokens = &BusinessTelephoneListTokens;
2697 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2698 TelephoneListPref = &BusinessTelephoneListPref;
2702 // Process the properties.
2704 bool FirstToken = TRUE;
2707 SplitPoints.clear();
2708 SplitLength.clear();
2710 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2714 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2715 intiter != SplitPoints.end(); ++intiter){
2717 SLiter = SplitLength.find(intiter->first);
2719 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2721 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2722 PropertyName = PropertyElement.GetNextToken();
2723 PropertyValue = PropertyElement.GetNextToken();
2725 intPrevValue = intiter->second;
2727 CaptureString(&PropertyValue, FALSE);
2729 // Process properties.
2731 if (PropertyName == wxT("ALTID")){
2733 TelephoneListAltID->erase(*TelephoneCount);
2734 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2736 } else if (PropertyName == wxT("PID")){
2738 TelephoneListPID->erase(*TelephoneCount);
2739 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2741 } else if (PropertyName == wxT("PREF")){
2743 int PriorityNumber = 0;
2744 bool ValidNumber = TRUE;
2747 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2750 catch(std::invalid_argument &e){
2751 ValidNumber = FALSE;
2754 if (ValidNumber == TRUE){
2756 TelephoneListPref->erase(*TelephoneCount);
2757 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2763 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2765 if (FirstToken == TRUE){
2767 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2772 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2782 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2783 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2785 // Add the name token data.
2787 if (!PropertyTokens.IsEmpty()){
2789 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2795 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2797 std::map<int, int> SplitPoints;
2798 std::map<int, int> SplitLength;
2800 int intPrevValue = 6;
2803 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2807 PropertyType PropType = PROPERTY_NONE;
2809 // Look for type before continuing.
2811 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2813 std::map<int, wxString> *LanguageList = NULL;
2814 std::map<int, wxString> *LanguageListType = NULL;
2815 std::map<int, wxString> *LanguageListAltID = NULL;
2816 std::map<int, wxString> *LanguageListPID = NULL;
2817 std::map<int, wxString> *LanguageListTokens = NULL;
2818 std::map<int, int> *LanguageListPref = NULL;
2822 LanguageList = &GeneralLanguageList;
2823 LanguageListType = &GeneralLanguageListType;
2824 LanguageListAltID = &GeneralLanguageListAltID;
2825 LanguageListPID = &GeneralLanguageListPID;
2826 LanguageListTokens = &GeneralLanguageListTokens;
2827 LanguageListPref = &GeneralLanguageListPref;
2830 LanguageList = &HomeLanguageList;
2831 LanguageListType = &HomeLanguageListType;
2832 LanguageListAltID = &HomeLanguageListAltID;
2833 LanguageListPID = &HomeLanguageListPID;
2834 LanguageListTokens = &HomeLanguageListTokens;
2835 LanguageListPref = &HomeLanguageListPref;
2838 LanguageList = &BusinessLanguageList;
2839 LanguageListType = &BusinessLanguageListType;
2840 LanguageListAltID = &BusinessLanguageListAltID;
2841 LanguageListPID = &BusinessLanguageListPID;
2842 LanguageListTokens = &BusinessLanguageListTokens;
2843 LanguageListPref = &BusinessLanguageListPref;
2849 std::map<int,int>::iterator SLiter;
2850 wxString PropertyData;
2851 wxString PropertyName;
2852 wxString PropertyValue;
2853 wxString PropertyTokens;
2854 bool FirstToken = TRUE;
2856 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2857 intiter != SplitPoints.end(); ++intiter){
2859 SLiter = SplitLength.find(intiter->first);
2861 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2863 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2864 PropertyName = PropertyElement.GetNextToken();
2865 PropertyValue = PropertyElement.GetNextToken();
2867 intPrevValue = intiter->second;
2869 CaptureString(&PropertyValue, FALSE);
2871 // Process properties.
2873 if (PropertyName == wxT("ALTID")){
2875 LanguageListAltID->erase(*LanguageCount);
2876 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2878 } else if (PropertyName == wxT("PID")){
2880 LanguageListPID->erase(*LanguageCount);
2881 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2883 } else if (PropertyName == wxT("PREF")){
2885 int PriorityNumber = 0;
2886 bool ValidNumber = TRUE;
2889 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2892 catch(std::invalid_argument &e){
2893 ValidNumber = FALSE;
2896 if (ValidNumber == TRUE){
2898 LanguageListPref->erase(*LanguageCount);
2899 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2905 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2907 if (FirstToken == TRUE){
2909 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2914 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2924 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2926 // Add the name token data.
2928 if (!PropertyTokens.IsEmpty()){
2930 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2936 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2938 std::map<int, int> SplitPoints;
2939 std::map<int, int> SplitLength;
2941 int intPrevValue = 5;
2944 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2948 PropertyType PropType = PROPERTY_NONE;
2950 // Look for type before continuing.
2952 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2954 std::map<int, wxString> *GeopositionList = NULL;
2955 std::map<int, wxString> *GeopositionListType = NULL;
2956 std::map<int, wxString> *GeopositionListAltID = NULL;
2957 std::map<int, wxString> *GeopositionListPID = NULL;
2958 std::map<int, wxString> *GeopositionListTokens = NULL;
2959 std::map<int, wxString> *GeopositionListMediatype = NULL;
2960 std::map<int, int> *GeopositionListPref = NULL;
2964 GeopositionList = &GeneralGeographyList;
2965 GeopositionListType = &GeneralGeographyListType;
2966 GeopositionListAltID = &GeneralGeographyListAltID;
2967 GeopositionListPID = &GeneralGeographyListPID;
2968 GeopositionListTokens = &GeneralGeographyListTokens;
2969 GeopositionListMediatype = &GeneralGeographyListMediatype;
2970 GeopositionListPref = &GeneralGeographyListPref;
2973 GeopositionList = &HomeGeographyList;
2974 GeopositionListType = &HomeGeographyListType;
2975 GeopositionListAltID = &HomeGeographyListAltID;
2976 GeopositionListPID = &HomeGeographyListPID;
2977 GeopositionListTokens = &HomeGeographyListTokens;
2978 GeopositionListMediatype = &HomeGeographyListMediatype;
2979 GeopositionListPref = &HomeGeographyListPref;
2982 GeopositionList = &BusinessGeographyList;
2983 GeopositionListType = &BusinessGeographyListType;
2984 GeopositionListAltID = &BusinessGeographyListAltID;
2985 GeopositionListPID = &BusinessGeographyListPID;
2986 GeopositionListTokens = &BusinessGeographyListTokens;
2987 GeopositionListMediatype = &BusinessGeographyListMediatype;
2988 GeopositionListPref = &BusinessGeographyListPref;
2994 std::map<int,int>::iterator SLiter;
2995 wxString PropertyData;
2996 wxString PropertyName;
2997 wxString PropertyValue;
2998 wxString PropertyTokens;
2999 bool FirstToken = TRUE;
3001 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3002 intiter != SplitPoints.end(); ++intiter){
3004 SLiter = SplitLength.find(intiter->first);
3006 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3008 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3009 PropertyName = PropertyElement.GetNextToken();
3010 PropertyValue = PropertyElement.GetNextToken();
3012 intPrevValue = intiter->second;
3014 CaptureString(&PropertyValue, FALSE);
3016 // Process properties.
3018 if (PropertyName == wxT("ALTID")){
3020 GeopositionListAltID->erase(*GeographicCount);
3021 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
3023 } else if (PropertyName == wxT("PID")){
3025 GeopositionListPID->erase(*GeographicCount);
3026 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
3028 } else if (PropertyName == wxT("MEDIATYPE")){
3030 GeopositionListMediatype->erase(*GeographicCount);
3031 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
3033 } else if (PropertyName == wxT("PREF")){
3035 int PriorityNumber = 0;
3036 bool ValidNumber = TRUE;
3039 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3042 catch(std::invalid_argument &e){
3043 ValidNumber = FALSE;
3046 if (ValidNumber == TRUE){
3048 GeopositionListPref->erase(*GeographicCount);
3049 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
3055 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3057 if (FirstToken == TRUE){
3059 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3064 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3074 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3076 // Add the name token data.
3078 if (!PropertyTokens.IsEmpty()){
3080 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3086 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3088 size_t intPropertyLen = PropertySeg1.Len();
3089 std::map<int, int> SplitPoints;
3090 std::map<int, int> SplitLength;
3091 std::map<int, int>::iterator SLiter;
3092 wxString PropertyData;
3093 wxString PropertyName;
3094 wxString PropertyValue;
3095 wxString PropertyTokens;
3096 wxString RelatedType;
3097 wxString RelatedTypeOriginal;
3098 wxString RelatedName;
3099 bool FirstToken = TRUE;
3100 int intSplitsFound = 0;
3101 int intSplitSize = 0;
3102 int intPrevValue = 9;
3106 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3110 // Look for type before continuing.
3112 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3113 intiter != SplitPoints.end(); ++intiter){
3115 SLiter = SplitLength.find(intiter->first);
3117 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3119 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3120 PropertyName = PropertyElement.GetNextToken();
3121 PropertyValue = PropertyElement.GetNextToken();
3123 intPrevValue = intiter->second;
3127 RelatedTypeOriginal = PropertyValue;
3129 if (PropertyName == wxT("TYPE")){
3131 if (PropertyValue == wxT("contact")){
3133 RelatedType = _("Contact");
3135 } else if (PropertyValue == wxT("acquaintance")){
3137 RelatedType = _("Acquaintance");
3139 } else if (PropertyValue == wxT("friend")){
3141 RelatedType = _("Friend");
3143 } else if (PropertyValue == wxT("met")){
3145 RelatedType = _("Met");
3147 } else if (PropertyValue == wxT("co-worker")){
3149 RelatedType = _("Co-worker");
3151 } else if (PropertyValue == wxT("colleague")){
3153 RelatedType = _("Colleague");
3155 } else if (PropertyValue == wxT("co-resident")){
3157 RelatedType = _("Co-resident");
3159 } else if (PropertyValue == wxT("neighbor")){
3161 RelatedType = _("Neighbour");
3163 } else if (PropertyValue == wxT("child")){
3165 RelatedType = _("Child");
3167 } else if (PropertyValue == wxT("parent")){
3169 RelatedType = _("Parent");
3171 } else if (PropertyValue == wxT("sibling")){
3173 RelatedType = _("Sibling");
3175 } else if (PropertyValue == wxT("spouse")){
3177 RelatedType = _("Spouse");
3179 } else if (PropertyValue == wxT("kin")){
3181 RelatedType = _("Kin");
3183 } else if (PropertyValue == wxT("muse")){
3185 RelatedType = _("Muse");
3187 } else if (PropertyValue == wxT("crush")){
3189 RelatedType = _("Crush");
3191 } else if (PropertyValue == wxT("date")){
3193 RelatedType = _("Date");
3195 } else if (PropertyValue == wxT("sweetheart")){
3197 RelatedType = _("Sweetheart");
3199 } else if (PropertyValue == wxT("me")){
3201 RelatedType = _("Me");
3203 } else if (PropertyValue == wxT("agent")){
3205 RelatedType = _("Agent");
3207 } else if (PropertyValue == wxT("emergency")){
3209 RelatedType = _("Emergency");
3213 RelatedType = PropertyValue;
3223 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3224 intiter != SplitPoints.end(); ++intiter){
3226 SLiter = SplitLength.find(intiter->first);
3228 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3230 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3231 PropertyName = PropertyElement.GetNextToken();
3232 PropertyValue = PropertyElement.GetNextToken();
3234 intPrevValue = intiter->second;
3236 // Process properties.
3238 size_t intPropertyValueLen = PropertyValue.Len();
3240 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3242 PropertyValue.Trim();
3243 PropertyValue.RemoveLast();
3247 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3249 PropertyValue.Remove(0, 1);
3253 CaptureString(&PropertyValue, FALSE);
3255 if (PropertyName == wxT("ALTID")){
3257 GeneralRelatedListAltID.erase(*RelatedCount);
3258 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3260 } else if (PropertyName == wxT("PID")){
3262 GeneralRelatedListPID.erase(*RelatedCount);
3263 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3265 } else if (PropertyName == wxT("PREF")){
3267 int PriorityNumber = 0;
3268 bool ValidNumber = TRUE;
3271 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3274 catch(std::invalid_argument &e){
3275 ValidNumber = FALSE;
3278 if (ValidNumber == TRUE){
3280 GeneralRelatedListPref.erase(*RelatedCount);
3281 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3285 } else if (PropertyName == wxT("LANGUAGE")){
3287 GeneralRelatedListLanguage.erase(*RelatedCount);
3288 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3290 } else if (PropertyName != wxT("TYPE")) {
3292 // Something else we don't know about so append
3293 // to the tokens variable.
3295 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3297 if (FirstToken == TRUE){
3299 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3304 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3314 // Add the data to the General/Home/Work address variables.
3316 GeneralRelatedList.erase(*RelatedCount);
3317 GeneralRelatedListRelType.erase(*RelatedCount);
3318 GeneralRelatedListType.erase(*RelatedCount);
3319 GeneralRelatedListTokens.erase(*RelatedCount);
3320 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3321 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3322 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3323 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3327 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3329 std::map<int, int> SplitPoints;
3330 std::map<int, int> SplitLength;
3331 std::map<int, int>::iterator SLiter;
3332 wxString PropertyData;
3333 wxString PropertyName;
3334 wxString PropertyValue;
3335 wxString PropertyTokens;
3336 bool FirstToken = TRUE;
3337 int intPrevValue = 5;
3342 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3346 PropertyType PropType = PROPERTY_NONE;
3348 // Look for type before continuing.
3350 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3352 // Setup the pointers.
3354 std::map<int, wxString> *WebsiteList = NULL;
3355 std::map<int, wxString> *WebsiteListAltID = NULL;
3356 std::map<int, wxString> *WebsiteListPID = NULL;
3357 std::map<int, wxString> *WebsiteListType = NULL;
3358 std::map<int, wxString> *WebsiteListTokens = NULL;
3359 std::map<int, wxString> *WebsiteListMediatype = NULL;
3360 std::map<int, int> *WebsiteListPref = NULL;
3362 // Setup blank lines for later on.
3366 WebsiteList = &GeneralWebsiteList;
3367 WebsiteListType = &GeneralWebsiteListType;
3368 WebsiteListAltID = &GeneralWebsiteListAltID;
3369 WebsiteListPID = &GeneralWebsiteListPID;
3370 WebsiteListTokens = &GeneralWebsiteListTokens;
3371 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3372 WebsiteListPref = &GeneralWebsiteListPref;
3375 WebsiteList = &HomeWebsiteList;
3376 WebsiteListType = &HomeWebsiteListType;
3377 WebsiteListAltID = &HomeWebsiteListAltID;
3378 WebsiteListPID = &HomeWebsiteListPID;
3379 WebsiteListTokens = &HomeWebsiteListTokens;
3380 WebsiteListMediatype = &HomeWebsiteListMediatype;
3381 WebsiteListPref = &HomeWebsiteListPref;
3384 WebsiteList = &BusinessWebsiteList;
3385 WebsiteListType = &BusinessWebsiteListType;
3386 WebsiteListAltID = &BusinessWebsiteListAltID;
3387 WebsiteListPID = &BusinessWebsiteListPID;
3388 WebsiteListTokens = &BusinessWebsiteListTokens;
3389 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3390 WebsiteListPref = &BusinessWebsiteListPref;
3396 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3397 intiter != SplitPoints.end(); ++intiter){
3399 SLiter = SplitLength.find(intiter->first);
3401 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3403 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3404 PropertyName = PropertyElement.GetNextToken();
3405 PropertyValue = PropertyElement.GetNextToken();
3407 intPrevValue = intiter->second;
3409 // Process properties.
3411 size_t intPropertyValueLen = PropertyValue.Len();
3413 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3415 PropertyValue.Trim();
3416 PropertyValue.RemoveLast();
3420 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3422 PropertyValue.Remove(0, 1);
3426 CaptureString(&PropertyValue, FALSE);
3428 if (PropertyName == wxT("ALTID")){
3430 WebsiteListAltID->erase(*URLCount);
3431 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3433 } else if (PropertyName == wxT("PID")){
3435 WebsiteListPID->erase(*URLCount);
3436 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3438 } else if (PropertyName == wxT("PREF")){
3440 int PriorityNumber = 0;
3441 bool ValidNumber = TRUE;
3444 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3447 catch(std::invalid_argument &e){
3448 ValidNumber = FALSE;
3451 if (ValidNumber == TRUE){
3453 WebsiteListPref->erase(*URLCount);
3454 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3458 } else if (PropertyName == wxT("MEDIATYPE")){
3460 WebsiteListMediatype->erase(*URLCount);
3461 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3465 // Something else we don't know about so append
3466 // to the tokens variable.
3468 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3470 if (FirstToken == TRUE){
3472 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3477 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3487 // Add the data to the General/Home/Work address variables.
3489 CaptureString(&PropertySeg2, FALSE);
3491 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3493 if (!PropertyTokens.IsEmpty()){
3495 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3501 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3503 std::map<int, int> SplitPoints;
3504 std::map<int, int> SplitLength;
3505 std::map<int, int>::iterator SLiter;
3506 wxString PropertyData;
3507 wxString PropertyName;
3508 wxString PropertyValue;
3509 wxString PropertyTokens;
3510 bool FirstToken = TRUE;
3511 int intPrevValue = 7;
3516 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3520 PropertyType PropType = PROPERTY_NONE;
3522 // Look for type before continuing.
3524 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3526 // Setup the pointers.
3528 std::map<int, wxString> *TitleList = NULL;
3529 std::map<int, wxString> *TitleListAltID = NULL;
3530 std::map<int, wxString> *TitleListPID = NULL;
3531 std::map<int, wxString> *TitleListType = NULL;
3532 std::map<int, wxString> *TitleListTokens = NULL;
3533 std::map<int, wxString> *TitleListLanguage = NULL;
3534 std::map<int, int> *TitleListPref = NULL;
3536 // Setup blank lines for later on.
3540 TitleList = &GeneralTitleList;
3541 TitleListType = &GeneralTitleListType;
3542 TitleListAltID = &GeneralTitleListAltID;
3543 TitleListPID = &GeneralTitleListPID;
3544 TitleListTokens = &GeneralTitleListTokens;
3545 TitleListLanguage = &GeneralTitleListLanguage;
3546 TitleListPref = &GeneralTitleListPref;
3549 TitleList = &HomeTitleList;
3550 TitleListType = &HomeTitleListType;
3551 TitleListAltID = &HomeTitleListAltID;
3552 TitleListPID = &HomeTitleListPID;
3553 TitleListTokens = &HomeTitleListTokens;
3554 TitleListLanguage = &HomeTitleListLanguage;
3555 TitleListPref = &HomeTitleListPref;
3558 TitleList = &BusinessTitleList;
3559 TitleListType = &BusinessTitleListType;
3560 TitleListAltID = &BusinessTitleListAltID;
3561 TitleListPID = &BusinessTitleListPID;
3562 TitleListTokens = &BusinessTitleListTokens;
3563 TitleListLanguage = &BusinessTitleListLanguage;
3564 TitleListPref = &BusinessTitleListPref;
3570 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3571 intiter != SplitPoints.end(); ++intiter){
3573 SLiter = SplitLength.find(intiter->first);
3575 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3577 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3578 PropertyName = PropertyElement.GetNextToken();
3579 PropertyValue = PropertyElement.GetNextToken();
3581 intPrevValue = intiter->second;
3583 // Process properties.
3585 size_t intPropertyValueLen = PropertyValue.Len();
3587 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3589 PropertyValue.Trim();
3590 PropertyValue.RemoveLast();
3594 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3596 PropertyValue.Remove(0, 1);
3600 CaptureString(&PropertyValue, FALSE);
3602 if (PropertyName == wxT("ALTID")){
3604 TitleListAltID->erase(*TitleCount);
3605 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3607 } else if (PropertyName == wxT("PID")){
3609 TitleListPID->erase(*TitleCount);
3610 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3612 } else if (PropertyName == wxT("PREF")){
3614 int PriorityNumber = 0;
3615 bool ValidNumber = TRUE;
3618 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3621 catch(std::invalid_argument &e){
3622 ValidNumber = FALSE;
3625 if (ValidNumber == TRUE){
3627 TitleListPref->erase(*TitleCount);
3628 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3632 } else if (PropertyName == wxT("LANGUAGE")){
3634 TitleListLanguage->erase(*TitleCount);
3635 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3639 // Something else we don't know about so append
3640 // to the tokens variable.
3642 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3644 if (FirstToken == TRUE){
3646 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3651 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3661 // Add the data to the General/Home/Work address variables.
3663 CaptureString(&PropertySeg2, FALSE);
3665 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3667 if (!PropertyTokens.IsEmpty()){
3669 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3675 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3677 std::map<int, int> SplitPoints;
3678 std::map<int, int> SplitLength;
3679 std::map<int, int>::iterator SLiter;
3680 wxString PropertyData;
3681 wxString PropertyName;
3682 wxString PropertyValue;
3683 wxString PropertyTokens;
3684 bool FirstToken = TRUE;
3685 int intPrevValue = 6;
3690 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3694 PropertyType PropType = PROPERTY_NONE;
3696 // Look for type before continuing.
3698 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3700 // Setup the pointers.
3702 std::map<int, wxString> *RoleList = NULL;
3703 std::map<int, wxString> *RoleListAltID = NULL;
3704 std::map<int, wxString> *RoleListPID = NULL;
3705 std::map<int, wxString> *RoleListType = NULL;
3706 std::map<int, wxString> *RoleListTokens = NULL;
3707 std::map<int, wxString> *RoleListLanguage = NULL;
3708 std::map<int, int> *RoleListPref = NULL;
3710 // Setup blank lines for later on.
3714 RoleList = &GeneralRoleList;
3715 RoleListType = &GeneralRoleListType;
3716 RoleListAltID = &GeneralRoleListAltID;
3717 RoleListPID = &GeneralRoleListPID;
3718 RoleListTokens = &GeneralRoleListTokens;
3719 RoleListLanguage = &GeneralRoleListLanguage;
3720 RoleListPref = &GeneralRoleListPref;
3723 RoleList = &HomeRoleList;
3724 RoleListType = &HomeRoleListType;
3725 RoleListAltID = &HomeRoleListAltID;
3726 RoleListPID = &HomeRoleListPID;
3727 RoleListTokens = &HomeRoleListTokens;
3728 RoleListLanguage = &HomeRoleListLanguage;
3729 RoleListPref = &HomeRoleListPref;
3732 RoleList = &BusinessRoleList;
3733 RoleListType = &BusinessRoleListType;
3734 RoleListAltID = &BusinessRoleListAltID;
3735 RoleListPID = &BusinessRoleListPID;
3736 RoleListTokens = &BusinessRoleListTokens;
3737 RoleListLanguage = &BusinessRoleListLanguage;
3738 RoleListPref = &BusinessRoleListPref;
3744 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3745 intiter != SplitPoints.end(); ++intiter){
3747 SLiter = SplitLength.find(intiter->first);
3749 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3751 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3752 PropertyName = PropertyElement.GetNextToken();
3753 PropertyValue = PropertyElement.GetNextToken();
3755 intPrevValue = intiter->second;
3757 // Process properties.
3759 size_t intPropertyValueLen = PropertyValue.Len();
3761 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3763 PropertyValue.Trim();
3764 PropertyValue.RemoveLast();
3768 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3770 PropertyValue.Remove(0, 1);
3774 CaptureString(&PropertyValue, FALSE);
3776 if (PropertyName == wxT("ALTID")){
3778 RoleListAltID->erase(*RoleCount);
3779 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3781 } else if (PropertyName == wxT("PID")){
3783 RoleListPID->erase(*RoleCount);
3784 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3786 } else if (PropertyName == wxT("PREF")){
3788 int PriorityNumber = 0;
3789 bool ValidNumber = TRUE;
3792 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3795 catch(std::invalid_argument &e){
3796 ValidNumber = FALSE;
3799 if (ValidNumber == TRUE){
3801 RoleListPref->erase(*RoleCount);
3802 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3806 } else if (PropertyName == wxT("LANGUAGE")){
3808 RoleListLanguage->erase(*RoleCount);
3809 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3813 // Something else we don't know about so append
3814 // to the tokens variable.
3816 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3818 if (FirstToken == TRUE){
3820 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3825 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3835 // Add the data to the General/Home/Work address variables.
3837 CaptureString(&PropertySeg2, FALSE);
3839 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3841 if (!PropertyTokens.IsEmpty()){
3843 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3849 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3851 std::map<int, int> SplitPoints;
3852 std::map<int, int> SplitLength;
3853 std::map<int, int>::iterator SLiter;
3854 wxString PropertyData;
3855 wxString PropertyName;
3856 wxString PropertyValue;
3857 wxString PropertyTokens;
3858 bool FirstToken = TRUE;
3859 int intPrevValue = 5;
3864 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3868 PropertyType PropType = PROPERTY_NONE;
3870 // Look for type before continuing.
3872 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3874 // Setup the pointers.
3876 std::map<int, wxString> *OrganisationsList = NULL;
3877 std::map<int, wxString> *OrganisationsListAltID = NULL;
3878 std::map<int, wxString> *OrganisationsListPID = NULL;
3879 std::map<int, wxString> *OrganisationsListType = NULL;
3880 std::map<int, wxString> *OrganisationsListTokens = NULL;
3881 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3882 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3883 std::map<int, int> *OrganisationsListPref = NULL;
3885 // Setup blank lines for later on.
3889 OrganisationsList = &GeneralOrganisationsList;
3890 OrganisationsListType = &GeneralOrganisationsListType;
3891 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3892 OrganisationsListPID = &GeneralOrganisationsListPID;
3893 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3894 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3895 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3896 OrganisationsListPref = &GeneralOrganisationsListPref;
3899 OrganisationsList = &HomeOrganisationsList;
3900 OrganisationsListType = &HomeOrganisationsListType;
3901 OrganisationsListAltID = &HomeOrganisationsListAltID;
3902 OrganisationsListPID = &HomeOrganisationsListPID;
3903 OrganisationsListTokens = &HomeOrganisationsListTokens;
3904 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3905 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3906 OrganisationsListPref = &HomeOrganisationsListPref;
3909 OrganisationsList = &BusinessOrganisationsList;
3910 OrganisationsListType = &BusinessOrganisationsListType;
3911 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3912 OrganisationsListPID = &BusinessOrganisationsListPID;
3913 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3914 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3915 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3916 OrganisationsListPref = &BusinessOrganisationsListPref;
3922 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3923 intiter != SplitPoints.end(); ++intiter){
3925 SLiter = SplitLength.find(intiter->first);
3927 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3929 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3930 PropertyName = PropertyElement.GetNextToken();
3931 PropertyValue = PropertyElement.GetNextToken();
3933 intPrevValue = intiter->second;
3935 // Process properties.
3937 size_t intPropertyValueLen = PropertyValue.Len();
3939 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3941 PropertyValue.Trim();
3942 PropertyValue.RemoveLast();
3946 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3948 PropertyValue.Remove(0, 1);
3952 CaptureString(&PropertyValue, FALSE);
3954 if (PropertyName == wxT("ALTID")){
3956 OrganisationsListAltID->erase(*OrganisationCount);
3957 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3959 } else if (PropertyName == wxT("PID")){
3961 OrganisationsListPID->erase(*OrganisationCount);
3962 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3964 } else if (PropertyName == wxT("SORT-AS")){
3966 OrganisationsListSortAs->erase(*OrganisationCount);
3967 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3969 } else if (PropertyName == wxT("PREF")){
3971 int PriorityNumber = 0;
3972 bool ValidNumber = TRUE;
3975 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3978 catch(std::invalid_argument &e){
3979 ValidNumber = FALSE;
3982 if (ValidNumber == TRUE){
3984 OrganisationsListPref->erase(*OrganisationCount);
3985 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3989 } else if (PropertyName == wxT("LANGUAGE")){
3991 OrganisationsListLanguage->erase(*OrganisationCount);
3992 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3996 // Something else we don't know about so append
3997 // to the tokens variable.
3999 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4001 if (FirstToken == TRUE){
4003 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4008 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4018 // Add the data to the General/Home/Work address variables.
4020 CaptureString(&PropertySeg2, FALSE);
4022 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
4024 if (!PropertyTokens.IsEmpty()){
4026 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
4032 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
4034 std::map<int, int> SplitPoints;
4035 std::map<int, int> SplitLength;
4036 std::map<int, int>::iterator SLiter;
4037 wxString PropertyData;
4038 wxString PropertyName;
4039 wxString PropertyValue;
4040 wxString PropertyTokens;
4041 bool FirstToken = TRUE;
4042 int intPrevValue = 6;
4047 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4051 PropertyType PropType = PROPERTY_NONE;
4053 // Look for type before continuing.
4055 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4057 // Setup the pointers.
4059 std::map<int, wxString> *NoteList = NULL;
4060 std::map<int, wxString> *NoteListAltID = NULL;
4061 std::map<int, wxString> *NoteListPID = NULL;
4062 std::map<int, wxString> *NoteListType = NULL;
4063 std::map<int, wxString> *NoteListTokens = NULL;
4064 std::map<int, wxString> *NoteListLanguage = NULL;
4065 std::map<int, int> *NoteListPref = NULL;
4067 // Setup blank lines for later on.
4071 NoteList = &GeneralNoteList;
4072 NoteListType = &GeneralNoteListType;
4073 NoteListAltID = &GeneralNoteListAltID;
4074 NoteListPID = &GeneralNoteListPID;
4075 NoteListTokens = &GeneralNoteListTokens;
4076 NoteListLanguage = &GeneralNoteListLanguage;
4077 NoteListPref = &GeneralNoteListPref;
4080 NoteList = &HomeNoteList;
4081 NoteListType = &HomeNoteListType;
4082 NoteListAltID = &HomeNoteListAltID;
4083 NoteListPID = &HomeNoteListPID;
4084 NoteListTokens = &HomeNoteListTokens;
4085 NoteListLanguage = &HomeNoteListLanguage;
4086 NoteListPref = &HomeNoteListPref;
4089 NoteList = &BusinessNoteList;
4090 NoteListType = &BusinessNoteListType;
4091 NoteListAltID = &BusinessNoteListAltID;
4092 NoteListPID = &BusinessNoteListPID;
4093 NoteListTokens = &BusinessNoteListTokens;
4094 NoteListLanguage = &BusinessNoteListLanguage;
4095 NoteListPref = &BusinessNoteListPref;
4101 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4102 intiter != SplitPoints.end(); ++intiter){
4104 SLiter = SplitLength.find(intiter->first);
4106 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4108 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4109 PropertyName = PropertyElement.GetNextToken();
4110 PropertyValue = PropertyElement.GetNextToken();
4112 intPrevValue = intiter->second;
4114 // Process properties.
4116 size_t intPropertyValueLen = PropertyValue.Len();
4118 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4120 PropertyValue.Trim();
4121 PropertyValue.RemoveLast();
4125 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4127 PropertyValue.Remove(0, 1);
4131 CaptureString(&PropertyValue, FALSE);
4133 if (PropertyName == wxT("ALTID")){
4135 NoteListAltID->erase(*NoteCount);
4136 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4138 } else if (PropertyName == wxT("PID")){
4140 NoteListPID->erase(*NoteCount);
4141 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4143 } else if (PropertyName == wxT("PREF")){
4145 int PriorityNumber = 0;
4146 bool ValidNumber = TRUE;
4149 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4152 catch(std::invalid_argument &e){
4153 ValidNumber = FALSE;
4156 if (ValidNumber == TRUE){
4158 NoteListPref->erase(*NoteCount);
4159 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4163 } else if (PropertyName == wxT("LANGUAGE")){
4165 NoteListLanguage->erase(*NoteCount);
4166 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4170 // Something else we don't know about so append
4171 // to the tokens variable.
4173 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4175 if (FirstToken == TRUE){
4177 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4182 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4192 // Add the data to the General/Home/Work address variables.
4194 CaptureString(&PropertySeg2, FALSE);
4196 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4198 if (!PropertyTokens.IsEmpty()){
4200 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4206 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4208 std::map<int, int> SplitPoints;
4209 std::map<int, int> SplitLength;
4210 std::map<int, int>::iterator SLiter;
4211 wxString PropertyData;
4212 wxString PropertyName;
4213 wxString PropertyValue;
4214 wxString PropertyTokens;
4215 bool FirstToken = TRUE;
4216 int intPrevValue = 12;
4221 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4225 PropertyType PropType = PROPERTY_NONE;
4227 // Look for type before continuing.
4229 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4231 // Setup blank lines for later on.
4237 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4240 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4246 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4247 intiter != SplitPoints.end(); ++intiter){
4249 SLiter = SplitLength.find(intiter->first);
4251 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4253 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4254 PropertyName = PropertyElement.GetNextToken();
4255 PropertyValue = PropertyElement.GetNextToken();
4257 intPrevValue = intiter->second;
4259 // Process properties.
4261 size_t intPropertyValueLen = PropertyValue.Len();
4263 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4265 PropertyValue.Trim();
4266 PropertyValue.RemoveLast();
4270 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4272 PropertyValue.Remove(0, 1);
4276 CaptureString(&PropertyValue, FALSE);
4278 if (PropertyName == wxT("ALTID")){
4280 CategoriesListAltID.erase(*CategoryCount);
4281 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4283 } else if (PropertyName == wxT("PID")){
4285 CategoriesListPID.erase(*CategoryCount);
4286 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4288 } else if (PropertyName == wxT("PREF")){
4290 int PriorityNumber = 0;
4291 bool ValidNumber = TRUE;
4294 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4297 catch(std::invalid_argument &e){
4298 ValidNumber = FALSE;
4301 if (ValidNumber == TRUE){
4303 CategoriesListPref.erase(*CategoryCount);
4304 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4308 } else if (PropertyName == wxT("LANGUAGE")){
4310 CategoriesListLanguage.erase(*CategoryCount);
4311 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4315 // Something else we don't know about so append
4316 // to the tokens variable.
4318 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4320 if (FirstToken == TRUE){
4322 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4327 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4337 // Deal with multiple categories.
4339 int intOrigCatCount = *CategoryCount;
4340 bool FirstCategoryProcessed = TRUE;
4341 bool AfterFirstToken = FALSE;
4342 int intSplitSize = 0;
4343 int intSplitsFound = 0;
4344 int intSplitSeek = 0;
4345 int intPropertyLen = PropertySeg2.Len();
4347 SplitPoints.clear();
4348 SplitLength.clear();
4351 for (int i = 0; i <= intPropertyLen; i++){
4353 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4361 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4363 if (AfterFirstToken == TRUE){
4365 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4366 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4370 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4371 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4372 AfterFirstToken = TRUE;
4384 if (SplitPoints.size() > 0){
4386 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4387 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4391 if (SplitPoints.size() == 0){
4393 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4395 if (!PropertyTokens.IsEmpty()){
4397 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4403 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4404 intiter != SplitPoints.end(); ++intiter){
4406 SLiter = SplitLength.find(intiter->first);
4408 intPrevValue = intiter->second;
4410 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4412 // Add the data to the General/Home/Work address variables.
4414 // Trim any whitespace from the start and end.
4416 PropertyData = PropertyData.Trim(FALSE);
4417 PropertyData = PropertyData.Trim(TRUE);
4419 CaptureString(&PropertyData, FALSE);
4421 if (FirstCategoryProcessed == TRUE){
4423 FirstCategoryProcessed = FALSE;
4425 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4427 if (!PropertyTokens.IsEmpty()){
4429 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4439 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4441 if (!PropertyTokens.IsEmpty()){
4443 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4449 // Copy the properties to each of the categories (if it exists).
4451 if (!PropertyTokens.IsEmpty()){
4453 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4457 // Check if ALTID was used.
4459 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4461 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4465 // Check if PID was used.
4467 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4469 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4473 // Check if PREF was used.
4475 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4477 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4481 // Check if LANGUAGE was used.
4483 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4485 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4489 // Check if TYPE was used.
4495 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4498 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4506 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4508 size_t intPropertyLen = PropertySeg1.Len();
4509 std::map<int, int> SplitPoints;
4510 std::map<int, int> SplitLength;
4511 std::map<int, int>::iterator SLiter;
4512 wxString PropertyData;
4513 wxString PropertyName;
4514 wxString PropertyValue;
4515 wxString PropertyTokens;
4516 bool FirstToken = TRUE;
4517 int intSplitsFound = 0;
4518 int intSplitSize = 0;
4519 int intPrevValue = 7;
4523 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4527 PropertyType PropType = PROPERTY_NONE;
4529 // Look for type before continuing.
4531 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4535 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4536 intiter != SplitPoints.end(); ++intiter){
4538 SLiter = SplitLength.find(intiter->first);
4540 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4542 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4543 PropertyName = PropertyElement.GetNextToken();
4544 PropertyValue = PropertyElement.GetNextToken();
4546 intPrevValue = intiter->second;
4548 // Process properties.
4550 size_t intPropertyValueLen = PropertyValue.Len();
4552 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4554 PropertyValue.Trim();
4555 PropertyValue.RemoveLast();
4559 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4561 PropertyValue.Remove(0, 1);
4565 CaptureString(&PropertyValue, FALSE);
4567 if (PropertyName == wxT("ALTID")){
4569 PicturesListAltID.erase(*PhotoCount);
4570 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4572 } else if (PropertyName == wxT("PID")){
4574 PicturesListPID.erase(*PhotoCount);
4575 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4577 } else if (PropertyName == wxT("PREF")){
4579 int PriorityNumber = 0;
4580 bool ValidNumber = TRUE;
4583 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4586 catch(std::invalid_argument &e){
4587 ValidNumber = FALSE;
4590 if (ValidNumber == TRUE){
4592 PicturesListPref.erase(*PhotoCount);
4593 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4597 } else if (PropertyName == wxT("MEDIATYPE")){
4599 PicturesListMediatype.erase(*PhotoCount);
4600 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4604 // Something else we don't know about so append
4605 // to the tokens variable.
4607 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4609 if (FirstToken == TRUE){
4611 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4616 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4626 intPropertyLen = PropertySeg2.Len();
4627 SplitPoints.clear();
4628 SplitLength.clear();
4633 CaptureString(&PropertySeg2, FALSE);
4635 for (int i = 0; i <= intPropertyLen; i++){
4639 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4642 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4644 if (intSplitsFound == 6){
4646 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4651 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4661 wxString wxSPhotoURI;
4662 wxString wxSPhotoMIME;
4663 wxString wxSPhotoEncoding;
4664 wxString wxSPhotoData;
4665 std::string base64enc;
4667 if (intSplitsFound == 0){
4671 std::map<int, int>::iterator striter;
4673 striter = SplitLength.find(1);
4675 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4677 while (wSTDataType.HasMoreTokens() == TRUE){
4679 wxSPhotoURI = wSTDataType.GetNextToken();
4680 wxSPhotoMIME = wSTDataType.GetNextToken();
4685 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4687 while (wSTDataInfo.HasMoreTokens() == TRUE){
4689 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4690 wxSPhotoData = wSTDataInfo.GetNextToken();
4691 base64enc = wxSPhotoData.mb_str();
4698 // Add the data to the General/Home/Work address variables.
4700 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4701 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4702 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4708 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4711 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4715 if (!PropertyTokens.IsEmpty()){
4717 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4723 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4725 size_t intPropertyLen = PropertySeg1.Len();
4726 std::map<int, int> SplitPoints;
4727 std::map<int, int> SplitLength;
4728 std::map<int, int>::iterator SLiter;
4729 wxString PropertyData;
4730 wxString PropertyName;
4731 wxString PropertyValue;
4732 wxString PropertyTokens;
4733 bool FirstToken = TRUE;
4734 int intSplitsFound = 0;
4735 int intSplitSize = 0;
4736 int intPrevValue = 6;
4740 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4744 PropertyType PropType = PROPERTY_NONE;
4746 // Look for type before continuing.
4748 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4752 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4753 intiter != SplitPoints.end(); ++intiter){
4755 SLiter = SplitLength.find(intiter->first);
4757 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4759 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4760 PropertyName = PropertyElement.GetNextToken();
4761 PropertyValue = PropertyElement.GetNextToken();
4763 intPrevValue = intiter->second;
4765 // Process properties.
4767 size_t intPropertyValueLen = PropertyValue.Len();
4769 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4771 PropertyValue.Trim();
4772 PropertyValue.RemoveLast();
4776 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4778 PropertyValue.Remove(0, 1);
4782 CaptureString(&PropertyValue, FALSE);
4784 if (PropertyName == wxT("ALTID")){
4786 LogosListAltID.erase(*LogoCount);
4787 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4789 } else if (PropertyName == wxT("PID")){
4791 LogosListPID.erase(*LogoCount);
4792 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4794 } else if (PropertyName == wxT("PREF")){
4796 int PriorityNumber = 0;
4797 bool ValidNumber = TRUE;
4800 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4803 catch(std::invalid_argument &e){
4804 ValidNumber = FALSE;
4807 if (ValidNumber == TRUE){
4809 LogosListPref.erase(*LogoCount);
4810 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4814 } else if (PropertyName == wxT("MEDIATYPE")){
4816 LogosListMediatype.erase(*LogoCount);
4817 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4821 // Something else we don't know about so append
4822 // to the tokens variable.
4824 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4826 if (FirstToken == TRUE){
4828 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4833 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4843 intPropertyLen = PropertySeg2.Len();
4844 SplitPoints.clear();
4845 SplitLength.clear();
4850 CaptureString(&PropertySeg2, FALSE);
4852 for (int i = 0; i <= intPropertyLen; i++){
4856 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4859 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4861 if (intSplitsFound == 6){
4863 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4868 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4878 wxString wxSPhotoURI;
4879 wxString wxSPhotoMIME;
4880 wxString wxSPhotoEncoding;
4881 wxString wxSPhotoData;
4882 std::string base64enc;
4884 if (intSplitsFound == 0){
4888 std::map<int, int>::iterator striter;
4890 striter = SplitLength.find(1);
4892 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4894 while (wSTDataType.HasMoreTokens() == TRUE){
4896 wxSPhotoURI = wSTDataType.GetNextToken();
4897 wxSPhotoMIME = wSTDataType.GetNextToken();
4902 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4904 while (wSTDataInfo.HasMoreTokens() == TRUE){
4906 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4907 wxSPhotoData = wSTDataInfo.GetNextToken();
4908 base64enc = wxSPhotoData.mb_str();
4915 // Add the data to the General/Home/Work address variables.
4917 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4918 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4919 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4925 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4928 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4932 if (!PropertyTokens.IsEmpty()){
4934 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4940 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4942 size_t intPropertyLen = PropertySeg1.Len();
4943 std::map<int, int> SplitPoints;
4944 std::map<int, int> SplitLength;
4945 std::map<int, int>::iterator SLiter;
4946 wxString PropertyData;
4947 wxString PropertyName;
4948 wxString PropertyValue;
4949 wxString PropertyTokens;
4950 bool FirstToken = TRUE;
4951 int intSplitsFound = 0;
4952 int intSplitSize = 0;
4953 int intPrevValue = 7;
4957 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4961 PropertyType PropType = PROPERTY_NONE;
4963 // Look for type before continuing.
4965 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4969 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4970 intiter != SplitPoints.end(); ++intiter){
4972 SLiter = SplitLength.find(intiter->first);
4974 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4976 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4977 PropertyName = PropertyElement.GetNextToken();
4978 PropertyValue = PropertyElement.GetNextToken();
4980 intPrevValue = intiter->second;
4982 // Process properties.
4984 size_t intPropertyValueLen = PropertyValue.Len();
4986 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4988 PropertyValue.Trim();
4989 PropertyValue.RemoveLast();
4993 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4995 PropertyValue.Remove(0, 1);
4999 CaptureString(&PropertyValue, FALSE);
5001 if (PropertyName == wxT("ALTID")){
5003 SoundsListAltID.erase(*SoundCount);
5004 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
5006 } else if (PropertyName == wxT("PID")){
5008 SoundsListPID.erase(*SoundCount);
5009 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
5011 } else if (PropertyName == wxT("PREF")){
5013 int PriorityNumber = 0;
5014 bool ValidNumber = TRUE;
5017 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5020 catch(std::invalid_argument &e){
5021 ValidNumber = FALSE;
5024 if (ValidNumber == TRUE){
5026 SoundsListPref.erase(*SoundCount);
5027 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
5031 } else if (PropertyName == wxT("MEDIATYPE")){
5033 SoundsListMediatype.erase(*SoundCount);
5034 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
5036 } else if (PropertyName == wxT("LANGUAGE")){
5038 SoundsListLanguage.erase(*SoundCount);
5039 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
5043 // Something else we don't know about so append
5044 // to the tokens variable.
5046 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5048 if (FirstToken == TRUE){
5050 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5055 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5065 intPropertyLen = PropertySeg2.Len();
5066 SplitPoints.clear();
5067 SplitLength.clear();
5072 CaptureString(&PropertySeg2, FALSE);
5074 for (int i = 0; i <= intPropertyLen; i++){
5078 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5081 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5083 if (intSplitsFound == 6){
5085 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5090 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5100 wxString wxSSoundURI;
5101 wxString wxSSoundMIME;
5102 wxString wxSSoundEncoding;
5103 wxString wxSSoundData;
5104 std::string base64enc;
5106 if (intSplitsFound == 0){
5110 std::map<int, int>::iterator striter;
5112 striter = SplitLength.find(1);
5114 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5116 while (wSTDataType.HasMoreTokens() == TRUE){
5118 wxSSoundURI = wSTDataType.GetNextToken();
5119 wxSSoundMIME = wSTDataType.GetNextToken();
5124 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5126 while (wSTDataInfo.HasMoreTokens() == TRUE){
5128 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5129 wxSSoundData = wSTDataInfo.GetNextToken();
5130 base64enc = wxSSoundData.mb_str();
5137 // Add the data to the General/Home/Work address variables.
5143 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5146 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5150 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5151 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5152 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5154 if (!PropertyTokens.IsEmpty()){
5156 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5162 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5164 size_t intPropertyLen = PropertySeg1.Len();
5165 std::map<int, int> SplitPoints;
5166 std::map<int, int> SplitLength;
5167 std::map<int, int>::iterator SLiter;
5168 wxString PropertyData;
5169 wxString PropertyName;
5170 wxString PropertyValue;
5171 wxString PropertyTokens;
5172 bool FirstToken = TRUE;
5173 int intSplitsFound = 0;
5174 int intSplitSize = 0;
5175 int intPrevValue = 8;
5179 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5183 PropertyType PropType = PROPERTY_NONE;
5185 // Look for type before continuing.
5187 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5191 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5192 intiter != SplitPoints.end(); ++intiter){
5194 SLiter = SplitLength.find(intiter->first);
5196 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5198 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5199 PropertyName = PropertyElement.GetNextToken();
5200 PropertyValue = PropertyElement.GetNextToken();
5202 intPrevValue = intiter->second;
5204 // Process properties.
5206 size_t intPropertyValueLen = PropertyValue.Len();
5208 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5210 PropertyValue.Trim();
5211 PropertyValue.RemoveLast();
5215 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5217 PropertyValue.Remove(0, 1);
5221 CaptureString(&PropertyValue, FALSE);
5223 if (PropertyName == wxT("ALTID")){
5225 CalendarListAltID.erase(*CalURICount);
5226 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5228 } else if (PropertyName == wxT("PID")){
5230 CalendarListPID.erase(*CalURICount);
5231 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5233 } else if (PropertyName == wxT("PREF")){
5235 int PriorityNumber = 0;
5236 bool ValidNumber = TRUE;
5239 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5242 catch(std::invalid_argument &e){
5243 ValidNumber = FALSE;
5246 if (ValidNumber == TRUE){
5248 CalendarListPref.erase(*CalURICount);
5249 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5253 } else if (PropertyName == wxT("MEDIATYPE")){
5255 CalendarListMediatype.erase(*CalURICount);
5256 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5260 // Something else we don't know about so append
5261 // to the tokens variable.
5263 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5265 if (FirstToken == TRUE){
5267 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5272 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5282 intPropertyLen = PropertySeg2.Len();
5283 SplitPoints.clear();
5284 SplitLength.clear();
5289 CaptureString(&PropertySeg2, FALSE);
5291 // Add the data to the General/Home/Work address variables.
5297 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5300 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5304 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5306 if (!PropertyTokens.IsEmpty()){
5308 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5314 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5316 size_t intPropertyLen = PropertySeg1.Len();
5317 std::map<int, int> SplitPoints;
5318 std::map<int, int> SplitLength;
5319 std::map<int, int>::iterator SLiter;
5320 wxString PropertyData;
5321 wxString PropertyName;
5322 wxString PropertyValue;
5323 wxString PropertyTokens;
5324 bool FirstToken = TRUE;
5325 int intSplitsFound = 0;
5326 int intSplitSize = 0;
5327 int intPrevValue = 8;
5331 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5335 PropertyType PropType = PROPERTY_NONE;
5337 // Look for type before continuing.
5339 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5343 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5344 intiter != SplitPoints.end(); ++intiter){
5346 SLiter = SplitLength.find(intiter->first);
5348 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5350 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5351 PropertyName = PropertyElement.GetNextToken();
5352 PropertyValue = PropertyElement.GetNextToken();
5354 intPrevValue = intiter->second;
5356 // Process properties.
5358 size_t intPropertyValueLen = PropertyValue.Len();
5360 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5362 PropertyValue.Trim();
5363 PropertyValue.RemoveLast();
5367 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5369 PropertyValue.Remove(0, 1);
5373 CaptureString(&PropertyValue, FALSE);
5375 if (PropertyName == wxT("ALTID")){
5377 CalendarRequestListAltID.erase(*CalAdrURICount);
5378 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5380 } else if (PropertyName == wxT("PID")){
5382 CalendarRequestListPID.erase(*CalAdrURICount);
5383 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5385 } else if (PropertyName == wxT("PREF")){
5387 int PriorityNumber = 0;
5388 bool ValidNumber = TRUE;
5391 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5394 catch(std::invalid_argument &e){
5395 ValidNumber = FALSE;
5398 if (ValidNumber == TRUE){
5400 CalendarRequestListPref.erase(*CalAdrURICount);
5401 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5405 } else if (PropertyName == wxT("MEDIATYPE")){
5407 CalendarRequestListMediatype.erase(*CalAdrURICount);
5408 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5412 // Something else we don't know about so append
5413 // to the tokens variable.
5415 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5417 if (FirstToken == TRUE){
5419 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5424 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5434 intPropertyLen = PropertySeg2.Len();
5435 SplitPoints.clear();
5436 SplitLength.clear();
5441 CaptureString(&PropertySeg2, FALSE);
5443 // Add the data to the General/Home/Work address variables.
5449 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5452 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5456 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5458 if (!PropertyTokens.IsEmpty()){
5460 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5466 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5468 size_t intPropertyLen = PropertySeg1.Len();
5469 std::map<int, int> SplitPoints;
5470 std::map<int, int> SplitLength;
5471 std::map<int, int>::iterator SLiter;
5472 wxString PropertyData;
5473 wxString PropertyName;
5474 wxString PropertyValue;
5475 wxString PropertyTokens;
5476 bool FirstToken = TRUE;
5477 int intSplitsFound = 0;
5478 int intSplitSize = 0;
5479 int intPrevValue = 7;
5483 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5487 PropertyType PropType = PROPERTY_NONE;
5489 // Look for type before continuing.
5491 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5495 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5496 intiter != SplitPoints.end(); ++intiter){
5498 SLiter = SplitLength.find(intiter->first);
5500 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5502 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5503 PropertyName = PropertyElement.GetNextToken();
5504 PropertyValue = PropertyElement.GetNextToken();
5506 intPrevValue = intiter->second;
5508 // Process properties.
5510 size_t intPropertyValueLen = PropertyValue.Len();
5512 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5514 PropertyValue.Trim();
5515 PropertyValue.RemoveLast();
5519 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5521 PropertyValue.Remove(0, 1);
5525 CaptureString(&PropertyValue, FALSE);
5527 if (PropertyName == wxT("ALTID")){
5529 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5530 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5532 } else if (PropertyName == wxT("PID")){
5534 FreeBusyListPID.erase(*FreeBusyAddressCount);
5535 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5537 } else if (PropertyName == wxT("PREF")){
5539 int PriorityNumber = 0;
5540 bool ValidNumber = TRUE;
5543 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5546 catch(std::invalid_argument &e){
5547 ValidNumber = FALSE;
5550 if (ValidNumber == TRUE){
5552 FreeBusyListPref.erase(*FreeBusyAddressCount);
5553 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5557 } else if (PropertyName == wxT("MEDIATYPE")){
5559 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5560 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5564 // Something else we don't know about so append
5565 // to the tokens variable.
5567 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5569 if (FirstToken == TRUE){
5571 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5576 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5586 intPropertyLen = PropertySeg2.Len();
5587 SplitPoints.clear();
5588 SplitLength.clear();
5593 CaptureString(&PropertySeg2, FALSE);
5595 // Add the data to the General/Home/Work address variables.
5601 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5604 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5608 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5610 if (!PropertyTokens.IsEmpty()){
5612 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5618 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5620 size_t intPropertyLen = PropertySeg1.Len();
5621 std::map<int, int> SplitPoints;
5622 std::map<int, int> SplitLength;
5623 std::map<int, int>::iterator SLiter;
5624 wxString PropertyData;
5625 wxString PropertyName;
5626 wxString PropertyValue;
5627 wxString PropertyTokens;
5628 bool FirstToken = TRUE;
5629 int intSplitsFound = 0;
5630 int intSplitSize = 0;
5631 int intPrevValue = 5;
5636 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5640 PropertyType PropType = PROPERTY_NONE;
5642 // Look for type before continuing.
5644 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5648 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5649 intiter != SplitPoints.end(); ++intiter){
5651 SLiter = SplitLength.find(intiter->first);
5653 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5655 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5656 PropertyName = PropertyElement.GetNextToken();
5657 PropertyValue = PropertyElement.GetNextToken();
5659 intPrevValue = intiter->second;
5661 // Process properties.
5663 size_t intPropertyValueLen = PropertyValue.Len();
5665 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5667 PropertyValue.Trim();
5668 PropertyValue.RemoveLast();
5672 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5674 PropertyValue.Remove(0, 1);
5678 if (PropertyName == wxT("ALTID")){
5680 KeyListAltID.erase(*KeyCount);
5681 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5683 } else if (PropertyName == wxT("PID")){
5685 KeyListPID.erase(*KeyCount);
5686 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5688 } else if (PropertyName == wxT("PREF")){
5690 int PriorityNumber = 0;
5691 bool ValidNumber = TRUE;
5694 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5697 catch(std::invalid_argument &e){
5698 ValidNumber = FALSE;
5701 if (ValidNumber == TRUE){
5703 KeyListPref.erase(*KeyCount);
5704 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5710 // Something else we don't know about so append
5711 // to the tokens variable.
5713 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5715 if (FirstToken == TRUE){
5717 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5722 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5732 intPropertyLen = PropertySeg2.Len();
5733 SplitPoints.clear();
5734 SplitLength.clear();
5739 for (int i = 0; i <= intPropertyLen; i++){
5743 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5746 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5748 if (intSplitsFound == 6){
5750 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5755 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5766 wxString wxSKeyMIME;
5767 wxString wxSKeyEncoding;
5768 wxString wxSKeyData;
5769 std::string base64enc;
5771 if (intSplitsFound == 0){
5775 std::map<int, int>::iterator striter;
5777 striter = SplitLength.find(1);
5779 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5781 while (wSTDataType.HasMoreTokens() == TRUE){
5783 wxSKeyURI = wSTDataType.GetNextToken();
5784 wxSKeyMIME = wSTDataType.GetNextToken();
5789 if (wxSKeyURI == wxT("data")){
5791 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5793 while (wSTDataInfo.HasMoreTokens() == TRUE){
5795 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5796 wxSKeyData = wSTDataInfo.GetNextToken();
5805 // Add the data to the General/Home/Work address variables.
5807 if (wxSKeyURI == wxT("data")){
5809 KeyListDataEncType.erase(*KeyCount);
5810 KeyListKeyType.erase(*KeyCount);
5811 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5812 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5814 KeyList.erase(*KeyCount);
5815 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5819 KeyList.erase(*KeyCount);
5820 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5824 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5830 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5833 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5837 if (!PropertyTokens.IsEmpty()){
5839 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5845 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5847 // Split the Vendor three ways.
5849 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5852 wxString wxSVNDPropName;
5855 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5857 wSTVendorDetails.GetNextToken();
5858 wxSVNDID = wSTVendorDetails.GetNextToken();
5859 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5864 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5866 // Add the data to the vendor variables.
5868 VendorList.erase(*VendorCount);
5869 VendorListPEN.erase(*VendorCount);
5870 VendorListElement.erase(*VendorCount);
5872 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5873 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5874 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5880 void ProcessIntegerValue(ContactDataObject *ContactData,
5881 std::map<int,int> *KeyListPref,
5882 wxString *PropertyValue,
5885 int PriorityNumber = 0;
5886 bool ValidNumber = TRUE;
5889 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5892 catch(std::invalid_argument &e){
5893 ValidNumber = FALSE;
5896 if (ValidNumber == TRUE){
5898 KeyListPref->erase(*KeyCount);
5899 KeyListPref->insert(std::make_pair(*KeyCount, PriorityNumber));
5905 void SplitValues(wxString *PropertyLine,
5906 std::map<int,int> *SplitPoints,
5907 std::map<int,int> *SplitLength,
5910 size_t intPropertyLen = PropertyLine->Len();
5911 int intSplitsFound = 0;
5912 int intSplitSize = 0;
5913 int intSplitSeek = 0;
5915 for (int i = intSize; i <= intPropertyLen; i++){
5919 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5920 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5922 if (intSplitsFound == 0){
5924 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5928 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5932 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5942 if (intSplitsFound == 0){
5944 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5945 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5949 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5950 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5956 void CheckType(wxString *PropertySeg1,
5957 std::map<int,int> *SplitPoints,
5958 std::map<int,int> *SplitLength,
5960 PropertyType *PropType){
5962 wxString PropertyData;
5963 wxString PropertyName;
5964 wxString PropertyValue;
5965 std::map<int,int>::iterator SLiter;
5967 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5968 intiter != SplitPoints->end(); ++intiter){
5970 SLiter = SplitLength->find(intiter->first);
5972 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5974 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5975 PropertyName = PropertyElement.GetNextToken();
5976 PropertyValue = PropertyElement.GetNextToken();
5978 *intPrevValue = intiter->second;
5980 if (PropertyName == wxT("TYPE")){
5982 if (PropertyValue == wxT("work")){
5984 *PropType = PROPERTY_WORK;
5986 } else if (PropertyValue == wxT("home")){
5988 *PropType = PROPERTY_HOME;
5992 *PropType = PROPERTY_NONE;