1 // ContactDataObject.cpp - Client Data Object.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 bool UIDProcessed = FALSE;
82 bool RevisionProcessed = FALSE;
83 int ContactLineLen = 0;
84 int QuoteBreakPoint = 0;
88 int NicknameCount = 0;
89 int TimeZoneCount = 0;
93 int TelephoneCount = 0;
94 int LanguageCount = 0;
95 int GeographicCount = 0;
100 int OrganisationCount = 0;
102 int CategoryCount = 0;
106 int CalendarCount = 0;
107 int CalendarAddressCount = 0;
108 int FreeBusyAddressCount = 0;
113 int ClientPIDCount = 0;
114 wxString ContactLine;
115 wxString PropertyLine;
116 wxString PropertySeg1;
117 wxString PropertySeg2;
118 wxString PropertyNextLine;
121 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
122 iter != ContactFileLines.end(); ++iter){
124 ExtraLineSeek = TRUE;
130 PropertyLine.Clear();
131 PropertySeg1.Clear();
132 PropertySeg2.Clear();
135 ContactLine = iter->second;
137 while (ExtraLineSeek == TRUE){
139 // Check if there is extra data on the next line
140 // (indicated by space or tab at the start) and add data.
144 if (iter == ContactFileLines.end()){
151 PropertyNextLine = iter->second;
153 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
155 PropertyNextLine.Remove(0, 1);
156 ContactLine.Append(PropertyNextLine);
161 ExtraLineSeek = FALSE;
167 ContactLineLen = ContactLine.Len();
169 // Make sure we are not in quotation mode.
170 // Make sure colon does not have \ or \\ before it.
172 for (int i = 0; i <= ContactLineLen; i++){
174 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
176 PropertyFind = FALSE;
178 } else if (PropertyFind == TRUE){
180 Property.Append(ContactLine.Mid(i, 1));
184 if (ContactLine.Mid(i, 1) == wxT("\"")){
186 if (QuoteMode == TRUE){
198 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
207 // Split that line at the point into two variables (ignore the colon).
209 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
212 if (Property == wxT("KIND") && KindProcessed == FALSE){
214 ProcessKind(PropertySeg2);
216 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
218 UIDToken = PropertySeg2;
221 } else if (Property == wxT("SOURCE")){
223 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
226 } else if (Property == wxT("XML")){
228 ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
231 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
233 ProcessRevision(PropertySeg1, PropertySeg2);
234 RevisionProcessed = TRUE;
236 } else if (Property == wxT("MEMBER")){
238 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
241 } else if (Property == wxT("FN")){
243 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
246 } else if (Property == wxT("N") && NameProcessed == FALSE){
248 ProcessN(PropertySeg1, PropertySeg2);
249 NameProcessed = TRUE;
251 } else if (Property == wxT("CLIENTPIDMAP")){
253 ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
256 } else if (Property == wxT("NICKNAME")){
258 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
261 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
263 ProcessGender(PropertySeg1, PropertySeg2);
264 GenderProcessed = TRUE;
266 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
268 ProcessBirthday(PropertySeg1, PropertySeg2);
269 BirthdayProcessed = TRUE;
271 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
273 ProcessAnniversary(PropertySeg1, PropertySeg2);
274 AnniversaryProcessed = TRUE;
276 } else if (Property == wxT("TZ")){
278 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
281 } else if (Property == wxT("ADR")){
283 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
286 } else if (Property == wxT("EMAIL")){
288 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
291 } else if (Property == wxT("IMPP")){
293 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
296 } else if (Property == wxT("TEL")){
298 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
301 } else if (Property == wxT("LANG")){
303 // See frmContactEditor-LoadLanguage.cpp
305 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
308 } else if (Property == wxT("GEO")){
310 // See frmContactEditor-LoadGeo.cpp
312 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
315 } else if (Property == wxT("RELATED")){
317 // See fromContactEditor-LoadRelated.cpp
319 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
322 } else if (Property == wxT("URL")){
324 // See frmContactEditor-LoadURL.cpp
326 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
329 } else if (Property == wxT("TITLE")) {
331 // See frmContactEditor-LoadTitle.cpp
333 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
336 } else if (Property == wxT("ROLE")) {
338 // See frmContactEditor-LoadTitle.cpp
340 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
343 } else if (Property == wxT("ORG")) {
345 // See frmContactEditor-LoadOrg.cpp
347 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
350 } else if (Property == wxT("NOTE")) {
352 // See frmContactEditor-LoadNote.cpp
354 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
357 } else if (Property == wxT("CATEGORIES")) {
359 // See frmContactEditor-LoadCategory.cpp
361 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
364 } else if (Property == wxT("PHOTO")) {
366 // See frmContactEditor-LoadPhoto.cpp
368 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
371 } else if (Property == wxT("LOGO")) {
373 // See frmContactEditor-LoadPhoto.cpp
375 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
378 } else if (Property == wxT("LOGO")) {
380 // See frmContactEditor-LoadPhoto.cpp
382 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
385 } else if (Property == wxT("SOUND")) {
387 // See frmContactEditor-LoadSound.cpp
389 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
392 } else if (Property == wxT("CALURI")){
394 // See frmContactEditor-LoadCalendar.cpp
396 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
399 } else if (Property == wxT("CALADRURI")){
401 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402 CalendarAddressCount++;
404 } else if (Property == wxT("FBURL")){
406 // See frmContactEditor-LoadCalendar.cpp
408 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409 FreeBusyAddressCount++;
411 } else if (Property == wxT("KEY")){
413 // See frmContactEditor-LoadKey.cpp
415 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
418 } else if (Property.Mid(0, 3) == wxT("VND")){
420 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
423 } else if (Property.Mid(0, 2) == wxT("X-")){
425 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
433 return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439 if (KindType == wxT("individual")){
441 ContactKind = CONTACTKIND_INDIVIDUAL;
443 } else if (KindType == wxT("group")){
445 ContactKind = CONTACTKIND_GROUP;
447 } else if (KindType == wxT("org")){
449 ContactKind = CONTACTKIND_ORGANISATION;
451 } else if (KindType == wxT("location")){
453 ContactKind = CONTACTKIND_LOCATION;
457 ContactKind = CONTACTKIND_NONE;
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464 size_t intPropertyLen = PropertySeg1.Len();
465 std::map<int, int> SplitPoints;
466 std::map<int, int> SplitLength;
467 std::map<int, int>::iterator SLiter;
468 wxString PropertyData;
469 wxString PropertyName;
470 wxString PropertyValue;
471 wxString PropertyTokens;
472 bool FirstToken = TRUE;
473 int intSplitsFound = 0;
474 int intSplitSize = 0;
475 int intPrevValue = 5;
479 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
483 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
484 intiter != SplitPoints.end(); ++intiter){
486 SLiter = SplitLength.find(intiter->first);
488 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
490 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
491 PropertyName = PropertyElement.GetNextToken();
492 PropertyValue = PropertyElement.GetNextToken();
494 intPrevValue = intiter->second;
496 // Process properties.
498 size_t intPropertyValueLen = PropertyValue.Len();
500 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
502 PropertyValue.Trim();
503 PropertyValue.RemoveLast();
507 if (PropertyValue.Mid(0, 1) == wxT("\"")){
509 PropertyValue.Remove(0, 1);
513 CaptureString(&PropertyValue, FALSE);
515 if (FirstToken == TRUE){
517 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
522 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
528 CaptureString(&PropertySeg2, FALSE);
530 Revision = PropertySeg2;
532 if (!PropertyTokens.IsEmpty()){
534 RevisionTokens = PropertyTokens;
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543 size_t intPropertyLen = PropertySeg1.Len();
544 std::map<int, int> SplitPoints;
545 std::map<int, int> SplitLength;
546 std::map<int, int>::iterator SLiter;
547 wxString PropertyData;
548 wxString PropertyName;
549 wxString PropertyValue;
550 wxString PropertyTokens;
551 bool FirstToken = TRUE;
552 int intSplitsFound = 0;
553 int intSplitSize = 0;
554 int intPrevValue = 8;
558 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
562 PropertyType PropType = PROPERTY_NONE;
564 // Look for type before continuing.
566 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
570 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
571 intiter != SplitPoints.end(); ++intiter){
573 SLiter = SplitLength.find(intiter->first);
575 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
577 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
578 PropertyName = PropertyElement.GetNextToken();
579 PropertyValue = PropertyElement.GetNextToken();
581 intPrevValue = intiter->second;
583 // Process properties.
585 size_t intPropertyValueLen = PropertyValue.Len();
587 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
589 PropertyValue.Trim();
590 PropertyValue.RemoveLast();
594 if (PropertyValue.Mid(0, 1) == wxT("\"")){
596 PropertyValue.Remove(0, 1);
600 CaptureString(&PropertyValue, FALSE);
602 if (PropertyName == wxT("ALTID")){
604 SourceListAltID.erase(*SourceCount);
605 SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
607 } else if (PropertyName == wxT("PID")){
609 SourceListPID.erase(*SourceCount);
610 SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
612 } else if (PropertyName == wxT("PREF")){
614 ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount);
616 } else if (PropertyName == wxT("MEDIATYPE")){
618 SourceListMediatype.erase(*SourceCount);
619 SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
623 // Something else we don't know about so append
624 // to the tokens variable.
626 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
628 if (FirstToken == TRUE){
630 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
635 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
645 intPropertyLen = PropertySeg2.Len();
652 CaptureString(&PropertySeg2, FALSE);
654 // Add the data to the General/Home/Work address variables.
660 SourceListType.insert(std::make_pair(*SourceCount, "home"));
663 SourceListType.insert(std::make_pair(*SourceCount, "work"));
667 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
669 if (!PropertyTokens.IsEmpty()){
671 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
677 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
679 std::map<int, int> SplitPoints;
680 std::map<int, int> SplitLength;
682 int intPrevValue = 5;
686 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
690 wxString PropertyName;
691 wxString PropertyValue;
692 wxString PropertyData;
693 wxString PropertyTokens;
694 std::map<int,int>::iterator SLiter;
695 bool FirstToken = TRUE;
697 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
698 intiter != SplitPoints.end(); ++intiter){
700 SLiter = SplitLength.find(intiter->first);
702 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
704 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
705 PropertyName = PropertyElement.GetNextToken();
706 PropertyValue = PropertyElement.GetNextToken();
708 intPrevValue = intiter->second;
710 CaptureString(&PropertyValue, FALSE);
712 if (PropertyName == wxT("ALTID")){
714 XMLListAltID.erase(*XMLCount);
715 XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
721 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
725 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
727 std::map<int, int> SplitPoints;
728 std::map<int, int> SplitLength;
730 int intPrevValue = 8;
734 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
738 wxString PropertyName;
739 wxString PropertyValue;
740 wxString PropertyData;
741 wxString PropertyTokens;
742 std::map<int,int>::iterator SLiter;
743 bool FirstToken = TRUE;
745 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
746 intiter != SplitPoints.end(); ++intiter){
748 SLiter = SplitLength.find(intiter->first);
750 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
752 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
753 PropertyName = PropertyElement.GetNextToken();
754 PropertyValue = PropertyElement.GetNextToken();
756 intPrevValue = intiter->second;
758 CaptureString(&PropertyValue, FALSE);
760 if (PropertyName == wxT("ALTID")){
762 GroupsListAltID.erase(*GroupCount);
763 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
765 } else if (PropertyName == wxT("PID")){
767 GroupsListPID.erase(*GroupCount);
768 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
770 } else if (PropertyName == wxT("PREF")){
772 ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount);
774 } else if (PropertyName == wxT("MEDIATYPE")){
776 GroupsListMediaType.erase(*GroupCount);
777 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
779 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
781 if (FirstToken == TRUE){
783 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
788 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
796 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
798 if (!PropertyTokens.IsEmpty()){
800 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
807 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
809 std::map<int, int> SplitPoints;
810 std::map<int, int> SplitLength;
812 int intPrevValue = 4;
816 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
820 wxString PropertyName;
821 wxString PropertyValue;
822 wxString PropertyData;
823 wxString PropertyTokens;
824 std::map<int,int>::iterator SLiter;
825 bool FirstToken = TRUE;
827 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
828 intiter != SplitPoints.end(); ++intiter){
830 SLiter = SplitLength.find(intiter->first);
832 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
834 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
835 PropertyName = PropertyElement.GetNextToken();
836 PropertyValue = PropertyElement.GetNextToken();
838 intPrevValue = intiter->second;
840 CaptureString(&PropertyValue, FALSE);
842 if (PropertyName == wxT("TYPE")){
844 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
845 PropertyValue == wxT("work") ){
847 FullNamesListType.erase(*FNCount);
848 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
852 } else if (PropertyName == wxT("LANGUAGE")){
854 FullNamesListLanguage.erase(*FNCount);
855 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
857 } else if (PropertyName == wxT("ALTID")){
859 FullNamesListAltID.erase(*FNCount);
860 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
862 } else if (PropertyName == wxT("PID")){
864 FullNamesListPID.erase(*FNCount);
865 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
867 } else if (PropertyName == wxT("PREF")){
869 ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount);
871 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
873 if (FirstToken == TRUE){
875 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
880 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
888 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
890 if (!PropertyTokens.IsEmpty()){
892 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
898 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
900 std::map<int, int> SplitPoints;
901 std::map<int, int> SplitLength;
903 int intPrevValue = 3;
907 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
911 wxString PropertyName;
912 wxString PropertyValue;
913 wxString PropertyData;
914 wxString PropertyTokens;
915 std::map<int,int>::iterator SLiter;
916 bool FirstToken = TRUE;
918 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
919 intiter != SplitPoints.end(); ++intiter){
921 SLiter = SplitLength.find(intiter->first);
923 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
925 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
926 PropertyName = PropertyElement.GetNextToken();
927 PropertyValue = PropertyElement.GetNextToken();
929 intPrevValue = intiter->second;
931 CaptureString(&PropertyValue, FALSE);
933 if (PropertyName == wxT("ALTID")){
935 NameAltID = PropertyValue;
937 } else if (PropertyName == wxT("LANGUAGE")){
939 NameLanguage = PropertyValue;
941 } else if (PropertyName == wxT("SORT-AS")){
943 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
944 PropertyValue.Len() >= 3){
945 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
948 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
950 if (FirstToken == TRUE){
952 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
957 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
965 // Split the name data.
967 int intSplitSeek = 0;
968 int intSplitsFound = 0;
969 int intSplitSize = 0;
970 int intPropertyLen = PropertySeg2.Len();
972 std::map<int,wxString> NameValues;
975 for (int i = 0; i <= intPropertyLen; i++){
977 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
979 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
984 if (intSplitsFound == 4){
986 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1000 // Split the data into several parts.
1002 for (std::map<int, wxString>::iterator iter = NameValues.begin();
1003 iter != NameValues.end(); ++iter){
1005 if (iter->first == 1){
1007 // Deal with family name.
1009 NameSurname = iter->second;
1011 } else if (iter->first == 2){
1013 // Deal with given names.
1015 NameForename = iter->second;
1017 } else if (iter->first == 3){
1019 // Deal with additional names.
1021 NameOtherNames = iter->second;
1023 } else if (iter->first == 4){
1025 // Deal with honorifix prefixes and suffixes.
1027 NameTitle = iter->second;
1031 if (iter == NameValues.end()){
1037 NameSuffix = iter->second;
1043 // Add the name token data.
1045 if (!PropertyTokens.IsEmpty()){
1047 NameTokens = PropertyTokens;
1053 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1055 size_t intPropertyLen = PropertySeg1.Len();
1056 std::map<int, int> SplitPoints;
1057 std::map<int, int> SplitLength;
1058 std::map<int, int>::iterator SLiter;
1059 wxString PropertyData;
1060 wxString PropertyName;
1061 wxString PropertyValue;
1062 wxString PropertyTokens;
1063 bool FirstToken = TRUE;
1064 int intSplitsFound = 0;
1065 int intSplitSize = 0;
1066 int intPrevValue = 14;
1070 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1074 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1075 intiter != SplitPoints.end(); ++intiter){
1077 SLiter = SplitLength.find(intiter->first);
1079 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1081 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1082 PropertyName = PropertyElement.GetNextToken();
1083 PropertyValue = PropertyElement.GetNextToken();
1085 intPrevValue = intiter->second;
1087 // Process properties.
1089 size_t intPropertyValueLen = PropertyValue.Len();
1091 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1093 PropertyValue.Trim();
1094 PropertyValue.RemoveLast();
1098 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1100 PropertyValue.Remove(0, 1);
1104 CaptureString(&PropertyValue, FALSE);
1106 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1112 if (FirstToken == TRUE){
1114 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1119 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1125 CaptureString(&PropertySeg2, FALSE);
1127 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1129 if (!PropertyTokens.IsEmpty()){
1131 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1137 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1139 std::map<int, int> SplitPoints;
1140 std::map<int, int> SplitLength;
1142 int intPrevValue = 10;
1145 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1149 PropertyType PropType = PROPERTY_NONE;
1151 // Look for type before continuing.
1153 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1157 std::map<int, wxString> *NicknamesList = NULL;
1158 std::map<int, wxString> *NicknamesListType = NULL;
1159 std::map<int, wxString> *NicknamesListLanguage = NULL;
1160 std::map<int, wxString> *NicknamesListAltID = NULL;
1161 std::map<int, wxString> *NicknamesListPID = NULL;
1162 std::map<int, wxString> *NicknamesListTokens = NULL;
1163 std::map<int, int> *NicknamesListPref = NULL;
1167 NicknamesList = &GeneralNicknamesList;
1168 NicknamesListType = &GeneralNicknamesListType;
1169 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1170 NicknamesListAltID = &GeneralNicknamesListAltID;
1171 NicknamesListPID = &GeneralNicknamesListPID;
1172 NicknamesListTokens = &GeneralNicknamesListTokens;
1173 NicknamesListPref = &GeneralNicknamesListPref;
1176 NicknamesList = &HomeNicknamesList;
1177 NicknamesListType = &HomeNicknamesListType;
1178 NicknamesListLanguage = &HomeNicknamesListLanguage;
1179 NicknamesListAltID = &HomeNicknamesListAltID;
1180 NicknamesListPID = &HomeNicknamesListPID;
1181 NicknamesListTokens = &HomeNicknamesListTokens;
1182 NicknamesListPref = &HomeNicknamesListPref;
1185 NicknamesList = &BusinessNicknamesList;
1186 NicknamesListType = &BusinessNicknamesListType;
1187 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1188 NicknamesListAltID = &BusinessNicknamesListAltID;
1189 NicknamesListPID = &BusinessNicknamesListPID;
1190 NicknamesListTokens = &BusinessNicknamesListTokens;
1191 NicknamesListPref = &BusinessNicknamesListPref;
1195 std::map<int, int>::iterator SLiter;
1196 wxString PropertyData;
1197 wxString PropertyName;
1198 wxString PropertyValue;
1199 wxString PropertyTokens;
1200 bool FirstToken = TRUE;
1202 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1203 intiter != SplitPoints.end(); ++intiter){
1205 SLiter = SplitLength.find(intiter->first);
1207 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1209 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1210 PropertyName = PropertyElement.GetNextToken();
1211 PropertyValue = PropertyElement.GetNextToken();
1213 intPrevValue = intiter->second;
1215 CaptureString(&PropertyValue, FALSE);
1217 if (PropertyName == wxT("ALTID")){
1219 NicknamesListAltID->erase(*NicknameCount);
1220 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1222 } else if (PropertyName == wxT("PID")){
1224 NicknamesListPID->erase(*NicknameCount);
1225 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1227 } else if (PropertyName == wxT("PREF")){
1229 int PriorityNumber = 0;
1230 bool ValidNumber = TRUE;
1233 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1236 catch(std::invalid_argument &e){
1237 ValidNumber = FALSE;
1240 if (ValidNumber == TRUE){
1242 NicknamesListPref->erase(*NicknameCount);
1243 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1247 } else if (PropertyName == wxT("LANGUAGE")){
1249 NicknamesListLanguage->erase(*NicknameCount);
1250 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1254 // Something else we don't know about so append
1255 // to the tokens variable.
1257 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1259 if (FirstToken == TRUE){
1261 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1266 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1276 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1278 // Add the name token data.
1280 if (!PropertyTokens.IsEmpty()){
1282 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1288 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1290 std::map<int, int> SplitPoints;
1291 std::map<int, int> SplitLength;
1292 std::map<int, int>::iterator SLiter;
1293 wxString PropertyData;
1294 wxString PropertyName;
1295 wxString PropertyValue;
1296 wxString PropertyTokens;
1297 bool FirstToken = TRUE;
1298 int intPrevValue = 8;
1300 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1304 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1305 intiter != SplitPoints.end(); ++intiter){
1307 SLiter = SplitLength.find(intiter->first);
1309 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1311 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1312 PropertyName = PropertyElement.GetNextToken();
1313 PropertyValue = PropertyElement.GetNextToken();
1315 intPrevValue = intiter->second;
1317 // Process properties.
1319 size_t intPropertyValueLen = PropertyValue.Len();
1321 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1323 PropertyValue.Trim();
1324 PropertyValue.RemoveLast();
1328 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1330 PropertyValue.Remove(0, 1);
1334 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1336 if (FirstToken == TRUE){
1338 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1343 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1351 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1353 wxString GenderComponent;
1355 if (GenderData.CountTokens() >= 2){
1357 Gender = GenderData.GetNextToken();
1358 GenderDetails = GenderData.GetString();
1360 CaptureString(&GenderDetails, FALSE);
1364 Gender = GenderData.GetNextToken();
1368 if (!PropertyTokens.IsEmpty()){
1370 GenderTokens = PropertyTokens;
1376 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1378 // Process date. Preserve the remainder in the string.
1380 std::map<int, int> SplitPoints;
1381 std::map<int, int> SplitLength;
1382 std::map<int, int>::iterator SLiter;
1383 wxString PropertyData;
1384 wxString PropertyName;
1385 wxString PropertyValue;
1386 wxString PropertyTokens;
1387 bool BirthdayText = FALSE;
1388 int intPrevValue = 6;
1390 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1394 // Look for type before continuing.
1396 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1397 intiter != SplitPoints.end(); ++intiter){
1399 SLiter = SplitLength.find(intiter->first);
1401 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1403 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1404 PropertyName = PropertyElement.GetNextToken();
1405 PropertyValue = PropertyElement.GetNextToken();
1407 intPrevValue = intiter->second;
1409 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1411 CaptureString(&PropertySeg2, FALSE);
1412 Birthday = PropertySeg2;
1413 BirthdayText = TRUE;
1419 // Setup blank lines for later on.
1422 bool FirstToken = TRUE;
1424 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1425 intiter != SplitPoints.end(); ++intiter){
1427 SLiter = SplitLength.find(intiter->first);
1429 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1431 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1432 PropertyName = PropertyElement.GetNextToken();
1433 PropertyValue = PropertyElement.GetNextToken();
1435 intPrevValue = intiter->second;
1437 // Process properties.
1439 CaptureString(&PropertyValue, FALSE);
1441 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1443 PropertyValue.Trim();
1444 PropertyValue.RemoveLast();
1448 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1450 PropertyValue.Remove(0, 1);
1454 if (PropertyName == wxT("ALTID")){
1456 BirthdayAltID = PropertyValue;
1458 } else if (PropertyName == wxT("CALSCALE")){
1460 BirthdayCalScale = PropertyValue;
1462 } else if (PropertyName != wxT("VALUE")) {
1464 // Something else we don't know about so append
1465 // to the tokens variable.
1467 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1469 if (FirstToken == TRUE){
1471 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1476 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1486 // Add the data to the variables and form.
1488 if (BirthdayText == FALSE){
1490 Birthday = PropertySeg2;
1494 if (!PropertyTokens.IsEmpty()){
1496 BirthdayTokens = PropertyTokens;
1502 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1504 // Process date. Preserve the remainder in the string.
1506 std::map<int, int> SplitPoints;
1507 std::map<int, int> SplitLength;
1508 std::map<int, int>::iterator SLiter;
1509 wxString PropertyData;
1510 wxString PropertyName;
1511 wxString PropertyValue;
1512 wxString PropertyTokens;
1513 bool AnniversaryText = FALSE;
1514 int intPrevValue = 13;
1516 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1520 // Look for type before continuing.
1522 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1523 intiter != SplitPoints.end(); ++intiter){
1525 SLiter = SplitLength.find(intiter->first);
1527 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1529 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1530 PropertyName = PropertyElement.GetNextToken();
1531 PropertyValue = PropertyElement.GetNextToken();
1533 intPrevValue = intiter->second;
1535 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1537 CaptureString(&PropertySeg2, FALSE);
1538 Anniversary = PropertySeg2;
1539 AnniversaryText = TRUE;
1545 // Setup blank lines for later on.
1548 bool FirstToken = TRUE;
1550 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1551 intiter != SplitPoints.end(); ++intiter){
1553 SLiter = SplitLength.find(intiter->first);
1555 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1557 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1558 PropertyName = PropertyElement.GetNextToken();
1559 PropertyValue = PropertyElement.GetNextToken();
1561 intPrevValue = intiter->second;
1563 // Process properties.
1565 CaptureString(&PropertyValue, FALSE);
1567 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1569 PropertyValue.Trim();
1570 PropertyValue.RemoveLast();
1574 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1576 PropertyValue.Remove(0, 1);
1580 if (PropertyName == wxT("ALTID")){
1582 AnniversaryAltID = PropertyValue;
1584 } else if (PropertyName == wxT("CALSCALE")){
1586 AnniversaryCalScale = PropertyValue;
1588 } else if (PropertyName != wxT("VALUE")) {
1590 // Something else we don't know about so append
1591 // to the tokens variable.
1593 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1595 if (FirstToken == TRUE){
1597 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1602 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1612 // Add the data to the variables and form.
1614 if (AnniversaryText == FALSE){
1616 Anniversary = PropertySeg2;
1620 if (!PropertyTokens.IsEmpty()){
1622 AnniversaryTokens = PropertyTokens;
1628 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1630 std::map<int, int> SplitPoints;
1631 std::map<int, int> SplitLength;
1633 int intPrevValue = 4;
1636 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1640 PropertyType PropType = PROPERTY_NONE;
1642 // Look for type before continuing.
1644 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1648 std::map<int, wxString> *TZList = NULL;
1649 std::map<int, wxString> *TZListType = NULL;
1650 std::map<int, wxString> *TZListMediatype = NULL;
1651 std::map<int, wxString> *TZListAltID = NULL;
1652 std::map<int, wxString> *TZListPID = NULL;
1653 std::map<int, wxString> *TZListTokens = NULL;
1654 std::map<int, int> *TZListPref = NULL;
1658 TZList = &GeneralTZList;
1659 TZListType = &GeneralTZListType;
1660 TZListMediatype = &GeneralTZListMediatype;
1661 TZListAltID = &GeneralTZListAltID;
1662 TZListPID = &GeneralTZListPID;
1663 TZListTokens = &GeneralTZListTokens;
1664 TZListPref = &GeneralTZListPref;
1667 TZList = &HomeTZList;
1668 TZListType = &HomeTZListType;
1669 TZListMediatype = &HomeTZListMediatype;
1670 TZListAltID = &HomeTZListAltID;
1671 TZListPID = &HomeTZListPID;
1672 TZListTokens = &HomeTZListTokens;
1673 TZListPref = &HomeTZListPref;
1676 TZList = &BusinessTZList;
1677 TZListType = &BusinessTZListType;
1678 TZListMediatype = &BusinessTZListMediatype;
1679 TZListAltID = &BusinessTZListAltID;
1680 TZListPID = &BusinessTZListPID;
1681 TZListTokens = &BusinessTZListTokens;
1682 TZListPref = &BusinessTZListPref;
1686 std::map<int, int>::iterator SLiter;
1687 wxString PropertyData;
1688 wxString PropertyName;
1689 wxString PropertyValue;
1690 wxString PropertyTokens;
1691 bool FirstToken = TRUE;
1693 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1694 intiter != SplitPoints.end(); ++intiter){
1696 SLiter = SplitLength.find(intiter->first);
1698 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1700 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1701 PropertyName = PropertyElement.GetNextToken();
1702 PropertyValue = PropertyElement.GetNextToken();
1704 intPrevValue = intiter->second;
1706 CaptureString(&PropertyValue, FALSE);
1708 if (PropertyName == wxT("ALTID")){
1710 TZListAltID->erase(*TimeZoneCount);
1711 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1713 } else if (PropertyName == wxT("PID")){
1715 TZListPID->erase(*TimeZoneCount);
1716 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1718 } else if (PropertyName == wxT("PREF")){
1720 int PriorityNumber = 0;
1721 bool ValidNumber = TRUE;
1724 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1727 catch(std::invalid_argument &e){
1728 ValidNumber = FALSE;
1731 if (ValidNumber == TRUE){
1733 TZListPref->erase(*TimeZoneCount);
1734 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1738 } else if (PropertyName == wxT("MEDIATYPE")){
1740 TZListMediatype->erase(*TimeZoneCount);
1741 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1745 // Something else we don't know about so append
1746 // to the tokens variable.
1748 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1750 if (FirstToken == TRUE){
1752 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1757 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1767 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1769 // Add the name token data.
1771 if (!PropertyTokens.IsEmpty()){
1773 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1780 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1782 size_t intPropertyLen = PropertySeg1.Len();
1783 std::map<int, int> SplitPoints;
1784 std::map<int, int> SplitLength;
1785 std::map<int, int>::iterator SLiter;
1786 wxString PropertyData;
1787 wxString PropertyName;
1788 wxString PropertyValue;
1789 wxString PropertyTokens;
1790 wxString AddressLabel;
1791 wxString AddressLang;
1792 wxString AddressAltID;
1793 wxString AddressPID;
1794 wxString AddressTokens;
1795 wxString AddressGeo;
1796 wxString AddressTimezone;
1797 wxString AddressType;
1798 wxString AddressMediatype;
1799 wxString AddressPOBox;
1800 wxString AddressExtended;
1801 wxString AddressStreet;
1802 wxString AddressLocality;
1803 wxString AddressCity;
1804 wxString AddressRegion;
1805 wxString AddressPostalCode;
1806 wxString AddressCountry;
1807 bool FirstToken = TRUE;
1808 int intSplitsFound = 0;
1809 int intSplitSize = 0;
1810 int intPrevValue = 5;
1815 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1819 PropertyType PropType = PROPERTY_NONE;
1821 // Look for type before continuing.
1823 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1827 std::map<int, wxString> *AddressList = NULL;
1828 std::map<int, wxString> *AddressListTown = NULL;
1829 std::map<int, wxString> *AddressListCounty = NULL;
1830 std::map<int, wxString> *AddressListPostCode = NULL;
1831 std::map<int, wxString> *AddressListCountry = NULL;
1832 std::map<int, wxString> *AddressListLabel = NULL;
1833 std::map<int, wxString> *AddressListLang = NULL;
1834 std::map<int, wxString> *AddressListAltID = NULL;
1835 std::map<int, wxString> *AddressListPID = NULL;
1836 std::map<int, wxString> *AddressListTokens = NULL;
1837 std::map<int, wxString> *AddressListGeo = NULL;
1838 std::map<int, wxString> *AddressListTimezone = NULL;
1839 std::map<int, wxString> *AddressListType = NULL;
1840 std::map<int, wxString> *AddressListMediatype = NULL;
1841 std::map<int, int> *AddressListPref = NULL;
1845 AddressList = &GeneralAddressList;
1846 AddressListTown = &GeneralAddressListTown;
1847 AddressListCounty = &GeneralAddressListCounty;
1848 AddressListPostCode = &GeneralAddressListPostCode;
1849 AddressListCountry = &GeneralAddressListCountry;
1850 AddressListLabel = &GeneralAddressListLabel;
1851 AddressListLang = &GeneralAddressListLang;
1852 AddressListAltID = &GeneralAddressListAltID;
1853 AddressListPID = &GeneralAddressListPID;
1854 AddressListTokens = &GeneralAddressListTokens;
1855 AddressListGeo = &GeneralAddressListGeo;
1856 AddressListTimezone = &GeneralAddressListTimezone;
1857 AddressListType = &GeneralAddressListType;
1858 AddressListMediatype = &GeneralAddressListMediatype;
1859 AddressListPref = &GeneralAddressListPref;
1862 AddressList = &HomeAddressList;
1863 AddressListTown = &HomeAddressListTown;
1864 AddressListCounty = &HomeAddressListCounty;
1865 AddressListPostCode = &HomeAddressListPostCode;
1866 AddressListCountry = &HomeAddressListCountry;
1867 AddressListLabel = &HomeAddressListLabel;
1868 AddressListLang = &HomeAddressListLang;
1869 AddressListAltID = &HomeAddressListAltID;
1870 AddressListPID = &HomeAddressListPID;
1871 AddressListTokens = &HomeAddressListTokens;
1872 AddressListGeo = &HomeAddressListGeo;
1873 AddressListTimezone = &HomeAddressListTimezone;
1874 AddressListType = &HomeAddressListType;
1875 AddressListMediatype = &HomeAddressListMediatype;
1876 AddressListPref = &HomeAddressListPref;
1879 AddressList = &BusinessAddressList;
1880 AddressListTown = &BusinessAddressListTown;
1881 AddressListCounty = &BusinessAddressListCounty;
1882 AddressListPostCode = &BusinessAddressListPostCode;
1883 AddressListCountry = &BusinessAddressListCountry;
1884 AddressListLabel = &BusinessAddressListLabel;
1885 AddressListLang = &BusinessAddressListLang;
1886 AddressListAltID = &BusinessAddressListAltID;
1887 AddressListPID = &BusinessAddressListPID;
1888 AddressListTokens = &BusinessAddressListTokens;
1889 AddressListGeo = &BusinessAddressListGeo;
1890 AddressListTimezone = &BusinessAddressListTimezone;
1891 AddressListType = &BusinessAddressListType;
1892 AddressListMediatype = &BusinessAddressListMediatype;
1893 AddressListPref = &BusinessAddressListPref;
1899 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1900 intiter != SplitPoints.end(); ++intiter){
1902 SLiter = SplitLength.find(intiter->first);
1904 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1906 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1907 PropertyName = PropertyElement.GetNextToken();
1908 PropertyValue = PropertyElement.GetNextToken();
1910 intPrevValue = intiter->second;
1912 CaptureString(&PropertyValue, FALSE);
1914 // Process properties.
1916 if (PropertyName == wxT("LABEL")){
1918 AddressListLabel->erase(*AddressCount);
1919 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1921 } else if (PropertyName == wxT("LANGUAGE")){
1923 AddressListLang->erase(*AddressCount);
1924 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1926 } else if (PropertyName == wxT("ALTID")){
1928 AddressListAltID->erase(*AddressCount);
1929 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1931 } else if (PropertyName == wxT("PID")){
1933 AddressListPID->erase(*AddressCount);
1934 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1936 } else if (PropertyName == wxT("GEO")){
1938 AddressListGeo->erase(*AddressCount);
1939 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1941 } else if (PropertyName == wxT("TZ")){
1943 AddressListTimezone->erase(*AddressCount);
1944 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1946 } else if (PropertyName == wxT("MEDIATYPE")){
1948 AddressListMediatype->erase(*AddressCount);
1949 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1951 } else if (PropertyName == wxT("PREF")){
1953 int PriorityNumber = 0;
1954 bool ValidNumber = TRUE;
1957 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1960 catch(std::invalid_argument &e){
1961 ValidNumber = FALSE;
1964 if (ValidNumber == TRUE){
1966 AddressListPref->erase(*AddressCount);
1967 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1973 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1975 if (FirstToken == TRUE){
1977 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1982 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1992 // Split the address.
1994 //std::map<int, int>::iterator SLiter;
1995 intPropertyLen = PropertySeg2.Len();
1996 SplitPoints.clear();
1997 SplitLength.clear();
2002 for (int i = 0; i <= intPropertyLen; i++){
2006 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2009 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2011 if (intSplitsFound == 6){
2013 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2018 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2028 // Split the data into several parts.
2030 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2031 intiter != SplitPoints.end(); ++intiter){
2033 if (intiter->first == 1){
2035 // Deal with PO Box.
2037 SLiter = SplitLength.find(1);
2039 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2040 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2041 intPrevValue = intiter->second;
2043 } else if (intiter->first == 2){
2045 // Deal with extended address.
2047 SLiter = SplitLength.find(2);
2049 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2050 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2051 intPrevValue = intiter->second;
2053 } else if (intiter->first == 3){
2055 // Deal with street address.
2057 SLiter = SplitLength.find(3);
2059 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2060 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2061 intPrevValue = intiter->second;
2063 } else if (intiter->first == 4){
2065 // Deal with locality
2067 SLiter = SplitLength.find(4);
2069 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2070 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2071 intPrevValue = intiter->second;
2073 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2075 } else if (intiter->first == 5){
2077 // Deal with region.
2079 SLiter = SplitLength.find(5);
2081 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2082 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2083 intPrevValue = intiter->second;
2085 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2087 } else if (intiter->first == 6){
2089 // Deal with post code.
2091 SLiter = SplitLength.find(6);
2093 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2094 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2095 intPrevValue = intiter->second;
2097 // Deal with country.
2099 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2100 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2108 // Add the data to the General/Home/Work address variables.
2110 CaptureString(&AddressStreet, FALSE);
2111 CaptureString(&AddressLocality, FALSE);
2112 CaptureString(&AddressRegion, FALSE);
2113 CaptureString(&AddressPostalCode, FALSE);
2114 CaptureString(&AddressCountry, FALSE);
2116 if (!PropertyTokens.IsEmpty()){
2118 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2122 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2123 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2124 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2125 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2126 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2130 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2133 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2136 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2140 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2144 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2146 std::map<int, int> SplitPoints;
2147 std::map<int, int> SplitLength;
2149 int intPrevValue = 7;
2152 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2156 PropertyType PropType = PROPERTY_NONE;
2158 // Look for type before continuing.
2160 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2162 std::map<int, wxString> *EmailList = NULL;
2163 std::map<int, wxString> *EmailListType = NULL;
2164 std::map<int, wxString> *EmailListAltID = NULL;
2165 std::map<int, wxString> *EmailListPID = NULL;
2166 std::map<int, wxString> *EmailListTokens = NULL;
2167 std::map<int, int> *EmailListPref = NULL;
2171 EmailList = &GeneralEmailList;
2172 EmailListType = &GeneralEmailListType;
2173 EmailListAltID = &GeneralEmailListAltID;
2174 EmailListPID = &GeneralEmailListPID;
2175 EmailListTokens = &GeneralEmailListTokens;
2176 EmailListPref = &GeneralEmailListPref;
2179 EmailList = &HomeEmailList;
2180 EmailListType = &HomeEmailListType;
2181 EmailListAltID = &HomeEmailListAltID;
2182 EmailListPID = &HomeEmailListPID;
2183 EmailListTokens = &HomeEmailListTokens;
2184 EmailListPref = &HomeEmailListPref;
2187 EmailList = &BusinessEmailList;
2188 EmailListType = &BusinessEmailListType;
2189 EmailListAltID = &BusinessEmailListAltID;
2190 EmailListPID = &BusinessEmailListPID;
2191 EmailListTokens = &BusinessEmailListTokens;
2192 EmailListPref = &BusinessEmailListPref;
2198 std::map<int,int>::iterator SLiter;
2199 wxString PropertyData;
2200 wxString PropertyName;
2201 wxString PropertyValue;
2202 wxString PropertyTokens;
2203 bool FirstToken = TRUE;
2205 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2206 intiter != SplitPoints.end(); ++intiter){
2208 SLiter = SplitLength.find(intiter->first);
2210 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2212 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2213 PropertyName = PropertyElement.GetNextToken();
2214 PropertyValue = PropertyElement.GetNextToken();
2216 intPrevValue = intiter->second;
2218 CaptureString(&PropertyValue, FALSE);
2220 // Process properties.
2222 if (PropertyName == wxT("ALTID")){
2224 EmailListAltID->erase(*EmailCount);
2225 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2227 } else if (PropertyName == wxT("PID")){
2229 EmailListPID->erase(*EmailCount);
2230 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2232 } else if (PropertyName == wxT("PREF")){
2234 int PriorityNumber = 0;
2235 bool ValidNumber = TRUE;
2238 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2241 catch(std::invalid_argument &e){
2242 ValidNumber = FALSE;
2245 if (ValidNumber == TRUE){
2247 EmailListPref->erase(*EmailCount);
2248 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2254 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2256 if (FirstToken == TRUE){
2258 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2263 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2273 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2275 // Add the name token data.
2277 if (!PropertyTokens.IsEmpty()){
2279 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2286 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2288 std::map<int, int> SplitPoints;
2289 std::map<int, int> SplitLength;
2291 int intPrevValue = 6;
2294 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2298 PropertyType PropType = PROPERTY_NONE;
2300 // Look for type before continuing.
2302 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2304 std::map<int, wxString> *IMList = NULL;
2305 std::map<int, wxString> *IMListType = NULL;
2306 std::map<int, wxString> *IMListAltID = NULL;
2307 std::map<int, wxString> *IMListPID = NULL;
2308 std::map<int, wxString> *IMListTokens = NULL;
2309 std::map<int, wxString> *IMListMediatype = NULL;
2310 std::map<int, int> *IMListPref = NULL;
2314 IMList = &GeneralIMList;
2315 IMListType = &GeneralIMListType;
2316 IMListAltID = &GeneralIMListAltID;
2317 IMListPID = &GeneralIMListPID;
2318 IMListTokens = &GeneralIMListTokens;
2319 IMListMediatype = &GeneralIMListMediatype;
2320 IMListPref = &GeneralIMListPref;
2323 IMList = &HomeIMList;
2324 IMListType = &HomeIMListType;
2325 IMListAltID = &HomeIMListAltID;
2326 IMListPID = &HomeIMListPID;
2327 IMListTokens = &HomeIMListTokens;
2328 IMListMediatype = &HomeIMListMediatype;
2329 IMListPref = &HomeIMListPref;
2332 IMList = &BusinessIMList;
2333 IMListType = &BusinessIMListType;
2334 IMListAltID = &BusinessIMListAltID;
2335 IMListPID = &BusinessIMListPID;
2336 IMListTokens = &BusinessIMListTokens;
2337 IMListMediatype = &BusinessIMListMediatype;
2338 IMListPref = &BusinessIMListPref;
2344 std::map<int,int>::iterator SLiter;
2345 wxString PropertyData;
2346 wxString PropertyName;
2347 wxString PropertyValue;
2348 wxString PropertyTokens;
2349 bool FirstToken = TRUE;
2351 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2352 intiter != SplitPoints.end(); ++intiter){
2354 SLiter = SplitLength.find(intiter->first);
2356 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2358 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2359 PropertyName = PropertyElement.GetNextToken();
2360 PropertyValue = PropertyElement.GetNextToken();
2362 intPrevValue = intiter->second;
2364 CaptureString(&PropertyValue, FALSE);
2366 // Process properties.
2368 if (PropertyName == wxT("ALTID")){
2370 IMListAltID->erase(*IMCount);
2371 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2373 } else if (PropertyName == wxT("PID")){
2375 IMListPID->erase(*IMCount);
2376 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2378 } else if (PropertyName == wxT("MEDIATYPE")){
2380 IMListMediatype->erase(*IMCount);
2381 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2383 } else if (PropertyName == wxT("PREF")){
2385 int PriorityNumber = 0;
2386 bool ValidNumber = TRUE;
2389 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2392 catch(std::invalid_argument &e){
2393 ValidNumber = FALSE;
2396 if (ValidNumber == TRUE){
2398 IMListPref->erase(*IMCount);
2399 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2405 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2407 if (FirstToken == TRUE){
2409 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2414 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2424 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2426 // Add the name token data.
2428 if (!PropertyTokens.IsEmpty()){
2430 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2436 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2438 std::map<int, int> SplitPoints;
2439 std::map<int, int> SplitLength;
2440 std::map<int, int>::iterator SLiter;
2444 PropertyType PropType = PROPERTY_NONE;
2446 // Look for type before continuing.
2449 wxString TelTypeDetail;
2450 wxString PropertyData;
2451 wxString PropertyName;
2452 wxString PropertyValue;
2453 wxString PropertyTokens;
2455 std::map<int,int> TypeSplitPoints;
2456 std::map<int,int> TypeSplitLength;
2457 std::map<int,int>::iterator TSLiter;
2459 int intSplitSize = 0;
2460 int intSplitsFound = 0;
2461 int intSplitPoint = 0;
2463 int intPrevValue = 5;
2465 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2469 // Look for type before continuing.
2471 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2472 intiter != SplitPoints.end(); ++intiter){
2474 SLiter = SplitLength.find(intiter->first);
2476 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2478 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2479 PropertyName = PropertyElement.GetNextToken();
2480 PropertyValue = PropertyElement.GetNextToken();
2482 intPrevValue = intiter->second;
2484 if (PropertyName == wxT("TYPE")){
2486 // Process each value in type and translate each
2489 // Strip out the quotes if they are there.
2491 size_t intPropertyValueLen = PropertyValue.Len();
2493 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2495 PropertyValue.Trim();
2496 PropertyValue.RemoveLast();
2500 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2502 PropertyValue.Remove(0, 1);
2506 TelTypeDetail = PropertyValue;
2512 for (int i = 0; i <= intPropertyValueLen; i++){
2516 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2518 if (intSplitsFound == 0){
2520 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2521 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2525 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2526 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2539 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2540 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2542 int intTypeSeek = 0;
2544 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2545 typeiter != TypeSplitPoints.end(); ++typeiter){
2547 wxString TypePropertyName;
2549 TSLiter = TypeSplitLength.find(typeiter->first);
2551 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2553 if (intTypeSeek == 0){
2558 TelTypeUI.Append(wxT(","));
2562 if (TypePropertyName == wxT("home")){
2564 PropType = PROPERTY_HOME;
2566 } else if (TypePropertyName == wxT("work")){
2568 PropType = PROPERTY_WORK;
2573 if (TypePropertyName == wxT("text")){
2575 TelTypeUI.Append(_("text"));
2578 } else if (TypePropertyName == wxT("voice")){
2580 TelTypeUI.Append(_("voice"));
2583 } else if (TypePropertyName == wxT("fax")){
2585 TelTypeUI.Append(_("fax"));
2588 } else if (TypePropertyName == wxT("cell")){
2590 TelTypeUI.Append(_("mobile"));
2593 } else if (TypePropertyName == wxT("video")){
2595 TelTypeUI.Append(_("video"));
2598 } else if (TypePropertyName == wxT("pager")){
2600 TelTypeUI.Append(_("pager"));
2603 } else if (TypePropertyName == wxT("textphone")){
2605 TelTypeUI.Append(_("textphone"));
2616 std::map<int, wxString> *TelephoneList = NULL;
2617 std::map<int, wxString> *TelephoneListType = NULL;
2618 std::map<int, wxString> *TelephoneListAltID = NULL;
2619 std::map<int, wxString> *TelephoneListPID = NULL;
2620 std::map<int, wxString> *TelephoneListTokens = NULL;
2621 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2622 std::map<int, int> *TelephoneListPref = NULL;
2626 TelephoneList = &GeneralTelephoneList;
2627 TelephoneListType = &GeneralTelephoneListType;
2628 TelephoneListAltID = &GeneralTelephoneListAltID;
2629 TelephoneListPID = &GeneralTelephoneListPID;
2630 TelephoneListTokens = &GeneralTelephoneListTokens;
2631 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2632 TelephoneListPref = &GeneralTelephoneListPref;
2635 TelephoneList = &HomeTelephoneList;
2636 TelephoneListType = &HomeTelephoneListType;
2637 TelephoneListAltID = &HomeTelephoneListAltID;
2638 TelephoneListPID = &HomeTelephoneListPID;
2639 TelephoneListTokens = &HomeTelephoneListTokens;
2640 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2641 TelephoneListPref = &HomeTelephoneListPref;
2644 TelephoneList = &BusinessTelephoneList;
2645 TelephoneListType = &BusinessTelephoneListType;
2646 TelephoneListAltID = &BusinessTelephoneListAltID;
2647 TelephoneListPID = &BusinessTelephoneListPID;
2648 TelephoneListTokens = &BusinessTelephoneListTokens;
2649 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2650 TelephoneListPref = &BusinessTelephoneListPref;
2654 // Process the properties.
2656 bool FirstToken = TRUE;
2659 SplitPoints.clear();
2660 SplitLength.clear();
2662 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2666 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2667 intiter != SplitPoints.end(); ++intiter){
2669 SLiter = SplitLength.find(intiter->first);
2671 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2673 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2674 PropertyName = PropertyElement.GetNextToken();
2675 PropertyValue = PropertyElement.GetNextToken();
2677 intPrevValue = intiter->second;
2679 CaptureString(&PropertyValue, FALSE);
2681 // Process properties.
2683 if (PropertyName == wxT("ALTID")){
2685 TelephoneListAltID->erase(*TelephoneCount);
2686 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2688 } else if (PropertyName == wxT("PID")){
2690 TelephoneListPID->erase(*TelephoneCount);
2691 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2693 } else if (PropertyName == wxT("PREF")){
2695 int PriorityNumber = 0;
2696 bool ValidNumber = TRUE;
2699 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2702 catch(std::invalid_argument &e){
2703 ValidNumber = FALSE;
2706 if (ValidNumber == TRUE){
2708 TelephoneListPref->erase(*TelephoneCount);
2709 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2715 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2717 if (FirstToken == TRUE){
2719 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2724 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2734 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2735 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2737 // Add the name token data.
2739 if (!PropertyTokens.IsEmpty()){
2741 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2747 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2749 std::map<int, int> SplitPoints;
2750 std::map<int, int> SplitLength;
2752 int intPrevValue = 6;
2755 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2759 PropertyType PropType = PROPERTY_NONE;
2761 // Look for type before continuing.
2763 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2765 std::map<int, wxString> *LanguageList = NULL;
2766 std::map<int, wxString> *LanguageListType = NULL;
2767 std::map<int, wxString> *LanguageListAltID = NULL;
2768 std::map<int, wxString> *LanguageListPID = NULL;
2769 std::map<int, wxString> *LanguageListTokens = NULL;
2770 std::map<int, int> *LanguageListPref = NULL;
2774 LanguageList = &GeneralLanguageList;
2775 LanguageListType = &GeneralLanguageListType;
2776 LanguageListAltID = &GeneralLanguageListAltID;
2777 LanguageListPID = &GeneralLanguageListPID;
2778 LanguageListTokens = &GeneralLanguageListTokens;
2779 LanguageListPref = &GeneralLanguageListPref;
2782 LanguageList = &HomeLanguageList;
2783 LanguageListType = &HomeLanguageListType;
2784 LanguageListAltID = &HomeLanguageListAltID;
2785 LanguageListPID = &HomeLanguageListPID;
2786 LanguageListTokens = &HomeLanguageListTokens;
2787 LanguageListPref = &HomeLanguageListPref;
2790 LanguageList = &BusinessLanguageList;
2791 LanguageListType = &BusinessLanguageListType;
2792 LanguageListAltID = &BusinessLanguageListAltID;
2793 LanguageListPID = &BusinessLanguageListPID;
2794 LanguageListTokens = &BusinessLanguageListTokens;
2795 LanguageListPref = &BusinessLanguageListPref;
2801 std::map<int,int>::iterator SLiter;
2802 wxString PropertyData;
2803 wxString PropertyName;
2804 wxString PropertyValue;
2805 wxString PropertyTokens;
2806 bool FirstToken = TRUE;
2808 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2809 intiter != SplitPoints.end(); ++intiter){
2811 SLiter = SplitLength.find(intiter->first);
2813 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2815 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2816 PropertyName = PropertyElement.GetNextToken();
2817 PropertyValue = PropertyElement.GetNextToken();
2819 intPrevValue = intiter->second;
2821 CaptureString(&PropertyValue, FALSE);
2823 // Process properties.
2825 if (PropertyName == wxT("ALTID")){
2827 LanguageListAltID->erase(*LanguageCount);
2828 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2830 } else if (PropertyName == wxT("PID")){
2832 LanguageListPID->erase(*LanguageCount);
2833 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2835 } else if (PropertyName == wxT("PREF")){
2837 int PriorityNumber = 0;
2838 bool ValidNumber = TRUE;
2841 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2844 catch(std::invalid_argument &e){
2845 ValidNumber = FALSE;
2848 if (ValidNumber == TRUE){
2850 LanguageListPref->erase(*LanguageCount);
2851 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2857 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2859 if (FirstToken == TRUE){
2861 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2866 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2876 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2878 // Add the name token data.
2880 if (!PropertyTokens.IsEmpty()){
2882 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2888 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2890 std::map<int, int> SplitPoints;
2891 std::map<int, int> SplitLength;
2893 int intPrevValue = 5;
2896 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2900 PropertyType PropType = PROPERTY_NONE;
2902 // Look for type before continuing.
2904 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2906 std::map<int, wxString> *GeopositionList = NULL;
2907 std::map<int, wxString> *GeopositionListType = NULL;
2908 std::map<int, wxString> *GeopositionListAltID = NULL;
2909 std::map<int, wxString> *GeopositionListPID = NULL;
2910 std::map<int, wxString> *GeopositionListTokens = NULL;
2911 std::map<int, wxString> *GeopositionListMediatype = NULL;
2912 std::map<int, int> *GeopositionListPref = NULL;
2916 GeopositionList = &GeneralGeographyList;
2917 GeopositionListType = &GeneralGeographyListType;
2918 GeopositionListAltID = &GeneralGeographyListAltID;
2919 GeopositionListPID = &GeneralGeographyListPID;
2920 GeopositionListTokens = &GeneralGeographyListTokens;
2921 GeopositionListMediatype = &GeneralGeographyListMediatype;
2922 GeopositionListPref = &GeneralGeographyListPref;
2925 GeopositionList = &HomeGeographyList;
2926 GeopositionListType = &HomeGeographyListType;
2927 GeopositionListAltID = &HomeGeographyListAltID;
2928 GeopositionListPID = &HomeGeographyListPID;
2929 GeopositionListTokens = &HomeGeographyListTokens;
2930 GeopositionListMediatype = &HomeGeographyListMediatype;
2931 GeopositionListPref = &HomeGeographyListPref;
2934 GeopositionList = &BusinessGeographyList;
2935 GeopositionListType = &BusinessGeographyListType;
2936 GeopositionListAltID = &BusinessGeographyListAltID;
2937 GeopositionListPID = &BusinessGeographyListPID;
2938 GeopositionListTokens = &BusinessGeographyListTokens;
2939 GeopositionListMediatype = &BusinessGeographyListMediatype;
2940 GeopositionListPref = &BusinessGeographyListPref;
2946 std::map<int,int>::iterator SLiter;
2947 wxString PropertyData;
2948 wxString PropertyName;
2949 wxString PropertyValue;
2950 wxString PropertyTokens;
2951 bool FirstToken = TRUE;
2953 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2954 intiter != SplitPoints.end(); ++intiter){
2956 SLiter = SplitLength.find(intiter->first);
2958 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2960 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2961 PropertyName = PropertyElement.GetNextToken();
2962 PropertyValue = PropertyElement.GetNextToken();
2964 intPrevValue = intiter->second;
2966 CaptureString(&PropertyValue, FALSE);
2968 // Process properties.
2970 if (PropertyName == wxT("ALTID")){
2972 GeopositionListAltID->erase(*GeographicCount);
2973 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2975 } else if (PropertyName == wxT("PID")){
2977 GeopositionListPID->erase(*GeographicCount);
2978 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2980 } else if (PropertyName == wxT("MEDIATYPE")){
2982 GeopositionListMediatype->erase(*GeographicCount);
2983 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2985 } else if (PropertyName == wxT("PREF")){
2987 int PriorityNumber = 0;
2988 bool ValidNumber = TRUE;
2991 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2994 catch(std::invalid_argument &e){
2995 ValidNumber = FALSE;
2998 if (ValidNumber == TRUE){
3000 GeopositionListPref->erase(*GeographicCount);
3001 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
3007 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3009 if (FirstToken == TRUE){
3011 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3016 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3026 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3028 // Add the name token data.
3030 if (!PropertyTokens.IsEmpty()){
3032 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3038 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3040 size_t intPropertyLen = PropertySeg1.Len();
3041 std::map<int, int> SplitPoints;
3042 std::map<int, int> SplitLength;
3043 std::map<int, int>::iterator SLiter;
3044 wxString PropertyData;
3045 wxString PropertyName;
3046 wxString PropertyValue;
3047 wxString PropertyTokens;
3048 wxString RelatedType;
3049 wxString RelatedTypeOriginal;
3050 wxString RelatedName;
3051 bool FirstToken = TRUE;
3052 int intSplitsFound = 0;
3053 int intSplitSize = 0;
3054 int intPrevValue = 9;
3058 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3062 // Look for type before continuing.
3064 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3065 intiter != SplitPoints.end(); ++intiter){
3067 SLiter = SplitLength.find(intiter->first);
3069 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3071 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3072 PropertyName = PropertyElement.GetNextToken();
3073 PropertyValue = PropertyElement.GetNextToken();
3075 intPrevValue = intiter->second;
3079 RelatedTypeOriginal = PropertyValue;
3081 if (PropertyName == wxT("TYPE")){
3083 if (PropertyValue == wxT("contact")){
3085 RelatedType = _("Contact");
3087 } else if (PropertyValue == wxT("acquaintance")){
3089 RelatedType = _("Acquaintance");
3091 } else if (PropertyValue == wxT("friend")){
3093 RelatedType = _("Friend");
3095 } else if (PropertyValue == wxT("met")){
3097 RelatedType = _("Met");
3099 } else if (PropertyValue == wxT("co-worker")){
3101 RelatedType = _("Co-worker");
3103 } else if (PropertyValue == wxT("colleague")){
3105 RelatedType = _("Colleague");
3107 } else if (PropertyValue == wxT("co-resident")){
3109 RelatedType = _("Co-resident");
3111 } else if (PropertyValue == wxT("neighbor")){
3113 RelatedType = _("Neighbour");
3115 } else if (PropertyValue == wxT("child")){
3117 RelatedType = _("Child");
3119 } else if (PropertyValue == wxT("parent")){
3121 RelatedType = _("Parent");
3123 } else if (PropertyValue == wxT("sibling")){
3125 RelatedType = _("Sibling");
3127 } else if (PropertyValue == wxT("spouse")){
3129 RelatedType = _("Spouse");
3131 } else if (PropertyValue == wxT("kin")){
3133 RelatedType = _("Kin");
3135 } else if (PropertyValue == wxT("muse")){
3137 RelatedType = _("Muse");
3139 } else if (PropertyValue == wxT("crush")){
3141 RelatedType = _("Crush");
3143 } else if (PropertyValue == wxT("date")){
3145 RelatedType = _("Date");
3147 } else if (PropertyValue == wxT("sweetheart")){
3149 RelatedType = _("Sweetheart");
3151 } else if (PropertyValue == wxT("me")){
3153 RelatedType = _("Me");
3155 } else if (PropertyValue == wxT("agent")){
3157 RelatedType = _("Agent");
3159 } else if (PropertyValue == wxT("emergency")){
3161 RelatedType = _("Emergency");
3165 RelatedType = PropertyValue;
3175 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3176 intiter != SplitPoints.end(); ++intiter){
3178 SLiter = SplitLength.find(intiter->first);
3180 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3182 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3183 PropertyName = PropertyElement.GetNextToken();
3184 PropertyValue = PropertyElement.GetNextToken();
3186 intPrevValue = intiter->second;
3188 // Process properties.
3190 size_t intPropertyValueLen = PropertyValue.Len();
3192 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3194 PropertyValue.Trim();
3195 PropertyValue.RemoveLast();
3199 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3201 PropertyValue.Remove(0, 1);
3205 CaptureString(&PropertyValue, FALSE);
3207 if (PropertyName == wxT("ALTID")){
3209 GeneralRelatedListAltID.erase(*RelatedCount);
3210 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3212 } else if (PropertyName == wxT("PID")){
3214 GeneralRelatedListPID.erase(*RelatedCount);
3215 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3217 } else if (PropertyName == wxT("PREF")){
3219 int PriorityNumber = 0;
3220 bool ValidNumber = TRUE;
3223 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3226 catch(std::invalid_argument &e){
3227 ValidNumber = FALSE;
3230 if (ValidNumber == TRUE){
3232 GeneralRelatedListPref.erase(*RelatedCount);
3233 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3237 } else if (PropertyName == wxT("LANGUAGE")){
3239 GeneralRelatedListLanguage.erase(*RelatedCount);
3240 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3242 } else if (PropertyName != wxT("TYPE")) {
3244 // Something else we don't know about so append
3245 // to the tokens variable.
3247 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3249 if (FirstToken == TRUE){
3251 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3256 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3266 // Add the data to the General/Home/Work address variables.
3268 GeneralRelatedList.erase(*RelatedCount);
3269 GeneralRelatedListRelType.erase(*RelatedCount);
3270 GeneralRelatedListType.erase(*RelatedCount);
3271 GeneralRelatedListTokens.erase(*RelatedCount);
3272 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3273 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3274 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3275 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3279 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3281 std::map<int, int> SplitPoints;
3282 std::map<int, int> SplitLength;
3283 std::map<int, int>::iterator SLiter;
3284 wxString PropertyData;
3285 wxString PropertyName;
3286 wxString PropertyValue;
3287 wxString PropertyTokens;
3288 bool FirstToken = TRUE;
3289 int intPrevValue = 5;
3294 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3298 PropertyType PropType = PROPERTY_NONE;
3300 // Look for type before continuing.
3302 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3304 // Setup the pointers.
3306 std::map<int, wxString> *WebsiteList = NULL;
3307 std::map<int, wxString> *WebsiteListAltID = NULL;
3308 std::map<int, wxString> *WebsiteListPID = NULL;
3309 std::map<int, wxString> *WebsiteListType = NULL;
3310 std::map<int, wxString> *WebsiteListTokens = NULL;
3311 std::map<int, wxString> *WebsiteListMediatype = NULL;
3312 std::map<int, int> *WebsiteListPref = NULL;
3314 // Setup blank lines for later on.
3318 WebsiteList = &GeneralWebsiteList;
3319 WebsiteListType = &GeneralWebsiteListType;
3320 WebsiteListAltID = &GeneralWebsiteListAltID;
3321 WebsiteListPID = &GeneralWebsiteListPID;
3322 WebsiteListTokens = &GeneralWebsiteListTokens;
3323 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3324 WebsiteListPref = &GeneralWebsiteListPref;
3327 WebsiteList = &HomeWebsiteList;
3328 WebsiteListType = &HomeWebsiteListType;
3329 WebsiteListAltID = &HomeWebsiteListAltID;
3330 WebsiteListPID = &HomeWebsiteListPID;
3331 WebsiteListTokens = &HomeWebsiteListTokens;
3332 WebsiteListMediatype = &HomeWebsiteListMediatype;
3333 WebsiteListPref = &HomeWebsiteListPref;
3336 WebsiteList = &BusinessWebsiteList;
3337 WebsiteListType = &BusinessWebsiteListType;
3338 WebsiteListAltID = &BusinessWebsiteListAltID;
3339 WebsiteListPID = &BusinessWebsiteListPID;
3340 WebsiteListTokens = &BusinessWebsiteListTokens;
3341 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3342 WebsiteListPref = &BusinessWebsiteListPref;
3348 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3349 intiter != SplitPoints.end(); ++intiter){
3351 SLiter = SplitLength.find(intiter->first);
3353 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3355 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3356 PropertyName = PropertyElement.GetNextToken();
3357 PropertyValue = PropertyElement.GetNextToken();
3359 intPrevValue = intiter->second;
3361 // Process properties.
3363 size_t intPropertyValueLen = PropertyValue.Len();
3365 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3367 PropertyValue.Trim();
3368 PropertyValue.RemoveLast();
3372 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3374 PropertyValue.Remove(0, 1);
3378 CaptureString(&PropertyValue, FALSE);
3380 if (PropertyName == wxT("ALTID")){
3382 WebsiteListAltID->erase(*URLCount);
3383 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3385 } else if (PropertyName == wxT("PID")){
3387 WebsiteListPID->erase(*URLCount);
3388 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3390 } else if (PropertyName == wxT("PREF")){
3392 int PriorityNumber = 0;
3393 bool ValidNumber = TRUE;
3396 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3399 catch(std::invalid_argument &e){
3400 ValidNumber = FALSE;
3403 if (ValidNumber == TRUE){
3405 WebsiteListPref->erase(*URLCount);
3406 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3410 } else if (PropertyName == wxT("MEDIATYPE")){
3412 WebsiteListMediatype->erase(*URLCount);
3413 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3417 // Something else we don't know about so append
3418 // to the tokens variable.
3420 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3422 if (FirstToken == TRUE){
3424 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3429 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3439 // Add the data to the General/Home/Work address variables.
3441 CaptureString(&PropertySeg2, FALSE);
3443 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3445 if (!PropertyTokens.IsEmpty()){
3447 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3453 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3455 std::map<int, int> SplitPoints;
3456 std::map<int, int> SplitLength;
3457 std::map<int, int>::iterator SLiter;
3458 wxString PropertyData;
3459 wxString PropertyName;
3460 wxString PropertyValue;
3461 wxString PropertyTokens;
3462 bool FirstToken = TRUE;
3463 int intPrevValue = 7;
3468 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3472 PropertyType PropType = PROPERTY_NONE;
3474 // Look for type before continuing.
3476 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3478 // Setup the pointers.
3480 std::map<int, wxString> *TitleList = NULL;
3481 std::map<int, wxString> *TitleListAltID = NULL;
3482 std::map<int, wxString> *TitleListPID = NULL;
3483 std::map<int, wxString> *TitleListType = NULL;
3484 std::map<int, wxString> *TitleListTokens = NULL;
3485 std::map<int, wxString> *TitleListLanguage = NULL;
3486 std::map<int, int> *TitleListPref = NULL;
3488 // Setup blank lines for later on.
3492 TitleList = &GeneralTitleList;
3493 TitleListType = &GeneralTitleListType;
3494 TitleListAltID = &GeneralTitleListAltID;
3495 TitleListPID = &GeneralTitleListPID;
3496 TitleListTokens = &GeneralTitleListTokens;
3497 TitleListLanguage = &GeneralTitleListLanguage;
3498 TitleListPref = &GeneralTitleListPref;
3501 TitleList = &HomeTitleList;
3502 TitleListType = &HomeTitleListType;
3503 TitleListAltID = &HomeTitleListAltID;
3504 TitleListPID = &HomeTitleListPID;
3505 TitleListTokens = &HomeTitleListTokens;
3506 TitleListLanguage = &HomeTitleListLanguage;
3507 TitleListPref = &HomeTitleListPref;
3510 TitleList = &BusinessTitleList;
3511 TitleListType = &BusinessTitleListType;
3512 TitleListAltID = &BusinessTitleListAltID;
3513 TitleListPID = &BusinessTitleListPID;
3514 TitleListTokens = &BusinessTitleListTokens;
3515 TitleListLanguage = &BusinessTitleListLanguage;
3516 TitleListPref = &BusinessTitleListPref;
3522 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3523 intiter != SplitPoints.end(); ++intiter){
3525 SLiter = SplitLength.find(intiter->first);
3527 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3529 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3530 PropertyName = PropertyElement.GetNextToken();
3531 PropertyValue = PropertyElement.GetNextToken();
3533 intPrevValue = intiter->second;
3535 // Process properties.
3537 size_t intPropertyValueLen = PropertyValue.Len();
3539 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3541 PropertyValue.Trim();
3542 PropertyValue.RemoveLast();
3546 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3548 PropertyValue.Remove(0, 1);
3552 CaptureString(&PropertyValue, FALSE);
3554 if (PropertyName == wxT("ALTID")){
3556 TitleListAltID->erase(*TitleCount);
3557 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3559 } else if (PropertyName == wxT("PID")){
3561 TitleListPID->erase(*TitleCount);
3562 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3564 } else if (PropertyName == wxT("PREF")){
3566 int PriorityNumber = 0;
3567 bool ValidNumber = TRUE;
3570 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3573 catch(std::invalid_argument &e){
3574 ValidNumber = FALSE;
3577 if (ValidNumber == TRUE){
3579 TitleListPref->erase(*TitleCount);
3580 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3584 } else if (PropertyName == wxT("LANGUAGE")){
3586 TitleListLanguage->erase(*TitleCount);
3587 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3591 // Something else we don't know about so append
3592 // to the tokens variable.
3594 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3596 if (FirstToken == TRUE){
3598 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3603 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3613 // Add the data to the General/Home/Work address variables.
3615 CaptureString(&PropertySeg2, FALSE);
3617 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3619 if (!PropertyTokens.IsEmpty()){
3621 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3627 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3629 std::map<int, int> SplitPoints;
3630 std::map<int, int> SplitLength;
3631 std::map<int, int>::iterator SLiter;
3632 wxString PropertyData;
3633 wxString PropertyName;
3634 wxString PropertyValue;
3635 wxString PropertyTokens;
3636 bool FirstToken = TRUE;
3637 int intPrevValue = 6;
3642 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3646 PropertyType PropType = PROPERTY_NONE;
3648 // Look for type before continuing.
3650 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3652 // Setup the pointers.
3654 std::map<int, wxString> *RoleList = NULL;
3655 std::map<int, wxString> *RoleListAltID = NULL;
3656 std::map<int, wxString> *RoleListPID = NULL;
3657 std::map<int, wxString> *RoleListType = NULL;
3658 std::map<int, wxString> *RoleListTokens = NULL;
3659 std::map<int, wxString> *RoleListLanguage = NULL;
3660 std::map<int, int> *RoleListPref = NULL;
3662 // Setup blank lines for later on.
3666 RoleList = &GeneralRoleList;
3667 RoleListType = &GeneralRoleListType;
3668 RoleListAltID = &GeneralRoleListAltID;
3669 RoleListPID = &GeneralRoleListPID;
3670 RoleListTokens = &GeneralRoleListTokens;
3671 RoleListLanguage = &GeneralRoleListLanguage;
3672 RoleListPref = &GeneralRoleListPref;
3675 RoleList = &HomeRoleList;
3676 RoleListType = &HomeRoleListType;
3677 RoleListAltID = &HomeRoleListAltID;
3678 RoleListPID = &HomeRoleListPID;
3679 RoleListTokens = &HomeRoleListTokens;
3680 RoleListLanguage = &HomeRoleListLanguage;
3681 RoleListPref = &HomeRoleListPref;
3684 RoleList = &BusinessRoleList;
3685 RoleListType = &BusinessRoleListType;
3686 RoleListAltID = &BusinessRoleListAltID;
3687 RoleListPID = &BusinessRoleListPID;
3688 RoleListTokens = &BusinessRoleListTokens;
3689 RoleListLanguage = &BusinessRoleListLanguage;
3690 RoleListPref = &BusinessRoleListPref;
3696 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3697 intiter != SplitPoints.end(); ++intiter){
3699 SLiter = SplitLength.find(intiter->first);
3701 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3703 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3704 PropertyName = PropertyElement.GetNextToken();
3705 PropertyValue = PropertyElement.GetNextToken();
3707 intPrevValue = intiter->second;
3709 // Process properties.
3711 size_t intPropertyValueLen = PropertyValue.Len();
3713 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3715 PropertyValue.Trim();
3716 PropertyValue.RemoveLast();
3720 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3722 PropertyValue.Remove(0, 1);
3726 CaptureString(&PropertyValue, FALSE);
3728 if (PropertyName == wxT("ALTID")){
3730 RoleListAltID->erase(*RoleCount);
3731 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3733 } else if (PropertyName == wxT("PID")){
3735 RoleListPID->erase(*RoleCount);
3736 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3738 } else if (PropertyName == wxT("PREF")){
3740 int PriorityNumber = 0;
3741 bool ValidNumber = TRUE;
3744 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3747 catch(std::invalid_argument &e){
3748 ValidNumber = FALSE;
3751 if (ValidNumber == TRUE){
3753 RoleListPref->erase(*RoleCount);
3754 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3758 } else if (PropertyName == wxT("LANGUAGE")){
3760 RoleListLanguage->erase(*RoleCount);
3761 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3765 // Something else we don't know about so append
3766 // to the tokens variable.
3768 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3770 if (FirstToken == TRUE){
3772 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3777 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3787 // Add the data to the General/Home/Work address variables.
3789 CaptureString(&PropertySeg2, FALSE);
3791 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3793 if (!PropertyTokens.IsEmpty()){
3795 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3801 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3803 std::map<int, int> SplitPoints;
3804 std::map<int, int> SplitLength;
3805 std::map<int, int>::iterator SLiter;
3806 wxString PropertyData;
3807 wxString PropertyName;
3808 wxString PropertyValue;
3809 wxString PropertyTokens;
3810 bool FirstToken = TRUE;
3811 int intPrevValue = 5;
3816 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3820 PropertyType PropType = PROPERTY_NONE;
3822 // Look for type before continuing.
3824 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3826 // Setup the pointers.
3828 std::map<int, wxString> *OrganisationsList = NULL;
3829 std::map<int, wxString> *OrganisationsListAltID = NULL;
3830 std::map<int, wxString> *OrganisationsListPID = NULL;
3831 std::map<int, wxString> *OrganisationsListType = NULL;
3832 std::map<int, wxString> *OrganisationsListTokens = NULL;
3833 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3834 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3835 std::map<int, int> *OrganisationsListPref = NULL;
3837 // Setup blank lines for later on.
3841 OrganisationsList = &GeneralOrganisationsList;
3842 OrganisationsListType = &GeneralOrganisationsListType;
3843 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3844 OrganisationsListPID = &GeneralOrganisationsListPID;
3845 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3846 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3847 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3848 OrganisationsListPref = &GeneralOrganisationsListPref;
3851 OrganisationsList = &HomeOrganisationsList;
3852 OrganisationsListType = &HomeOrganisationsListType;
3853 OrganisationsListAltID = &HomeOrganisationsListAltID;
3854 OrganisationsListPID = &HomeOrganisationsListPID;
3855 OrganisationsListTokens = &HomeOrganisationsListTokens;
3856 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3857 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3858 OrganisationsListPref = &HomeOrganisationsListPref;
3861 OrganisationsList = &BusinessOrganisationsList;
3862 OrganisationsListType = &BusinessOrganisationsListType;
3863 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3864 OrganisationsListPID = &BusinessOrganisationsListPID;
3865 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3866 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3867 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3868 OrganisationsListPref = &BusinessOrganisationsListPref;
3874 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3875 intiter != SplitPoints.end(); ++intiter){
3877 SLiter = SplitLength.find(intiter->first);
3879 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3881 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3882 PropertyName = PropertyElement.GetNextToken();
3883 PropertyValue = PropertyElement.GetNextToken();
3885 intPrevValue = intiter->second;
3887 // Process properties.
3889 size_t intPropertyValueLen = PropertyValue.Len();
3891 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3893 PropertyValue.Trim();
3894 PropertyValue.RemoveLast();
3898 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3900 PropertyValue.Remove(0, 1);
3904 CaptureString(&PropertyValue, FALSE);
3906 if (PropertyName == wxT("ALTID")){
3908 OrganisationsListAltID->erase(*OrganisationCount);
3909 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3911 } else if (PropertyName == wxT("PID")){
3913 OrganisationsListPID->erase(*OrganisationCount);
3914 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3916 } else if (PropertyName == wxT("SORT-AS")){
3918 OrganisationsListSortAs->erase(*OrganisationCount);
3919 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3921 } else if (PropertyName == wxT("PREF")){
3923 int PriorityNumber = 0;
3924 bool ValidNumber = TRUE;
3927 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3930 catch(std::invalid_argument &e){
3931 ValidNumber = FALSE;
3934 if (ValidNumber == TRUE){
3936 OrganisationsListPref->erase(*OrganisationCount);
3937 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3941 } else if (PropertyName == wxT("LANGUAGE")){
3943 OrganisationsListLanguage->erase(*OrganisationCount);
3944 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3948 // Something else we don't know about so append
3949 // to the tokens variable.
3951 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3953 if (FirstToken == TRUE){
3955 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3960 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3970 // Add the data to the General/Home/Work address variables.
3972 CaptureString(&PropertySeg2, FALSE);
3974 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3976 if (!PropertyTokens.IsEmpty()){
3978 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3984 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3986 std::map<int, int> SplitPoints;
3987 std::map<int, int> SplitLength;
3988 std::map<int, int>::iterator SLiter;
3989 wxString PropertyData;
3990 wxString PropertyName;
3991 wxString PropertyValue;
3992 wxString PropertyTokens;
3993 bool FirstToken = TRUE;
3994 int intPrevValue = 6;
3999 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4003 PropertyType PropType = PROPERTY_NONE;
4005 // Look for type before continuing.
4007 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4009 // Setup the pointers.
4011 std::map<int, wxString> *NoteList = NULL;
4012 std::map<int, wxString> *NoteListAltID = NULL;
4013 std::map<int, wxString> *NoteListPID = NULL;
4014 std::map<int, wxString> *NoteListType = NULL;
4015 std::map<int, wxString> *NoteListTokens = NULL;
4016 std::map<int, wxString> *NoteListLanguage = NULL;
4017 std::map<int, int> *NoteListPref = NULL;
4019 // Setup blank lines for later on.
4023 NoteList = &GeneralNoteList;
4024 NoteListType = &GeneralNoteListType;
4025 NoteListAltID = &GeneralNoteListAltID;
4026 NoteListPID = &GeneralNoteListPID;
4027 NoteListTokens = &GeneralNoteListTokens;
4028 NoteListLanguage = &GeneralNoteListLanguage;
4029 NoteListPref = &GeneralNoteListPref;
4032 NoteList = &HomeNoteList;
4033 NoteListType = &HomeNoteListType;
4034 NoteListAltID = &HomeNoteListAltID;
4035 NoteListPID = &HomeNoteListPID;
4036 NoteListTokens = &HomeNoteListTokens;
4037 NoteListLanguage = &HomeNoteListLanguage;
4038 NoteListPref = &HomeNoteListPref;
4041 NoteList = &BusinessNoteList;
4042 NoteListType = &BusinessNoteListType;
4043 NoteListAltID = &BusinessNoteListAltID;
4044 NoteListPID = &BusinessNoteListPID;
4045 NoteListTokens = &BusinessNoteListTokens;
4046 NoteListLanguage = &BusinessNoteListLanguage;
4047 NoteListPref = &BusinessNoteListPref;
4053 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4054 intiter != SplitPoints.end(); ++intiter){
4056 SLiter = SplitLength.find(intiter->first);
4058 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4060 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4061 PropertyName = PropertyElement.GetNextToken();
4062 PropertyValue = PropertyElement.GetNextToken();
4064 intPrevValue = intiter->second;
4066 // Process properties.
4068 size_t intPropertyValueLen = PropertyValue.Len();
4070 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4072 PropertyValue.Trim();
4073 PropertyValue.RemoveLast();
4077 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4079 PropertyValue.Remove(0, 1);
4083 CaptureString(&PropertyValue, FALSE);
4085 if (PropertyName == wxT("ALTID")){
4087 NoteListAltID->erase(*NoteCount);
4088 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4090 } else if (PropertyName == wxT("PID")){
4092 NoteListPID->erase(*NoteCount);
4093 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4095 } else if (PropertyName == wxT("PREF")){
4097 int PriorityNumber = 0;
4098 bool ValidNumber = TRUE;
4101 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4104 catch(std::invalid_argument &e){
4105 ValidNumber = FALSE;
4108 if (ValidNumber == TRUE){
4110 NoteListPref->erase(*NoteCount);
4111 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4115 } else if (PropertyName == wxT("LANGUAGE")){
4117 NoteListLanguage->erase(*NoteCount);
4118 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4122 // Something else we don't know about so append
4123 // to the tokens variable.
4125 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4127 if (FirstToken == TRUE){
4129 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4134 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4144 // Add the data to the General/Home/Work address variables.
4146 CaptureString(&PropertySeg2, FALSE);
4148 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4150 if (!PropertyTokens.IsEmpty()){
4152 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4158 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4160 std::map<int, int> SplitPoints;
4161 std::map<int, int> SplitLength;
4162 std::map<int, int>::iterator SLiter;
4163 wxString PropertyData;
4164 wxString PropertyName;
4165 wxString PropertyValue;
4166 wxString PropertyTokens;
4167 bool FirstToken = TRUE;
4168 int intPrevValue = 12;
4173 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4177 PropertyType PropType = PROPERTY_NONE;
4179 // Look for type before continuing.
4181 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4183 // Setup blank lines for later on.
4189 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4192 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4198 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4199 intiter != SplitPoints.end(); ++intiter){
4201 SLiter = SplitLength.find(intiter->first);
4203 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4205 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4206 PropertyName = PropertyElement.GetNextToken();
4207 PropertyValue = PropertyElement.GetNextToken();
4209 intPrevValue = intiter->second;
4211 // Process properties.
4213 size_t intPropertyValueLen = PropertyValue.Len();
4215 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4217 PropertyValue.Trim();
4218 PropertyValue.RemoveLast();
4222 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4224 PropertyValue.Remove(0, 1);
4228 CaptureString(&PropertyValue, FALSE);
4230 if (PropertyName == wxT("ALTID")){
4232 CategoriesListAltID.erase(*CategoryCount);
4233 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4235 } else if (PropertyName == wxT("PID")){
4237 CategoriesListPID.erase(*CategoryCount);
4238 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4240 } else if (PropertyName == wxT("PREF")){
4242 int PriorityNumber = 0;
4243 bool ValidNumber = TRUE;
4246 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4249 catch(std::invalid_argument &e){
4250 ValidNumber = FALSE;
4253 if (ValidNumber == TRUE){
4255 CategoriesListPref.erase(*CategoryCount);
4256 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4260 } else if (PropertyName == wxT("LANGUAGE")){
4262 CategoriesListLanguage.erase(*CategoryCount);
4263 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4267 // Something else we don't know about so append
4268 // to the tokens variable.
4270 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4272 if (FirstToken == TRUE){
4274 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4279 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4289 // Deal with multiple categories.
4291 int intOrigCatCount = *CategoryCount;
4292 bool FirstCategoryProcessed = TRUE;
4293 bool AfterFirstToken = FALSE;
4294 int intSplitSize = 0;
4295 int intSplitsFound = 0;
4296 int intSplitSeek = 0;
4297 int intPropertyLen = PropertySeg2.Len();
4299 SplitPoints.clear();
4300 SplitLength.clear();
4303 for (int i = 0; i <= intPropertyLen; i++){
4305 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4313 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4315 if (AfterFirstToken == TRUE){
4317 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4318 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4322 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4323 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4324 AfterFirstToken = TRUE;
4336 if (SplitPoints.size() > 0){
4338 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4339 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4343 if (SplitPoints.size() == 0){
4345 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4347 if (!PropertyTokens.IsEmpty()){
4349 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4355 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4356 intiter != SplitPoints.end(); ++intiter){
4358 SLiter = SplitLength.find(intiter->first);
4360 intPrevValue = intiter->second;
4362 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4364 // Add the data to the General/Home/Work address variables.
4366 // Trim any whitespace from the start and end.
4368 PropertyData = PropertyData.Trim(FALSE);
4369 PropertyData = PropertyData.Trim(TRUE);
4371 CaptureString(&PropertyData, FALSE);
4373 if (FirstCategoryProcessed == TRUE){
4375 FirstCategoryProcessed = FALSE;
4377 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4379 if (!PropertyTokens.IsEmpty()){
4381 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4391 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4393 if (!PropertyTokens.IsEmpty()){
4395 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4401 // Copy the properties to each of the categories (if it exists).
4403 if (!PropertyTokens.IsEmpty()){
4405 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4409 // Check if ALTID was used.
4411 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4413 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4417 // Check if PID was used.
4419 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4421 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4425 // Check if PREF was used.
4427 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4429 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4433 // Check if LANGUAGE was used.
4435 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4437 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4441 // Check if TYPE was used.
4447 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4450 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4458 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4460 size_t intPropertyLen = PropertySeg1.Len();
4461 std::map<int, int> SplitPoints;
4462 std::map<int, int> SplitLength;
4463 std::map<int, int>::iterator SLiter;
4464 wxString PropertyData;
4465 wxString PropertyName;
4466 wxString PropertyValue;
4467 wxString PropertyTokens;
4468 bool FirstToken = TRUE;
4469 int intSplitsFound = 0;
4470 int intSplitSize = 0;
4471 int intPrevValue = 7;
4475 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4479 PropertyType PropType = PROPERTY_NONE;
4481 // Look for type before continuing.
4483 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4487 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4488 intiter != SplitPoints.end(); ++intiter){
4490 SLiter = SplitLength.find(intiter->first);
4492 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4494 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4495 PropertyName = PropertyElement.GetNextToken();
4496 PropertyValue = PropertyElement.GetNextToken();
4498 intPrevValue = intiter->second;
4500 // Process properties.
4502 size_t intPropertyValueLen = PropertyValue.Len();
4504 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4506 PropertyValue.Trim();
4507 PropertyValue.RemoveLast();
4511 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4513 PropertyValue.Remove(0, 1);
4517 CaptureString(&PropertyValue, FALSE);
4519 if (PropertyName == wxT("ALTID")){
4521 PicturesListAltID.erase(*PhotoCount);
4522 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4524 } else if (PropertyName == wxT("PID")){
4526 PicturesListPID.erase(*PhotoCount);
4527 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4529 } else if (PropertyName == wxT("PREF")){
4531 int PriorityNumber = 0;
4532 bool ValidNumber = TRUE;
4535 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4538 catch(std::invalid_argument &e){
4539 ValidNumber = FALSE;
4542 if (ValidNumber == TRUE){
4544 PicturesListPref.erase(*PhotoCount);
4545 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4549 } else if (PropertyName == wxT("MEDIATYPE")){
4551 PicturesListMediatype.erase(*PhotoCount);
4552 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4556 // Something else we don't know about so append
4557 // to the tokens variable.
4559 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4561 if (FirstToken == TRUE){
4563 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4568 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4578 intPropertyLen = PropertySeg2.Len();
4579 SplitPoints.clear();
4580 SplitLength.clear();
4585 CaptureString(&PropertySeg2, FALSE);
4587 for (int i = 0; i <= intPropertyLen; i++){
4591 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4594 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4596 if (intSplitsFound == 6){
4598 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4603 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4613 wxString wxSPhotoURI;
4614 wxString wxSPhotoMIME;
4615 wxString wxSPhotoEncoding;
4616 wxString wxSPhotoData;
4617 std::string base64enc;
4619 if (intSplitsFound == 0){
4623 std::map<int, int>::iterator striter;
4625 striter = SplitLength.find(1);
4627 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4629 while (wSTDataType.HasMoreTokens() == TRUE){
4631 wxSPhotoURI = wSTDataType.GetNextToken();
4632 wxSPhotoMIME = wSTDataType.GetNextToken();
4637 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4639 while (wSTDataInfo.HasMoreTokens() == TRUE){
4641 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4642 wxSPhotoData = wSTDataInfo.GetNextToken();
4643 base64enc = wxSPhotoData.mb_str();
4650 // Add the data to the General/Home/Work address variables.
4652 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4653 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4654 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4660 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4663 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4667 if (!PropertyTokens.IsEmpty()){
4669 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4675 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4677 size_t intPropertyLen = PropertySeg1.Len();
4678 std::map<int, int> SplitPoints;
4679 std::map<int, int> SplitLength;
4680 std::map<int, int>::iterator SLiter;
4681 wxString PropertyData;
4682 wxString PropertyName;
4683 wxString PropertyValue;
4684 wxString PropertyTokens;
4685 bool FirstToken = TRUE;
4686 int intSplitsFound = 0;
4687 int intSplitSize = 0;
4688 int intPrevValue = 6;
4692 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4696 PropertyType PropType = PROPERTY_NONE;
4698 // Look for type before continuing.
4700 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4704 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4705 intiter != SplitPoints.end(); ++intiter){
4707 SLiter = SplitLength.find(intiter->first);
4709 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4711 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4712 PropertyName = PropertyElement.GetNextToken();
4713 PropertyValue = PropertyElement.GetNextToken();
4715 intPrevValue = intiter->second;
4717 // Process properties.
4719 size_t intPropertyValueLen = PropertyValue.Len();
4721 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4723 PropertyValue.Trim();
4724 PropertyValue.RemoveLast();
4728 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4730 PropertyValue.Remove(0, 1);
4734 CaptureString(&PropertyValue, FALSE);
4736 if (PropertyName == wxT("ALTID")){
4738 LogosListAltID.erase(*LogoCount);
4739 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4741 } else if (PropertyName == wxT("PID")){
4743 LogosListPID.erase(*LogoCount);
4744 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4746 } else if (PropertyName == wxT("PREF")){
4748 int PriorityNumber = 0;
4749 bool ValidNumber = TRUE;
4752 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4755 catch(std::invalid_argument &e){
4756 ValidNumber = FALSE;
4759 if (ValidNumber == TRUE){
4761 LogosListPref.erase(*LogoCount);
4762 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4766 } else if (PropertyName == wxT("MEDIATYPE")){
4768 LogosListMediatype.erase(*LogoCount);
4769 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4773 // Something else we don't know about so append
4774 // to the tokens variable.
4776 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4778 if (FirstToken == TRUE){
4780 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4785 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4795 intPropertyLen = PropertySeg2.Len();
4796 SplitPoints.clear();
4797 SplitLength.clear();
4802 CaptureString(&PropertySeg2, FALSE);
4804 for (int i = 0; i <= intPropertyLen; i++){
4808 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4811 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4813 if (intSplitsFound == 6){
4815 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4820 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4830 wxString wxSPhotoURI;
4831 wxString wxSPhotoMIME;
4832 wxString wxSPhotoEncoding;
4833 wxString wxSPhotoData;
4834 std::string base64enc;
4836 if (intSplitsFound == 0){
4840 std::map<int, int>::iterator striter;
4842 striter = SplitLength.find(1);
4844 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4846 while (wSTDataType.HasMoreTokens() == TRUE){
4848 wxSPhotoURI = wSTDataType.GetNextToken();
4849 wxSPhotoMIME = wSTDataType.GetNextToken();
4854 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4856 while (wSTDataInfo.HasMoreTokens() == TRUE){
4858 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4859 wxSPhotoData = wSTDataInfo.GetNextToken();
4860 base64enc = wxSPhotoData.mb_str();
4867 // Add the data to the General/Home/Work address variables.
4869 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4870 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4871 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4877 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4880 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4884 if (!PropertyTokens.IsEmpty()){
4886 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4892 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4894 size_t intPropertyLen = PropertySeg1.Len();
4895 std::map<int, int> SplitPoints;
4896 std::map<int, int> SplitLength;
4897 std::map<int, int>::iterator SLiter;
4898 wxString PropertyData;
4899 wxString PropertyName;
4900 wxString PropertyValue;
4901 wxString PropertyTokens;
4902 bool FirstToken = TRUE;
4903 int intSplitsFound = 0;
4904 int intSplitSize = 0;
4905 int intPrevValue = 7;
4909 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4913 PropertyType PropType = PROPERTY_NONE;
4915 // Look for type before continuing.
4917 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4921 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4922 intiter != SplitPoints.end(); ++intiter){
4924 SLiter = SplitLength.find(intiter->first);
4926 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4928 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4929 PropertyName = PropertyElement.GetNextToken();
4930 PropertyValue = PropertyElement.GetNextToken();
4932 intPrevValue = intiter->second;
4934 // Process properties.
4936 size_t intPropertyValueLen = PropertyValue.Len();
4938 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4940 PropertyValue.Trim();
4941 PropertyValue.RemoveLast();
4945 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4947 PropertyValue.Remove(0, 1);
4951 CaptureString(&PropertyValue, FALSE);
4953 if (PropertyName == wxT("ALTID")){
4955 SoundsListAltID.erase(*SoundCount);
4956 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4958 } else if (PropertyName == wxT("PID")){
4960 SoundsListPID.erase(*SoundCount);
4961 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4963 } else if (PropertyName == wxT("PREF")){
4965 int PriorityNumber = 0;
4966 bool ValidNumber = TRUE;
4969 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4972 catch(std::invalid_argument &e){
4973 ValidNumber = FALSE;
4976 if (ValidNumber == TRUE){
4978 SoundsListPref.erase(*SoundCount);
4979 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4983 } else if (PropertyName == wxT("MEDIATYPE")){
4985 SoundsListMediatype.erase(*SoundCount);
4986 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4988 } else if (PropertyName == wxT("LANGUAGE")){
4990 SoundsListLanguage.erase(*SoundCount);
4991 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4995 // Something else we don't know about so append
4996 // to the tokens variable.
4998 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5000 if (FirstToken == TRUE){
5002 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5007 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5017 intPropertyLen = PropertySeg2.Len();
5018 SplitPoints.clear();
5019 SplitLength.clear();
5024 CaptureString(&PropertySeg2, FALSE);
5026 for (int i = 0; i <= intPropertyLen; i++){
5030 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5033 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5035 if (intSplitsFound == 6){
5037 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5042 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5052 wxString wxSSoundURI;
5053 wxString wxSSoundMIME;
5054 wxString wxSSoundEncoding;
5055 wxString wxSSoundData;
5056 std::string base64enc;
5058 if (intSplitsFound == 0){
5062 std::map<int, int>::iterator striter;
5064 striter = SplitLength.find(1);
5066 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5068 while (wSTDataType.HasMoreTokens() == TRUE){
5070 wxSSoundURI = wSTDataType.GetNextToken();
5071 wxSSoundMIME = wSTDataType.GetNextToken();
5076 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5078 while (wSTDataInfo.HasMoreTokens() == TRUE){
5080 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5081 wxSSoundData = wSTDataInfo.GetNextToken();
5082 base64enc = wxSSoundData.mb_str();
5089 // Add the data to the General/Home/Work address variables.
5095 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5098 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5102 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5103 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5104 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5106 if (!PropertyTokens.IsEmpty()){
5108 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5114 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5116 size_t intPropertyLen = PropertySeg1.Len();
5117 std::map<int, int> SplitPoints;
5118 std::map<int, int> SplitLength;
5119 std::map<int, int>::iterator SLiter;
5120 wxString PropertyData;
5121 wxString PropertyName;
5122 wxString PropertyValue;
5123 wxString PropertyTokens;
5124 bool FirstToken = TRUE;
5125 int intSplitsFound = 0;
5126 int intSplitSize = 0;
5127 int intPrevValue = 8;
5131 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5135 PropertyType PropType = PROPERTY_NONE;
5137 // Look for type before continuing.
5139 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5143 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5144 intiter != SplitPoints.end(); ++intiter){
5146 SLiter = SplitLength.find(intiter->first);
5148 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5150 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5151 PropertyName = PropertyElement.GetNextToken();
5152 PropertyValue = PropertyElement.GetNextToken();
5154 intPrevValue = intiter->second;
5156 // Process properties.
5158 size_t intPropertyValueLen = PropertyValue.Len();
5160 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5162 PropertyValue.Trim();
5163 PropertyValue.RemoveLast();
5167 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5169 PropertyValue.Remove(0, 1);
5173 CaptureString(&PropertyValue, FALSE);
5175 if (PropertyName == wxT("ALTID")){
5177 CalendarListAltID.erase(*CalURICount);
5178 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5180 } else if (PropertyName == wxT("PID")){
5182 CalendarListPID.erase(*CalURICount);
5183 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5185 } else if (PropertyName == wxT("PREF")){
5187 int PriorityNumber = 0;
5188 bool ValidNumber = TRUE;
5191 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5194 catch(std::invalid_argument &e){
5195 ValidNumber = FALSE;
5198 if (ValidNumber == TRUE){
5200 CalendarListPref.erase(*CalURICount);
5201 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5205 } else if (PropertyName == wxT("MEDIATYPE")){
5207 CalendarListMediatype.erase(*CalURICount);
5208 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5212 // Something else we don't know about so append
5213 // to the tokens variable.
5215 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5217 if (FirstToken == TRUE){
5219 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5224 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5234 intPropertyLen = PropertySeg2.Len();
5235 SplitPoints.clear();
5236 SplitLength.clear();
5241 CaptureString(&PropertySeg2, FALSE);
5243 // Add the data to the General/Home/Work address variables.
5249 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5252 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5256 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5258 if (!PropertyTokens.IsEmpty()){
5260 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5266 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5268 size_t intPropertyLen = PropertySeg1.Len();
5269 std::map<int, int> SplitPoints;
5270 std::map<int, int> SplitLength;
5271 std::map<int, int>::iterator SLiter;
5272 wxString PropertyData;
5273 wxString PropertyName;
5274 wxString PropertyValue;
5275 wxString PropertyTokens;
5276 bool FirstToken = TRUE;
5277 int intSplitsFound = 0;
5278 int intSplitSize = 0;
5279 int intPrevValue = 8;
5283 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5287 PropertyType PropType = PROPERTY_NONE;
5289 // Look for type before continuing.
5291 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5295 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5296 intiter != SplitPoints.end(); ++intiter){
5298 SLiter = SplitLength.find(intiter->first);
5300 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5302 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5303 PropertyName = PropertyElement.GetNextToken();
5304 PropertyValue = PropertyElement.GetNextToken();
5306 intPrevValue = intiter->second;
5308 // Process properties.
5310 size_t intPropertyValueLen = PropertyValue.Len();
5312 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5314 PropertyValue.Trim();
5315 PropertyValue.RemoveLast();
5319 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5321 PropertyValue.Remove(0, 1);
5325 CaptureString(&PropertyValue, FALSE);
5327 if (PropertyName == wxT("ALTID")){
5329 CalendarRequestListAltID.erase(*CalAdrURICount);
5330 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5332 } else if (PropertyName == wxT("PID")){
5334 CalendarRequestListPID.erase(*CalAdrURICount);
5335 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5337 } else if (PropertyName == wxT("PREF")){
5339 int PriorityNumber = 0;
5340 bool ValidNumber = TRUE;
5343 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5346 catch(std::invalid_argument &e){
5347 ValidNumber = FALSE;
5350 if (ValidNumber == TRUE){
5352 CalendarRequestListPref.erase(*CalAdrURICount);
5353 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5357 } else if (PropertyName == wxT("MEDIATYPE")){
5359 CalendarRequestListMediatype.erase(*CalAdrURICount);
5360 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5364 // Something else we don't know about so append
5365 // to the tokens variable.
5367 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5369 if (FirstToken == TRUE){
5371 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5376 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5386 intPropertyLen = PropertySeg2.Len();
5387 SplitPoints.clear();
5388 SplitLength.clear();
5393 CaptureString(&PropertySeg2, FALSE);
5395 // Add the data to the General/Home/Work address variables.
5401 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5404 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5408 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5410 if (!PropertyTokens.IsEmpty()){
5412 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5418 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5420 size_t intPropertyLen = PropertySeg1.Len();
5421 std::map<int, int> SplitPoints;
5422 std::map<int, int> SplitLength;
5423 std::map<int, int>::iterator SLiter;
5424 wxString PropertyData;
5425 wxString PropertyName;
5426 wxString PropertyValue;
5427 wxString PropertyTokens;
5428 bool FirstToken = TRUE;
5429 int intSplitsFound = 0;
5430 int intSplitSize = 0;
5431 int intPrevValue = 7;
5435 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5439 PropertyType PropType = PROPERTY_NONE;
5441 // Look for type before continuing.
5443 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5447 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5448 intiter != SplitPoints.end(); ++intiter){
5450 SLiter = SplitLength.find(intiter->first);
5452 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5454 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5455 PropertyName = PropertyElement.GetNextToken();
5456 PropertyValue = PropertyElement.GetNextToken();
5458 intPrevValue = intiter->second;
5460 // Process properties.
5462 size_t intPropertyValueLen = PropertyValue.Len();
5464 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5466 PropertyValue.Trim();
5467 PropertyValue.RemoveLast();
5471 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5473 PropertyValue.Remove(0, 1);
5477 CaptureString(&PropertyValue, FALSE);
5479 if (PropertyName == wxT("ALTID")){
5481 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5482 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5484 } else if (PropertyName == wxT("PID")){
5486 FreeBusyListPID.erase(*FreeBusyAddressCount);
5487 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5489 } else if (PropertyName == wxT("PREF")){
5491 int PriorityNumber = 0;
5492 bool ValidNumber = TRUE;
5495 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5498 catch(std::invalid_argument &e){
5499 ValidNumber = FALSE;
5502 if (ValidNumber == TRUE){
5504 FreeBusyListPref.erase(*FreeBusyAddressCount);
5505 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5509 } else if (PropertyName == wxT("MEDIATYPE")){
5511 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5512 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5516 // Something else we don't know about so append
5517 // to the tokens variable.
5519 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5521 if (FirstToken == TRUE){
5523 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5528 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5538 intPropertyLen = PropertySeg2.Len();
5539 SplitPoints.clear();
5540 SplitLength.clear();
5545 CaptureString(&PropertySeg2, FALSE);
5547 // Add the data to the General/Home/Work address variables.
5553 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5556 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5560 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5562 if (!PropertyTokens.IsEmpty()){
5564 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5570 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5572 size_t intPropertyLen = PropertySeg1.Len();
5573 std::map<int, int> SplitPoints;
5574 std::map<int, int> SplitLength;
5575 std::map<int, int>::iterator SLiter;
5576 wxString PropertyData;
5577 wxString PropertyName;
5578 wxString PropertyValue;
5579 wxString PropertyTokens;
5580 bool FirstToken = TRUE;
5581 int intSplitsFound = 0;
5582 int intSplitSize = 0;
5583 int intPrevValue = 5;
5588 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5592 PropertyType PropType = PROPERTY_NONE;
5594 // Look for type before continuing.
5596 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5600 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5601 intiter != SplitPoints.end(); ++intiter){
5603 SLiter = SplitLength.find(intiter->first);
5605 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5607 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5608 PropertyName = PropertyElement.GetNextToken();
5609 PropertyValue = PropertyElement.GetNextToken();
5611 intPrevValue = intiter->second;
5613 // Process properties.
5615 size_t intPropertyValueLen = PropertyValue.Len();
5617 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5619 PropertyValue.Trim();
5620 PropertyValue.RemoveLast();
5624 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5626 PropertyValue.Remove(0, 1);
5630 if (PropertyName == wxT("ALTID")){
5632 KeyListAltID.erase(*KeyCount);
5633 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5635 } else if (PropertyName == wxT("PID")){
5637 KeyListPID.erase(*KeyCount);
5638 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5640 } else if (PropertyName == wxT("PREF")){
5642 int PriorityNumber = 0;
5643 bool ValidNumber = TRUE;
5646 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5649 catch(std::invalid_argument &e){
5650 ValidNumber = FALSE;
5653 if (ValidNumber == TRUE){
5655 KeyListPref.erase(*KeyCount);
5656 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5662 // Something else we don't know about so append
5663 // to the tokens variable.
5665 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5667 if (FirstToken == TRUE){
5669 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5674 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5684 intPropertyLen = PropertySeg2.Len();
5685 SplitPoints.clear();
5686 SplitLength.clear();
5691 for (int i = 0; i <= intPropertyLen; i++){
5695 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5698 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5700 if (intSplitsFound == 6){
5702 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5707 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5718 wxString wxSKeyMIME;
5719 wxString wxSKeyEncoding;
5720 wxString wxSKeyData;
5721 std::string base64enc;
5723 if (intSplitsFound == 0){
5727 std::map<int, int>::iterator striter;
5729 striter = SplitLength.find(1);
5731 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5733 while (wSTDataType.HasMoreTokens() == TRUE){
5735 wxSKeyURI = wSTDataType.GetNextToken();
5736 wxSKeyMIME = wSTDataType.GetNextToken();
5741 if (wxSKeyURI == wxT("data")){
5743 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5745 while (wSTDataInfo.HasMoreTokens() == TRUE){
5747 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5748 wxSKeyData = wSTDataInfo.GetNextToken();
5757 // Add the data to the General/Home/Work address variables.
5759 if (wxSKeyURI == wxT("data")){
5761 KeyListDataEncType.erase(*KeyCount);
5762 KeyListKeyType.erase(*KeyCount);
5763 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5764 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5766 KeyList.erase(*KeyCount);
5767 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5771 KeyList.erase(*KeyCount);
5772 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5776 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5782 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5785 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5789 if (!PropertyTokens.IsEmpty()){
5791 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5797 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5799 // Split the Vendor three ways.
5801 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5804 wxString wxSVNDPropName;
5807 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5809 wSTVendorDetails.GetNextToken();
5810 wxSVNDID = wSTVendorDetails.GetNextToken();
5811 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5816 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5818 // Add the data to the vendor variables.
5820 VendorList.erase(*VendorCount);
5821 VendorListPEN.erase(*VendorCount);
5822 VendorListElement.erase(*VendorCount);
5824 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5825 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5826 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5832 void ProcessIntegerValue(ContactDataObject *ContactData,
5833 std::map<int,int> *PrefPtr,
5834 wxString *PropertyValue,
5837 int PriorityNumber = 0;
5838 bool ValidNumber = TRUE;
5841 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5844 catch(std::invalid_argument &e){
5845 ValidNumber = FALSE;
5848 if (ValidNumber == TRUE){
5850 PrefPtr->erase(*ItemCount);
5851 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5857 void SplitValues(wxString *PropertyLine,
5858 std::map<int,int> *SplitPoints,
5859 std::map<int,int> *SplitLength,
5862 size_t intPropertyLen = PropertyLine->Len();
5863 int intSplitsFound = 0;
5864 int intSplitSize = 0;
5865 int intSplitSeek = 0;
5867 for (int i = intSize; i <= intPropertyLen; i++){
5871 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5872 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5874 if (intSplitsFound == 0){
5876 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5880 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5884 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5894 if (intSplitsFound == 0){
5896 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5897 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5901 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5902 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5908 void CheckType(wxString *PropertySeg1,
5909 std::map<int,int> *SplitPoints,
5910 std::map<int,int> *SplitLength,
5912 PropertyType *PropType){
5914 wxString PropertyData;
5915 wxString PropertyName;
5916 wxString PropertyValue;
5917 std::map<int,int>::iterator SLiter;
5919 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5920 intiter != SplitPoints->end(); ++intiter){
5922 SLiter = SplitLength->find(intiter->first);
5924 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5926 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5927 PropertyName = PropertyElement.GetNextToken();
5928 PropertyValue = PropertyElement.GetNextToken();
5930 *intPrevValue = intiter->second;
5932 if (PropertyName == wxT("TYPE")){
5934 if (PropertyValue == wxT("work")){
5936 *PropType = PROPERTY_WORK;
5938 } else if (PropertyValue == wxT("home")){
5940 *PropType = PROPERTY_HOME;
5944 *PropType = PROPERTY_NONE;