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 ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount);
1231 } else if (PropertyName == wxT("LANGUAGE")){
1233 NicknamesListLanguage->erase(*NicknameCount);
1234 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1238 // Something else we don't know about so append
1239 // to the tokens variable.
1241 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1243 if (FirstToken == TRUE){
1245 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1250 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1260 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1262 // Add the name token data.
1264 if (!PropertyTokens.IsEmpty()){
1266 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1272 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1274 std::map<int, int> SplitPoints;
1275 std::map<int, int> SplitLength;
1276 std::map<int, int>::iterator SLiter;
1277 wxString PropertyData;
1278 wxString PropertyName;
1279 wxString PropertyValue;
1280 wxString PropertyTokens;
1281 bool FirstToken = TRUE;
1282 int intPrevValue = 8;
1284 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1288 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1289 intiter != SplitPoints.end(); ++intiter){
1291 SLiter = SplitLength.find(intiter->first);
1293 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1295 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1296 PropertyName = PropertyElement.GetNextToken();
1297 PropertyValue = PropertyElement.GetNextToken();
1299 intPrevValue = intiter->second;
1301 // Process properties.
1303 size_t intPropertyValueLen = PropertyValue.Len();
1305 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1307 PropertyValue.Trim();
1308 PropertyValue.RemoveLast();
1312 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1314 PropertyValue.Remove(0, 1);
1318 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1320 if (FirstToken == TRUE){
1322 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1327 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1335 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1337 wxString GenderComponent;
1339 if (GenderData.CountTokens() >= 2){
1341 Gender = GenderData.GetNextToken();
1342 GenderDetails = GenderData.GetString();
1344 CaptureString(&GenderDetails, FALSE);
1348 Gender = GenderData.GetNextToken();
1352 if (!PropertyTokens.IsEmpty()){
1354 GenderTokens = PropertyTokens;
1360 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1362 // Process date. Preserve the remainder in the string.
1364 std::map<int, int> SplitPoints;
1365 std::map<int, int> SplitLength;
1366 std::map<int, int>::iterator SLiter;
1367 wxString PropertyData;
1368 wxString PropertyName;
1369 wxString PropertyValue;
1370 wxString PropertyTokens;
1371 bool BirthdayText = FALSE;
1372 int intPrevValue = 6;
1374 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1378 // Look for type before continuing.
1380 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1381 intiter != SplitPoints.end(); ++intiter){
1383 SLiter = SplitLength.find(intiter->first);
1385 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1387 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1388 PropertyName = PropertyElement.GetNextToken();
1389 PropertyValue = PropertyElement.GetNextToken();
1391 intPrevValue = intiter->second;
1393 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1395 CaptureString(&PropertySeg2, FALSE);
1396 Birthday = PropertySeg2;
1397 BirthdayText = TRUE;
1403 // Setup blank lines for later on.
1406 bool FirstToken = TRUE;
1408 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1409 intiter != SplitPoints.end(); ++intiter){
1411 SLiter = SplitLength.find(intiter->first);
1413 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1415 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1416 PropertyName = PropertyElement.GetNextToken();
1417 PropertyValue = PropertyElement.GetNextToken();
1419 intPrevValue = intiter->second;
1421 // Process properties.
1423 CaptureString(&PropertyValue, FALSE);
1425 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1427 PropertyValue.Trim();
1428 PropertyValue.RemoveLast();
1432 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1434 PropertyValue.Remove(0, 1);
1438 if (PropertyName == wxT("ALTID")){
1440 BirthdayAltID = PropertyValue;
1442 } else if (PropertyName == wxT("CALSCALE")){
1444 BirthdayCalScale = PropertyValue;
1446 } else if (PropertyName != wxT("VALUE")) {
1448 // Something else we don't know about so append
1449 // to the tokens variable.
1451 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1453 if (FirstToken == TRUE){
1455 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1460 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1470 // Add the data to the variables and form.
1472 if (BirthdayText == FALSE){
1474 Birthday = PropertySeg2;
1478 if (!PropertyTokens.IsEmpty()){
1480 BirthdayTokens = PropertyTokens;
1486 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1488 // Process date. Preserve the remainder in the string.
1490 std::map<int, int> SplitPoints;
1491 std::map<int, int> SplitLength;
1492 std::map<int, int>::iterator SLiter;
1493 wxString PropertyData;
1494 wxString PropertyName;
1495 wxString PropertyValue;
1496 wxString PropertyTokens;
1497 bool AnniversaryText = FALSE;
1498 int intPrevValue = 13;
1500 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1504 // Look for type before continuing.
1506 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1507 intiter != SplitPoints.end(); ++intiter){
1509 SLiter = SplitLength.find(intiter->first);
1511 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1513 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1514 PropertyName = PropertyElement.GetNextToken();
1515 PropertyValue = PropertyElement.GetNextToken();
1517 intPrevValue = intiter->second;
1519 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1521 CaptureString(&PropertySeg2, FALSE);
1522 Anniversary = PropertySeg2;
1523 AnniversaryText = TRUE;
1529 // Setup blank lines for later on.
1532 bool FirstToken = TRUE;
1534 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1535 intiter != SplitPoints.end(); ++intiter){
1537 SLiter = SplitLength.find(intiter->first);
1539 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1541 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1542 PropertyName = PropertyElement.GetNextToken();
1543 PropertyValue = PropertyElement.GetNextToken();
1545 intPrevValue = intiter->second;
1547 // Process properties.
1549 CaptureString(&PropertyValue, FALSE);
1551 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1553 PropertyValue.Trim();
1554 PropertyValue.RemoveLast();
1558 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1560 PropertyValue.Remove(0, 1);
1564 if (PropertyName == wxT("ALTID")){
1566 AnniversaryAltID = PropertyValue;
1568 } else if (PropertyName == wxT("CALSCALE")){
1570 AnniversaryCalScale = PropertyValue;
1572 } else if (PropertyName != wxT("VALUE")) {
1574 // Something else we don't know about so append
1575 // to the tokens variable.
1577 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1579 if (FirstToken == TRUE){
1581 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1586 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1596 // Add the data to the variables and form.
1598 if (AnniversaryText == FALSE){
1600 Anniversary = PropertySeg2;
1604 if (!PropertyTokens.IsEmpty()){
1606 AnniversaryTokens = PropertyTokens;
1612 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1614 std::map<int, int> SplitPoints;
1615 std::map<int, int> SplitLength;
1617 int intPrevValue = 4;
1620 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1624 PropertyType PropType = PROPERTY_NONE;
1626 // Look for type before continuing.
1628 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1632 std::map<int, wxString> *TZList = NULL;
1633 std::map<int, wxString> *TZListType = NULL;
1634 std::map<int, wxString> *TZListMediatype = NULL;
1635 std::map<int, wxString> *TZListAltID = NULL;
1636 std::map<int, wxString> *TZListPID = NULL;
1637 std::map<int, wxString> *TZListTokens = NULL;
1638 std::map<int, int> *TZListPref = NULL;
1642 TZList = &GeneralTZList;
1643 TZListType = &GeneralTZListType;
1644 TZListMediatype = &GeneralTZListMediatype;
1645 TZListAltID = &GeneralTZListAltID;
1646 TZListPID = &GeneralTZListPID;
1647 TZListTokens = &GeneralTZListTokens;
1648 TZListPref = &GeneralTZListPref;
1651 TZList = &HomeTZList;
1652 TZListType = &HomeTZListType;
1653 TZListMediatype = &HomeTZListMediatype;
1654 TZListAltID = &HomeTZListAltID;
1655 TZListPID = &HomeTZListPID;
1656 TZListTokens = &HomeTZListTokens;
1657 TZListPref = &HomeTZListPref;
1660 TZList = &BusinessTZList;
1661 TZListType = &BusinessTZListType;
1662 TZListMediatype = &BusinessTZListMediatype;
1663 TZListAltID = &BusinessTZListAltID;
1664 TZListPID = &BusinessTZListPID;
1665 TZListTokens = &BusinessTZListTokens;
1666 TZListPref = &BusinessTZListPref;
1670 std::map<int, int>::iterator SLiter;
1671 wxString PropertyData;
1672 wxString PropertyName;
1673 wxString PropertyValue;
1674 wxString PropertyTokens;
1675 bool FirstToken = TRUE;
1677 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1678 intiter != SplitPoints.end(); ++intiter){
1680 SLiter = SplitLength.find(intiter->first);
1682 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1684 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1685 PropertyName = PropertyElement.GetNextToken();
1686 PropertyValue = PropertyElement.GetNextToken();
1688 intPrevValue = intiter->second;
1690 CaptureString(&PropertyValue, FALSE);
1692 if (PropertyName == wxT("ALTID")){
1694 TZListAltID->erase(*TimeZoneCount);
1695 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1697 } else if (PropertyName == wxT("PID")){
1699 TZListPID->erase(*TimeZoneCount);
1700 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1702 } else if (PropertyName == wxT("PREF")){
1704 ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount);
1706 } else if (PropertyName == wxT("MEDIATYPE")){
1708 TZListMediatype->erase(*TimeZoneCount);
1709 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1713 // Something else we don't know about so append
1714 // to the tokens variable.
1716 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1718 if (FirstToken == TRUE){
1720 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1725 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1735 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1737 // Add the name token data.
1739 if (!PropertyTokens.IsEmpty()){
1741 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1748 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1750 size_t intPropertyLen = PropertySeg1.Len();
1751 std::map<int, int> SplitPoints;
1752 std::map<int, int> SplitLength;
1753 std::map<int, int>::iterator SLiter;
1754 wxString PropertyData;
1755 wxString PropertyName;
1756 wxString PropertyValue;
1757 wxString PropertyTokens;
1758 wxString AddressLabel;
1759 wxString AddressLang;
1760 wxString AddressAltID;
1761 wxString AddressPID;
1762 wxString AddressTokens;
1763 wxString AddressGeo;
1764 wxString AddressTimezone;
1765 wxString AddressType;
1766 wxString AddressMediatype;
1767 wxString AddressPOBox;
1768 wxString AddressExtended;
1769 wxString AddressStreet;
1770 wxString AddressLocality;
1771 wxString AddressCity;
1772 wxString AddressRegion;
1773 wxString AddressPostalCode;
1774 wxString AddressCountry;
1775 bool FirstToken = TRUE;
1776 int intSplitsFound = 0;
1777 int intSplitSize = 0;
1778 int intPrevValue = 5;
1783 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1787 PropertyType PropType = PROPERTY_NONE;
1789 // Look for type before continuing.
1791 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1795 std::map<int, wxString> *AddressList = NULL;
1796 std::map<int, wxString> *AddressListTown = NULL;
1797 std::map<int, wxString> *AddressListCounty = NULL;
1798 std::map<int, wxString> *AddressListPostCode = NULL;
1799 std::map<int, wxString> *AddressListCountry = NULL;
1800 std::map<int, wxString> *AddressListLabel = NULL;
1801 std::map<int, wxString> *AddressListLang = NULL;
1802 std::map<int, wxString> *AddressListAltID = NULL;
1803 std::map<int, wxString> *AddressListPID = NULL;
1804 std::map<int, wxString> *AddressListTokens = NULL;
1805 std::map<int, wxString> *AddressListGeo = NULL;
1806 std::map<int, wxString> *AddressListTimezone = NULL;
1807 std::map<int, wxString> *AddressListType = NULL;
1808 std::map<int, wxString> *AddressListMediatype = NULL;
1809 std::map<int, int> *AddressListPref = NULL;
1813 AddressList = &GeneralAddressList;
1814 AddressListTown = &GeneralAddressListTown;
1815 AddressListCounty = &GeneralAddressListCounty;
1816 AddressListPostCode = &GeneralAddressListPostCode;
1817 AddressListCountry = &GeneralAddressListCountry;
1818 AddressListLabel = &GeneralAddressListLabel;
1819 AddressListLang = &GeneralAddressListLang;
1820 AddressListAltID = &GeneralAddressListAltID;
1821 AddressListPID = &GeneralAddressListPID;
1822 AddressListTokens = &GeneralAddressListTokens;
1823 AddressListGeo = &GeneralAddressListGeo;
1824 AddressListTimezone = &GeneralAddressListTimezone;
1825 AddressListType = &GeneralAddressListType;
1826 AddressListMediatype = &GeneralAddressListMediatype;
1827 AddressListPref = &GeneralAddressListPref;
1830 AddressList = &HomeAddressList;
1831 AddressListTown = &HomeAddressListTown;
1832 AddressListCounty = &HomeAddressListCounty;
1833 AddressListPostCode = &HomeAddressListPostCode;
1834 AddressListCountry = &HomeAddressListCountry;
1835 AddressListLabel = &HomeAddressListLabel;
1836 AddressListLang = &HomeAddressListLang;
1837 AddressListAltID = &HomeAddressListAltID;
1838 AddressListPID = &HomeAddressListPID;
1839 AddressListTokens = &HomeAddressListTokens;
1840 AddressListGeo = &HomeAddressListGeo;
1841 AddressListTimezone = &HomeAddressListTimezone;
1842 AddressListType = &HomeAddressListType;
1843 AddressListMediatype = &HomeAddressListMediatype;
1844 AddressListPref = &HomeAddressListPref;
1847 AddressList = &BusinessAddressList;
1848 AddressListTown = &BusinessAddressListTown;
1849 AddressListCounty = &BusinessAddressListCounty;
1850 AddressListPostCode = &BusinessAddressListPostCode;
1851 AddressListCountry = &BusinessAddressListCountry;
1852 AddressListLabel = &BusinessAddressListLabel;
1853 AddressListLang = &BusinessAddressListLang;
1854 AddressListAltID = &BusinessAddressListAltID;
1855 AddressListPID = &BusinessAddressListPID;
1856 AddressListTokens = &BusinessAddressListTokens;
1857 AddressListGeo = &BusinessAddressListGeo;
1858 AddressListTimezone = &BusinessAddressListTimezone;
1859 AddressListType = &BusinessAddressListType;
1860 AddressListMediatype = &BusinessAddressListMediatype;
1861 AddressListPref = &BusinessAddressListPref;
1867 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1868 intiter != SplitPoints.end(); ++intiter){
1870 SLiter = SplitLength.find(intiter->first);
1872 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1874 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1875 PropertyName = PropertyElement.GetNextToken();
1876 PropertyValue = PropertyElement.GetNextToken();
1878 intPrevValue = intiter->second;
1880 CaptureString(&PropertyValue, FALSE);
1882 // Process properties.
1884 if (PropertyName == wxT("LABEL")){
1886 AddressListLabel->erase(*AddressCount);
1887 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1889 } else if (PropertyName == wxT("LANGUAGE")){
1891 AddressListLang->erase(*AddressCount);
1892 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1894 } else if (PropertyName == wxT("ALTID")){
1896 AddressListAltID->erase(*AddressCount);
1897 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1899 } else if (PropertyName == wxT("PID")){
1901 AddressListPID->erase(*AddressCount);
1902 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1904 } else if (PropertyName == wxT("GEO")){
1906 AddressListGeo->erase(*AddressCount);
1907 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1909 } else if (PropertyName == wxT("TZ")){
1911 AddressListTimezone->erase(*AddressCount);
1912 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1914 } else if (PropertyName == wxT("MEDIATYPE")){
1916 AddressListMediatype->erase(*AddressCount);
1917 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1919 } else if (PropertyName == wxT("PREF")){
1921 int PriorityNumber = 0;
1922 bool ValidNumber = TRUE;
1925 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1928 catch(std::invalid_argument &e){
1929 ValidNumber = FALSE;
1932 if (ValidNumber == TRUE){
1934 AddressListPref->erase(*AddressCount);
1935 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1941 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1943 if (FirstToken == TRUE){
1945 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1950 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1960 // Split the address.
1962 //std::map<int, int>::iterator SLiter;
1963 intPropertyLen = PropertySeg2.Len();
1964 SplitPoints.clear();
1965 SplitLength.clear();
1970 for (int i = 0; i <= intPropertyLen; i++){
1974 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1977 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1979 if (intSplitsFound == 6){
1981 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1986 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1996 // Split the data into several parts.
1998 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1999 intiter != SplitPoints.end(); ++intiter){
2001 if (intiter->first == 1){
2003 // Deal with PO Box.
2005 SLiter = SplitLength.find(1);
2007 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2008 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2009 intPrevValue = intiter->second;
2011 } else if (intiter->first == 2){
2013 // Deal with extended address.
2015 SLiter = SplitLength.find(2);
2017 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2018 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2019 intPrevValue = intiter->second;
2021 } else if (intiter->first == 3){
2023 // Deal with street address.
2025 SLiter = SplitLength.find(3);
2027 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2028 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2029 intPrevValue = intiter->second;
2031 } else if (intiter->first == 4){
2033 // Deal with locality
2035 SLiter = SplitLength.find(4);
2037 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2038 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2039 intPrevValue = intiter->second;
2041 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2043 } else if (intiter->first == 5){
2045 // Deal with region.
2047 SLiter = SplitLength.find(5);
2049 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2050 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2051 intPrevValue = intiter->second;
2053 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2055 } else if (intiter->first == 6){
2057 // Deal with post code.
2059 SLiter = SplitLength.find(6);
2061 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2062 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2063 intPrevValue = intiter->second;
2065 // Deal with country.
2067 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2068 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2076 // Add the data to the General/Home/Work address variables.
2078 CaptureString(&AddressStreet, FALSE);
2079 CaptureString(&AddressLocality, FALSE);
2080 CaptureString(&AddressRegion, FALSE);
2081 CaptureString(&AddressPostalCode, FALSE);
2082 CaptureString(&AddressCountry, FALSE);
2084 if (!PropertyTokens.IsEmpty()){
2086 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2090 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2091 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2092 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2093 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2094 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2098 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2101 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2104 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2108 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2112 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2114 std::map<int, int> SplitPoints;
2115 std::map<int, int> SplitLength;
2117 int intPrevValue = 7;
2120 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2124 PropertyType PropType = PROPERTY_NONE;
2126 // Look for type before continuing.
2128 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2130 std::map<int, wxString> *EmailList = NULL;
2131 std::map<int, wxString> *EmailListType = NULL;
2132 std::map<int, wxString> *EmailListAltID = NULL;
2133 std::map<int, wxString> *EmailListPID = NULL;
2134 std::map<int, wxString> *EmailListTokens = NULL;
2135 std::map<int, int> *EmailListPref = NULL;
2139 EmailList = &GeneralEmailList;
2140 EmailListType = &GeneralEmailListType;
2141 EmailListAltID = &GeneralEmailListAltID;
2142 EmailListPID = &GeneralEmailListPID;
2143 EmailListTokens = &GeneralEmailListTokens;
2144 EmailListPref = &GeneralEmailListPref;
2147 EmailList = &HomeEmailList;
2148 EmailListType = &HomeEmailListType;
2149 EmailListAltID = &HomeEmailListAltID;
2150 EmailListPID = &HomeEmailListPID;
2151 EmailListTokens = &HomeEmailListTokens;
2152 EmailListPref = &HomeEmailListPref;
2155 EmailList = &BusinessEmailList;
2156 EmailListType = &BusinessEmailListType;
2157 EmailListAltID = &BusinessEmailListAltID;
2158 EmailListPID = &BusinessEmailListPID;
2159 EmailListTokens = &BusinessEmailListTokens;
2160 EmailListPref = &BusinessEmailListPref;
2166 std::map<int,int>::iterator SLiter;
2167 wxString PropertyData;
2168 wxString PropertyName;
2169 wxString PropertyValue;
2170 wxString PropertyTokens;
2171 bool FirstToken = TRUE;
2173 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2174 intiter != SplitPoints.end(); ++intiter){
2176 SLiter = SplitLength.find(intiter->first);
2178 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2180 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2181 PropertyName = PropertyElement.GetNextToken();
2182 PropertyValue = PropertyElement.GetNextToken();
2184 intPrevValue = intiter->second;
2186 CaptureString(&PropertyValue, FALSE);
2188 // Process properties.
2190 if (PropertyName == wxT("ALTID")){
2192 EmailListAltID->erase(*EmailCount);
2193 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2195 } else if (PropertyName == wxT("PID")){
2197 EmailListPID->erase(*EmailCount);
2198 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2200 } else if (PropertyName == wxT("PREF")){
2202 int PriorityNumber = 0;
2203 bool ValidNumber = TRUE;
2206 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2209 catch(std::invalid_argument &e){
2210 ValidNumber = FALSE;
2213 if (ValidNumber == TRUE){
2215 EmailListPref->erase(*EmailCount);
2216 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2222 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2224 if (FirstToken == TRUE){
2226 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2231 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2241 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2243 // Add the name token data.
2245 if (!PropertyTokens.IsEmpty()){
2247 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2254 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2256 std::map<int, int> SplitPoints;
2257 std::map<int, int> SplitLength;
2259 int intPrevValue = 6;
2262 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2266 PropertyType PropType = PROPERTY_NONE;
2268 // Look for type before continuing.
2270 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2272 std::map<int, wxString> *IMList = NULL;
2273 std::map<int, wxString> *IMListType = NULL;
2274 std::map<int, wxString> *IMListAltID = NULL;
2275 std::map<int, wxString> *IMListPID = NULL;
2276 std::map<int, wxString> *IMListTokens = NULL;
2277 std::map<int, wxString> *IMListMediatype = NULL;
2278 std::map<int, int> *IMListPref = NULL;
2282 IMList = &GeneralIMList;
2283 IMListType = &GeneralIMListType;
2284 IMListAltID = &GeneralIMListAltID;
2285 IMListPID = &GeneralIMListPID;
2286 IMListTokens = &GeneralIMListTokens;
2287 IMListMediatype = &GeneralIMListMediatype;
2288 IMListPref = &GeneralIMListPref;
2291 IMList = &HomeIMList;
2292 IMListType = &HomeIMListType;
2293 IMListAltID = &HomeIMListAltID;
2294 IMListPID = &HomeIMListPID;
2295 IMListTokens = &HomeIMListTokens;
2296 IMListMediatype = &HomeIMListMediatype;
2297 IMListPref = &HomeIMListPref;
2300 IMList = &BusinessIMList;
2301 IMListType = &BusinessIMListType;
2302 IMListAltID = &BusinessIMListAltID;
2303 IMListPID = &BusinessIMListPID;
2304 IMListTokens = &BusinessIMListTokens;
2305 IMListMediatype = &BusinessIMListMediatype;
2306 IMListPref = &BusinessIMListPref;
2312 std::map<int,int>::iterator SLiter;
2313 wxString PropertyData;
2314 wxString PropertyName;
2315 wxString PropertyValue;
2316 wxString PropertyTokens;
2317 bool FirstToken = TRUE;
2319 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2320 intiter != SplitPoints.end(); ++intiter){
2322 SLiter = SplitLength.find(intiter->first);
2324 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2326 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2327 PropertyName = PropertyElement.GetNextToken();
2328 PropertyValue = PropertyElement.GetNextToken();
2330 intPrevValue = intiter->second;
2332 CaptureString(&PropertyValue, FALSE);
2334 // Process properties.
2336 if (PropertyName == wxT("ALTID")){
2338 IMListAltID->erase(*IMCount);
2339 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2341 } else if (PropertyName == wxT("PID")){
2343 IMListPID->erase(*IMCount);
2344 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2346 } else if (PropertyName == wxT("MEDIATYPE")){
2348 IMListMediatype->erase(*IMCount);
2349 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2351 } else if (PropertyName == wxT("PREF")){
2353 int PriorityNumber = 0;
2354 bool ValidNumber = TRUE;
2357 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2360 catch(std::invalid_argument &e){
2361 ValidNumber = FALSE;
2364 if (ValidNumber == TRUE){
2366 IMListPref->erase(*IMCount);
2367 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2373 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2375 if (FirstToken == TRUE){
2377 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2382 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2392 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2394 // Add the name token data.
2396 if (!PropertyTokens.IsEmpty()){
2398 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2404 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2406 std::map<int, int> SplitPoints;
2407 std::map<int, int> SplitLength;
2408 std::map<int, int>::iterator SLiter;
2412 PropertyType PropType = PROPERTY_NONE;
2414 // Look for type before continuing.
2417 wxString TelTypeDetail;
2418 wxString PropertyData;
2419 wxString PropertyName;
2420 wxString PropertyValue;
2421 wxString PropertyTokens;
2423 std::map<int,int> TypeSplitPoints;
2424 std::map<int,int> TypeSplitLength;
2425 std::map<int,int>::iterator TSLiter;
2427 int intSplitSize = 0;
2428 int intSplitsFound = 0;
2429 int intSplitPoint = 0;
2431 int intPrevValue = 5;
2433 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2437 // Look for type before continuing.
2439 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2440 intiter != SplitPoints.end(); ++intiter){
2442 SLiter = SplitLength.find(intiter->first);
2444 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2446 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2447 PropertyName = PropertyElement.GetNextToken();
2448 PropertyValue = PropertyElement.GetNextToken();
2450 intPrevValue = intiter->second;
2452 if (PropertyName == wxT("TYPE")){
2454 // Process each value in type and translate each
2457 // Strip out the quotes if they are there.
2459 size_t intPropertyValueLen = PropertyValue.Len();
2461 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2463 PropertyValue.Trim();
2464 PropertyValue.RemoveLast();
2468 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2470 PropertyValue.Remove(0, 1);
2474 TelTypeDetail = PropertyValue;
2480 for (int i = 0; i <= intPropertyValueLen; i++){
2484 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2486 if (intSplitsFound == 0){
2488 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2489 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2493 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2494 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2507 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2508 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2510 int intTypeSeek = 0;
2512 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2513 typeiter != TypeSplitPoints.end(); ++typeiter){
2515 wxString TypePropertyName;
2517 TSLiter = TypeSplitLength.find(typeiter->first);
2519 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2521 if (intTypeSeek == 0){
2526 TelTypeUI.Append(wxT(","));
2530 if (TypePropertyName == wxT("home")){
2532 PropType = PROPERTY_HOME;
2534 } else if (TypePropertyName == wxT("work")){
2536 PropType = PROPERTY_WORK;
2541 if (TypePropertyName == wxT("text")){
2543 TelTypeUI.Append(_("text"));
2546 } else if (TypePropertyName == wxT("voice")){
2548 TelTypeUI.Append(_("voice"));
2551 } else if (TypePropertyName == wxT("fax")){
2553 TelTypeUI.Append(_("fax"));
2556 } else if (TypePropertyName == wxT("cell")){
2558 TelTypeUI.Append(_("mobile"));
2561 } else if (TypePropertyName == wxT("video")){
2563 TelTypeUI.Append(_("video"));
2566 } else if (TypePropertyName == wxT("pager")){
2568 TelTypeUI.Append(_("pager"));
2571 } else if (TypePropertyName == wxT("textphone")){
2573 TelTypeUI.Append(_("textphone"));
2584 std::map<int, wxString> *TelephoneList = NULL;
2585 std::map<int, wxString> *TelephoneListType = NULL;
2586 std::map<int, wxString> *TelephoneListAltID = NULL;
2587 std::map<int, wxString> *TelephoneListPID = NULL;
2588 std::map<int, wxString> *TelephoneListTokens = NULL;
2589 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2590 std::map<int, int> *TelephoneListPref = NULL;
2594 TelephoneList = &GeneralTelephoneList;
2595 TelephoneListType = &GeneralTelephoneListType;
2596 TelephoneListAltID = &GeneralTelephoneListAltID;
2597 TelephoneListPID = &GeneralTelephoneListPID;
2598 TelephoneListTokens = &GeneralTelephoneListTokens;
2599 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2600 TelephoneListPref = &GeneralTelephoneListPref;
2603 TelephoneList = &HomeTelephoneList;
2604 TelephoneListType = &HomeTelephoneListType;
2605 TelephoneListAltID = &HomeTelephoneListAltID;
2606 TelephoneListPID = &HomeTelephoneListPID;
2607 TelephoneListTokens = &HomeTelephoneListTokens;
2608 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2609 TelephoneListPref = &HomeTelephoneListPref;
2612 TelephoneList = &BusinessTelephoneList;
2613 TelephoneListType = &BusinessTelephoneListType;
2614 TelephoneListAltID = &BusinessTelephoneListAltID;
2615 TelephoneListPID = &BusinessTelephoneListPID;
2616 TelephoneListTokens = &BusinessTelephoneListTokens;
2617 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2618 TelephoneListPref = &BusinessTelephoneListPref;
2622 // Process the properties.
2624 bool FirstToken = TRUE;
2627 SplitPoints.clear();
2628 SplitLength.clear();
2630 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2634 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2635 intiter != SplitPoints.end(); ++intiter){
2637 SLiter = SplitLength.find(intiter->first);
2639 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2641 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2642 PropertyName = PropertyElement.GetNextToken();
2643 PropertyValue = PropertyElement.GetNextToken();
2645 intPrevValue = intiter->second;
2647 CaptureString(&PropertyValue, FALSE);
2649 // Process properties.
2651 if (PropertyName == wxT("ALTID")){
2653 TelephoneListAltID->erase(*TelephoneCount);
2654 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2656 } else if (PropertyName == wxT("PID")){
2658 TelephoneListPID->erase(*TelephoneCount);
2659 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2661 } else if (PropertyName == wxT("PREF")){
2663 int PriorityNumber = 0;
2664 bool ValidNumber = TRUE;
2667 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2670 catch(std::invalid_argument &e){
2671 ValidNumber = FALSE;
2674 if (ValidNumber == TRUE){
2676 TelephoneListPref->erase(*TelephoneCount);
2677 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2683 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2685 if (FirstToken == TRUE){
2687 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2692 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2702 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2703 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2705 // Add the name token data.
2707 if (!PropertyTokens.IsEmpty()){
2709 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2715 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2717 std::map<int, int> SplitPoints;
2718 std::map<int, int> SplitLength;
2720 int intPrevValue = 6;
2723 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2727 PropertyType PropType = PROPERTY_NONE;
2729 // Look for type before continuing.
2731 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2733 std::map<int, wxString> *LanguageList = NULL;
2734 std::map<int, wxString> *LanguageListType = NULL;
2735 std::map<int, wxString> *LanguageListAltID = NULL;
2736 std::map<int, wxString> *LanguageListPID = NULL;
2737 std::map<int, wxString> *LanguageListTokens = NULL;
2738 std::map<int, int> *LanguageListPref = NULL;
2742 LanguageList = &GeneralLanguageList;
2743 LanguageListType = &GeneralLanguageListType;
2744 LanguageListAltID = &GeneralLanguageListAltID;
2745 LanguageListPID = &GeneralLanguageListPID;
2746 LanguageListTokens = &GeneralLanguageListTokens;
2747 LanguageListPref = &GeneralLanguageListPref;
2750 LanguageList = &HomeLanguageList;
2751 LanguageListType = &HomeLanguageListType;
2752 LanguageListAltID = &HomeLanguageListAltID;
2753 LanguageListPID = &HomeLanguageListPID;
2754 LanguageListTokens = &HomeLanguageListTokens;
2755 LanguageListPref = &HomeLanguageListPref;
2758 LanguageList = &BusinessLanguageList;
2759 LanguageListType = &BusinessLanguageListType;
2760 LanguageListAltID = &BusinessLanguageListAltID;
2761 LanguageListPID = &BusinessLanguageListPID;
2762 LanguageListTokens = &BusinessLanguageListTokens;
2763 LanguageListPref = &BusinessLanguageListPref;
2769 std::map<int,int>::iterator SLiter;
2770 wxString PropertyData;
2771 wxString PropertyName;
2772 wxString PropertyValue;
2773 wxString PropertyTokens;
2774 bool FirstToken = TRUE;
2776 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2777 intiter != SplitPoints.end(); ++intiter){
2779 SLiter = SplitLength.find(intiter->first);
2781 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2783 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2784 PropertyName = PropertyElement.GetNextToken();
2785 PropertyValue = PropertyElement.GetNextToken();
2787 intPrevValue = intiter->second;
2789 CaptureString(&PropertyValue, FALSE);
2791 // Process properties.
2793 if (PropertyName == wxT("ALTID")){
2795 LanguageListAltID->erase(*LanguageCount);
2796 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2798 } else if (PropertyName == wxT("PID")){
2800 LanguageListPID->erase(*LanguageCount);
2801 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2803 } else if (PropertyName == wxT("PREF")){
2805 int PriorityNumber = 0;
2806 bool ValidNumber = TRUE;
2809 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2812 catch(std::invalid_argument &e){
2813 ValidNumber = FALSE;
2816 if (ValidNumber == TRUE){
2818 LanguageListPref->erase(*LanguageCount);
2819 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2825 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2827 if (FirstToken == TRUE){
2829 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2834 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2844 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2846 // Add the name token data.
2848 if (!PropertyTokens.IsEmpty()){
2850 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2856 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2858 std::map<int, int> SplitPoints;
2859 std::map<int, int> SplitLength;
2861 int intPrevValue = 5;
2864 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2868 PropertyType PropType = PROPERTY_NONE;
2870 // Look for type before continuing.
2872 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2874 std::map<int, wxString> *GeopositionList = NULL;
2875 std::map<int, wxString> *GeopositionListType = NULL;
2876 std::map<int, wxString> *GeopositionListAltID = NULL;
2877 std::map<int, wxString> *GeopositionListPID = NULL;
2878 std::map<int, wxString> *GeopositionListTokens = NULL;
2879 std::map<int, wxString> *GeopositionListMediatype = NULL;
2880 std::map<int, int> *GeopositionListPref = NULL;
2884 GeopositionList = &GeneralGeographyList;
2885 GeopositionListType = &GeneralGeographyListType;
2886 GeopositionListAltID = &GeneralGeographyListAltID;
2887 GeopositionListPID = &GeneralGeographyListPID;
2888 GeopositionListTokens = &GeneralGeographyListTokens;
2889 GeopositionListMediatype = &GeneralGeographyListMediatype;
2890 GeopositionListPref = &GeneralGeographyListPref;
2893 GeopositionList = &HomeGeographyList;
2894 GeopositionListType = &HomeGeographyListType;
2895 GeopositionListAltID = &HomeGeographyListAltID;
2896 GeopositionListPID = &HomeGeographyListPID;
2897 GeopositionListTokens = &HomeGeographyListTokens;
2898 GeopositionListMediatype = &HomeGeographyListMediatype;
2899 GeopositionListPref = &HomeGeographyListPref;
2902 GeopositionList = &BusinessGeographyList;
2903 GeopositionListType = &BusinessGeographyListType;
2904 GeopositionListAltID = &BusinessGeographyListAltID;
2905 GeopositionListPID = &BusinessGeographyListPID;
2906 GeopositionListTokens = &BusinessGeographyListTokens;
2907 GeopositionListMediatype = &BusinessGeographyListMediatype;
2908 GeopositionListPref = &BusinessGeographyListPref;
2914 std::map<int,int>::iterator SLiter;
2915 wxString PropertyData;
2916 wxString PropertyName;
2917 wxString PropertyValue;
2918 wxString PropertyTokens;
2919 bool FirstToken = TRUE;
2921 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2922 intiter != SplitPoints.end(); ++intiter){
2924 SLiter = SplitLength.find(intiter->first);
2926 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2928 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2929 PropertyName = PropertyElement.GetNextToken();
2930 PropertyValue = PropertyElement.GetNextToken();
2932 intPrevValue = intiter->second;
2934 CaptureString(&PropertyValue, FALSE);
2936 // Process properties.
2938 if (PropertyName == wxT("ALTID")){
2940 GeopositionListAltID->erase(*GeographicCount);
2941 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2943 } else if (PropertyName == wxT("PID")){
2945 GeopositionListPID->erase(*GeographicCount);
2946 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2948 } else if (PropertyName == wxT("MEDIATYPE")){
2950 GeopositionListMediatype->erase(*GeographicCount);
2951 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2953 } else if (PropertyName == wxT("PREF")){
2955 int PriorityNumber = 0;
2956 bool ValidNumber = TRUE;
2959 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2962 catch(std::invalid_argument &e){
2963 ValidNumber = FALSE;
2966 if (ValidNumber == TRUE){
2968 GeopositionListPref->erase(*GeographicCount);
2969 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2975 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2977 if (FirstToken == TRUE){
2979 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2984 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2994 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2996 // Add the name token data.
2998 if (!PropertyTokens.IsEmpty()){
3000 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3006 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3008 size_t intPropertyLen = PropertySeg1.Len();
3009 std::map<int, int> SplitPoints;
3010 std::map<int, int> SplitLength;
3011 std::map<int, int>::iterator SLiter;
3012 wxString PropertyData;
3013 wxString PropertyName;
3014 wxString PropertyValue;
3015 wxString PropertyTokens;
3016 wxString RelatedType;
3017 wxString RelatedTypeOriginal;
3018 wxString RelatedName;
3019 bool FirstToken = TRUE;
3020 int intSplitsFound = 0;
3021 int intSplitSize = 0;
3022 int intPrevValue = 9;
3026 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3030 // Look for type before continuing.
3032 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3033 intiter != SplitPoints.end(); ++intiter){
3035 SLiter = SplitLength.find(intiter->first);
3037 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3039 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3040 PropertyName = PropertyElement.GetNextToken();
3041 PropertyValue = PropertyElement.GetNextToken();
3043 intPrevValue = intiter->second;
3047 RelatedTypeOriginal = PropertyValue;
3049 if (PropertyName == wxT("TYPE")){
3051 if (PropertyValue == wxT("contact")){
3053 RelatedType = _("Contact");
3055 } else if (PropertyValue == wxT("acquaintance")){
3057 RelatedType = _("Acquaintance");
3059 } else if (PropertyValue == wxT("friend")){
3061 RelatedType = _("Friend");
3063 } else if (PropertyValue == wxT("met")){
3065 RelatedType = _("Met");
3067 } else if (PropertyValue == wxT("co-worker")){
3069 RelatedType = _("Co-worker");
3071 } else if (PropertyValue == wxT("colleague")){
3073 RelatedType = _("Colleague");
3075 } else if (PropertyValue == wxT("co-resident")){
3077 RelatedType = _("Co-resident");
3079 } else if (PropertyValue == wxT("neighbor")){
3081 RelatedType = _("Neighbour");
3083 } else if (PropertyValue == wxT("child")){
3085 RelatedType = _("Child");
3087 } else if (PropertyValue == wxT("parent")){
3089 RelatedType = _("Parent");
3091 } else if (PropertyValue == wxT("sibling")){
3093 RelatedType = _("Sibling");
3095 } else if (PropertyValue == wxT("spouse")){
3097 RelatedType = _("Spouse");
3099 } else if (PropertyValue == wxT("kin")){
3101 RelatedType = _("Kin");
3103 } else if (PropertyValue == wxT("muse")){
3105 RelatedType = _("Muse");
3107 } else if (PropertyValue == wxT("crush")){
3109 RelatedType = _("Crush");
3111 } else if (PropertyValue == wxT("date")){
3113 RelatedType = _("Date");
3115 } else if (PropertyValue == wxT("sweetheart")){
3117 RelatedType = _("Sweetheart");
3119 } else if (PropertyValue == wxT("me")){
3121 RelatedType = _("Me");
3123 } else if (PropertyValue == wxT("agent")){
3125 RelatedType = _("Agent");
3127 } else if (PropertyValue == wxT("emergency")){
3129 RelatedType = _("Emergency");
3133 RelatedType = PropertyValue;
3143 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3144 intiter != SplitPoints.end(); ++intiter){
3146 SLiter = SplitLength.find(intiter->first);
3148 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3150 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3151 PropertyName = PropertyElement.GetNextToken();
3152 PropertyValue = PropertyElement.GetNextToken();
3154 intPrevValue = intiter->second;
3156 // Process properties.
3158 size_t intPropertyValueLen = PropertyValue.Len();
3160 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3162 PropertyValue.Trim();
3163 PropertyValue.RemoveLast();
3167 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3169 PropertyValue.Remove(0, 1);
3173 CaptureString(&PropertyValue, FALSE);
3175 if (PropertyName == wxT("ALTID")){
3177 GeneralRelatedListAltID.erase(*RelatedCount);
3178 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3180 } else if (PropertyName == wxT("PID")){
3182 GeneralRelatedListPID.erase(*RelatedCount);
3183 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3185 } else if (PropertyName == wxT("PREF")){
3187 int PriorityNumber = 0;
3188 bool ValidNumber = TRUE;
3191 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3194 catch(std::invalid_argument &e){
3195 ValidNumber = FALSE;
3198 if (ValidNumber == TRUE){
3200 GeneralRelatedListPref.erase(*RelatedCount);
3201 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3205 } else if (PropertyName == wxT("LANGUAGE")){
3207 GeneralRelatedListLanguage.erase(*RelatedCount);
3208 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3210 } else if (PropertyName != wxT("TYPE")) {
3212 // Something else we don't know about so append
3213 // to the tokens variable.
3215 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3217 if (FirstToken == TRUE){
3219 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3224 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3234 // Add the data to the General/Home/Work address variables.
3236 GeneralRelatedList.erase(*RelatedCount);
3237 GeneralRelatedListRelType.erase(*RelatedCount);
3238 GeneralRelatedListType.erase(*RelatedCount);
3239 GeneralRelatedListTokens.erase(*RelatedCount);
3240 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3241 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3242 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3243 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3247 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3249 std::map<int, int> SplitPoints;
3250 std::map<int, int> SplitLength;
3251 std::map<int, int>::iterator SLiter;
3252 wxString PropertyData;
3253 wxString PropertyName;
3254 wxString PropertyValue;
3255 wxString PropertyTokens;
3256 bool FirstToken = TRUE;
3257 int intPrevValue = 5;
3262 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3266 PropertyType PropType = PROPERTY_NONE;
3268 // Look for type before continuing.
3270 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3272 // Setup the pointers.
3274 std::map<int, wxString> *WebsiteList = NULL;
3275 std::map<int, wxString> *WebsiteListAltID = NULL;
3276 std::map<int, wxString> *WebsiteListPID = NULL;
3277 std::map<int, wxString> *WebsiteListType = NULL;
3278 std::map<int, wxString> *WebsiteListTokens = NULL;
3279 std::map<int, wxString> *WebsiteListMediatype = NULL;
3280 std::map<int, int> *WebsiteListPref = NULL;
3282 // Setup blank lines for later on.
3286 WebsiteList = &GeneralWebsiteList;
3287 WebsiteListType = &GeneralWebsiteListType;
3288 WebsiteListAltID = &GeneralWebsiteListAltID;
3289 WebsiteListPID = &GeneralWebsiteListPID;
3290 WebsiteListTokens = &GeneralWebsiteListTokens;
3291 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3292 WebsiteListPref = &GeneralWebsiteListPref;
3295 WebsiteList = &HomeWebsiteList;
3296 WebsiteListType = &HomeWebsiteListType;
3297 WebsiteListAltID = &HomeWebsiteListAltID;
3298 WebsiteListPID = &HomeWebsiteListPID;
3299 WebsiteListTokens = &HomeWebsiteListTokens;
3300 WebsiteListMediatype = &HomeWebsiteListMediatype;
3301 WebsiteListPref = &HomeWebsiteListPref;
3304 WebsiteList = &BusinessWebsiteList;
3305 WebsiteListType = &BusinessWebsiteListType;
3306 WebsiteListAltID = &BusinessWebsiteListAltID;
3307 WebsiteListPID = &BusinessWebsiteListPID;
3308 WebsiteListTokens = &BusinessWebsiteListTokens;
3309 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3310 WebsiteListPref = &BusinessWebsiteListPref;
3316 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3317 intiter != SplitPoints.end(); ++intiter){
3319 SLiter = SplitLength.find(intiter->first);
3321 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3323 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3324 PropertyName = PropertyElement.GetNextToken();
3325 PropertyValue = PropertyElement.GetNextToken();
3327 intPrevValue = intiter->second;
3329 // Process properties.
3331 size_t intPropertyValueLen = PropertyValue.Len();
3333 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3335 PropertyValue.Trim();
3336 PropertyValue.RemoveLast();
3340 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3342 PropertyValue.Remove(0, 1);
3346 CaptureString(&PropertyValue, FALSE);
3348 if (PropertyName == wxT("ALTID")){
3350 WebsiteListAltID->erase(*URLCount);
3351 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3353 } else if (PropertyName == wxT("PID")){
3355 WebsiteListPID->erase(*URLCount);
3356 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3358 } else if (PropertyName == wxT("PREF")){
3360 int PriorityNumber = 0;
3361 bool ValidNumber = TRUE;
3364 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3367 catch(std::invalid_argument &e){
3368 ValidNumber = FALSE;
3371 if (ValidNumber == TRUE){
3373 WebsiteListPref->erase(*URLCount);
3374 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3378 } else if (PropertyName == wxT("MEDIATYPE")){
3380 WebsiteListMediatype->erase(*URLCount);
3381 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3385 // Something else we don't know about so append
3386 // to the tokens variable.
3388 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3390 if (FirstToken == TRUE){
3392 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3397 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3407 // Add the data to the General/Home/Work address variables.
3409 CaptureString(&PropertySeg2, FALSE);
3411 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3413 if (!PropertyTokens.IsEmpty()){
3415 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3421 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3423 std::map<int, int> SplitPoints;
3424 std::map<int, int> SplitLength;
3425 std::map<int, int>::iterator SLiter;
3426 wxString PropertyData;
3427 wxString PropertyName;
3428 wxString PropertyValue;
3429 wxString PropertyTokens;
3430 bool FirstToken = TRUE;
3431 int intPrevValue = 7;
3436 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3440 PropertyType PropType = PROPERTY_NONE;
3442 // Look for type before continuing.
3444 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3446 // Setup the pointers.
3448 std::map<int, wxString> *TitleList = NULL;
3449 std::map<int, wxString> *TitleListAltID = NULL;
3450 std::map<int, wxString> *TitleListPID = NULL;
3451 std::map<int, wxString> *TitleListType = NULL;
3452 std::map<int, wxString> *TitleListTokens = NULL;
3453 std::map<int, wxString> *TitleListLanguage = NULL;
3454 std::map<int, int> *TitleListPref = NULL;
3456 // Setup blank lines for later on.
3460 TitleList = &GeneralTitleList;
3461 TitleListType = &GeneralTitleListType;
3462 TitleListAltID = &GeneralTitleListAltID;
3463 TitleListPID = &GeneralTitleListPID;
3464 TitleListTokens = &GeneralTitleListTokens;
3465 TitleListLanguage = &GeneralTitleListLanguage;
3466 TitleListPref = &GeneralTitleListPref;
3469 TitleList = &HomeTitleList;
3470 TitleListType = &HomeTitleListType;
3471 TitleListAltID = &HomeTitleListAltID;
3472 TitleListPID = &HomeTitleListPID;
3473 TitleListTokens = &HomeTitleListTokens;
3474 TitleListLanguage = &HomeTitleListLanguage;
3475 TitleListPref = &HomeTitleListPref;
3478 TitleList = &BusinessTitleList;
3479 TitleListType = &BusinessTitleListType;
3480 TitleListAltID = &BusinessTitleListAltID;
3481 TitleListPID = &BusinessTitleListPID;
3482 TitleListTokens = &BusinessTitleListTokens;
3483 TitleListLanguage = &BusinessTitleListLanguage;
3484 TitleListPref = &BusinessTitleListPref;
3490 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3491 intiter != SplitPoints.end(); ++intiter){
3493 SLiter = SplitLength.find(intiter->first);
3495 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3497 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3498 PropertyName = PropertyElement.GetNextToken();
3499 PropertyValue = PropertyElement.GetNextToken();
3501 intPrevValue = intiter->second;
3503 // Process properties.
3505 size_t intPropertyValueLen = PropertyValue.Len();
3507 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3509 PropertyValue.Trim();
3510 PropertyValue.RemoveLast();
3514 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3516 PropertyValue.Remove(0, 1);
3520 CaptureString(&PropertyValue, FALSE);
3522 if (PropertyName == wxT("ALTID")){
3524 TitleListAltID->erase(*TitleCount);
3525 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3527 } else if (PropertyName == wxT("PID")){
3529 TitleListPID->erase(*TitleCount);
3530 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3532 } else if (PropertyName == wxT("PREF")){
3534 int PriorityNumber = 0;
3535 bool ValidNumber = TRUE;
3538 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3541 catch(std::invalid_argument &e){
3542 ValidNumber = FALSE;
3545 if (ValidNumber == TRUE){
3547 TitleListPref->erase(*TitleCount);
3548 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3552 } else if (PropertyName == wxT("LANGUAGE")){
3554 TitleListLanguage->erase(*TitleCount);
3555 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3559 // Something else we don't know about so append
3560 // to the tokens variable.
3562 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3564 if (FirstToken == TRUE){
3566 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3571 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3581 // Add the data to the General/Home/Work address variables.
3583 CaptureString(&PropertySeg2, FALSE);
3585 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3587 if (!PropertyTokens.IsEmpty()){
3589 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3595 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3597 std::map<int, int> SplitPoints;
3598 std::map<int, int> SplitLength;
3599 std::map<int, int>::iterator SLiter;
3600 wxString PropertyData;
3601 wxString PropertyName;
3602 wxString PropertyValue;
3603 wxString PropertyTokens;
3604 bool FirstToken = TRUE;
3605 int intPrevValue = 6;
3610 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3614 PropertyType PropType = PROPERTY_NONE;
3616 // Look for type before continuing.
3618 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3620 // Setup the pointers.
3622 std::map<int, wxString> *RoleList = NULL;
3623 std::map<int, wxString> *RoleListAltID = NULL;
3624 std::map<int, wxString> *RoleListPID = NULL;
3625 std::map<int, wxString> *RoleListType = NULL;
3626 std::map<int, wxString> *RoleListTokens = NULL;
3627 std::map<int, wxString> *RoleListLanguage = NULL;
3628 std::map<int, int> *RoleListPref = NULL;
3630 // Setup blank lines for later on.
3634 RoleList = &GeneralRoleList;
3635 RoleListType = &GeneralRoleListType;
3636 RoleListAltID = &GeneralRoleListAltID;
3637 RoleListPID = &GeneralRoleListPID;
3638 RoleListTokens = &GeneralRoleListTokens;
3639 RoleListLanguage = &GeneralRoleListLanguage;
3640 RoleListPref = &GeneralRoleListPref;
3643 RoleList = &HomeRoleList;
3644 RoleListType = &HomeRoleListType;
3645 RoleListAltID = &HomeRoleListAltID;
3646 RoleListPID = &HomeRoleListPID;
3647 RoleListTokens = &HomeRoleListTokens;
3648 RoleListLanguage = &HomeRoleListLanguage;
3649 RoleListPref = &HomeRoleListPref;
3652 RoleList = &BusinessRoleList;
3653 RoleListType = &BusinessRoleListType;
3654 RoleListAltID = &BusinessRoleListAltID;
3655 RoleListPID = &BusinessRoleListPID;
3656 RoleListTokens = &BusinessRoleListTokens;
3657 RoleListLanguage = &BusinessRoleListLanguage;
3658 RoleListPref = &BusinessRoleListPref;
3664 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3665 intiter != SplitPoints.end(); ++intiter){
3667 SLiter = SplitLength.find(intiter->first);
3669 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3671 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3672 PropertyName = PropertyElement.GetNextToken();
3673 PropertyValue = PropertyElement.GetNextToken();
3675 intPrevValue = intiter->second;
3677 // Process properties.
3679 size_t intPropertyValueLen = PropertyValue.Len();
3681 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3683 PropertyValue.Trim();
3684 PropertyValue.RemoveLast();
3688 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3690 PropertyValue.Remove(0, 1);
3694 CaptureString(&PropertyValue, FALSE);
3696 if (PropertyName == wxT("ALTID")){
3698 RoleListAltID->erase(*RoleCount);
3699 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3701 } else if (PropertyName == wxT("PID")){
3703 RoleListPID->erase(*RoleCount);
3704 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3706 } else if (PropertyName == wxT("PREF")){
3708 int PriorityNumber = 0;
3709 bool ValidNumber = TRUE;
3712 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3715 catch(std::invalid_argument &e){
3716 ValidNumber = FALSE;
3719 if (ValidNumber == TRUE){
3721 RoleListPref->erase(*RoleCount);
3722 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3726 } else if (PropertyName == wxT("LANGUAGE")){
3728 RoleListLanguage->erase(*RoleCount);
3729 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3733 // Something else we don't know about so append
3734 // to the tokens variable.
3736 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3738 if (FirstToken == TRUE){
3740 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3745 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3755 // Add the data to the General/Home/Work address variables.
3757 CaptureString(&PropertySeg2, FALSE);
3759 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3761 if (!PropertyTokens.IsEmpty()){
3763 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3769 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3771 std::map<int, int> SplitPoints;
3772 std::map<int, int> SplitLength;
3773 std::map<int, int>::iterator SLiter;
3774 wxString PropertyData;
3775 wxString PropertyName;
3776 wxString PropertyValue;
3777 wxString PropertyTokens;
3778 bool FirstToken = TRUE;
3779 int intPrevValue = 5;
3784 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3788 PropertyType PropType = PROPERTY_NONE;
3790 // Look for type before continuing.
3792 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3794 // Setup the pointers.
3796 std::map<int, wxString> *OrganisationsList = NULL;
3797 std::map<int, wxString> *OrganisationsListAltID = NULL;
3798 std::map<int, wxString> *OrganisationsListPID = NULL;
3799 std::map<int, wxString> *OrganisationsListType = NULL;
3800 std::map<int, wxString> *OrganisationsListTokens = NULL;
3801 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3802 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3803 std::map<int, int> *OrganisationsListPref = NULL;
3805 // Setup blank lines for later on.
3809 OrganisationsList = &GeneralOrganisationsList;
3810 OrganisationsListType = &GeneralOrganisationsListType;
3811 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3812 OrganisationsListPID = &GeneralOrganisationsListPID;
3813 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3814 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3815 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3816 OrganisationsListPref = &GeneralOrganisationsListPref;
3819 OrganisationsList = &HomeOrganisationsList;
3820 OrganisationsListType = &HomeOrganisationsListType;
3821 OrganisationsListAltID = &HomeOrganisationsListAltID;
3822 OrganisationsListPID = &HomeOrganisationsListPID;
3823 OrganisationsListTokens = &HomeOrganisationsListTokens;
3824 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3825 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3826 OrganisationsListPref = &HomeOrganisationsListPref;
3829 OrganisationsList = &BusinessOrganisationsList;
3830 OrganisationsListType = &BusinessOrganisationsListType;
3831 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3832 OrganisationsListPID = &BusinessOrganisationsListPID;
3833 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3834 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3835 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3836 OrganisationsListPref = &BusinessOrganisationsListPref;
3842 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3843 intiter != SplitPoints.end(); ++intiter){
3845 SLiter = SplitLength.find(intiter->first);
3847 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3849 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3850 PropertyName = PropertyElement.GetNextToken();
3851 PropertyValue = PropertyElement.GetNextToken();
3853 intPrevValue = intiter->second;
3855 // Process properties.
3857 size_t intPropertyValueLen = PropertyValue.Len();
3859 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3861 PropertyValue.Trim();
3862 PropertyValue.RemoveLast();
3866 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3868 PropertyValue.Remove(0, 1);
3872 CaptureString(&PropertyValue, FALSE);
3874 if (PropertyName == wxT("ALTID")){
3876 OrganisationsListAltID->erase(*OrganisationCount);
3877 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3879 } else if (PropertyName == wxT("PID")){
3881 OrganisationsListPID->erase(*OrganisationCount);
3882 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3884 } else if (PropertyName == wxT("SORT-AS")){
3886 OrganisationsListSortAs->erase(*OrganisationCount);
3887 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3889 } else if (PropertyName == wxT("PREF")){
3891 int PriorityNumber = 0;
3892 bool ValidNumber = TRUE;
3895 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3898 catch(std::invalid_argument &e){
3899 ValidNumber = FALSE;
3902 if (ValidNumber == TRUE){
3904 OrganisationsListPref->erase(*OrganisationCount);
3905 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3909 } else if (PropertyName == wxT("LANGUAGE")){
3911 OrganisationsListLanguage->erase(*OrganisationCount);
3912 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3916 // Something else we don't know about so append
3917 // to the tokens variable.
3919 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3921 if (FirstToken == TRUE){
3923 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3928 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3938 // Add the data to the General/Home/Work address variables.
3940 CaptureString(&PropertySeg2, FALSE);
3942 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3944 if (!PropertyTokens.IsEmpty()){
3946 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3952 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3954 std::map<int, int> SplitPoints;
3955 std::map<int, int> SplitLength;
3956 std::map<int, int>::iterator SLiter;
3957 wxString PropertyData;
3958 wxString PropertyName;
3959 wxString PropertyValue;
3960 wxString PropertyTokens;
3961 bool FirstToken = TRUE;
3962 int intPrevValue = 6;
3967 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3971 PropertyType PropType = PROPERTY_NONE;
3973 // Look for type before continuing.
3975 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3977 // Setup the pointers.
3979 std::map<int, wxString> *NoteList = NULL;
3980 std::map<int, wxString> *NoteListAltID = NULL;
3981 std::map<int, wxString> *NoteListPID = NULL;
3982 std::map<int, wxString> *NoteListType = NULL;
3983 std::map<int, wxString> *NoteListTokens = NULL;
3984 std::map<int, wxString> *NoteListLanguage = NULL;
3985 std::map<int, int> *NoteListPref = NULL;
3987 // Setup blank lines for later on.
3991 NoteList = &GeneralNoteList;
3992 NoteListType = &GeneralNoteListType;
3993 NoteListAltID = &GeneralNoteListAltID;
3994 NoteListPID = &GeneralNoteListPID;
3995 NoteListTokens = &GeneralNoteListTokens;
3996 NoteListLanguage = &GeneralNoteListLanguage;
3997 NoteListPref = &GeneralNoteListPref;
4000 NoteList = &HomeNoteList;
4001 NoteListType = &HomeNoteListType;
4002 NoteListAltID = &HomeNoteListAltID;
4003 NoteListPID = &HomeNoteListPID;
4004 NoteListTokens = &HomeNoteListTokens;
4005 NoteListLanguage = &HomeNoteListLanguage;
4006 NoteListPref = &HomeNoteListPref;
4009 NoteList = &BusinessNoteList;
4010 NoteListType = &BusinessNoteListType;
4011 NoteListAltID = &BusinessNoteListAltID;
4012 NoteListPID = &BusinessNoteListPID;
4013 NoteListTokens = &BusinessNoteListTokens;
4014 NoteListLanguage = &BusinessNoteListLanguage;
4015 NoteListPref = &BusinessNoteListPref;
4021 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4022 intiter != SplitPoints.end(); ++intiter){
4024 SLiter = SplitLength.find(intiter->first);
4026 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4028 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4029 PropertyName = PropertyElement.GetNextToken();
4030 PropertyValue = PropertyElement.GetNextToken();
4032 intPrevValue = intiter->second;
4034 // Process properties.
4036 size_t intPropertyValueLen = PropertyValue.Len();
4038 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4040 PropertyValue.Trim();
4041 PropertyValue.RemoveLast();
4045 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4047 PropertyValue.Remove(0, 1);
4051 CaptureString(&PropertyValue, FALSE);
4053 if (PropertyName == wxT("ALTID")){
4055 NoteListAltID->erase(*NoteCount);
4056 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4058 } else if (PropertyName == wxT("PID")){
4060 NoteListPID->erase(*NoteCount);
4061 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4063 } else if (PropertyName == wxT("PREF")){
4065 int PriorityNumber = 0;
4066 bool ValidNumber = TRUE;
4069 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4072 catch(std::invalid_argument &e){
4073 ValidNumber = FALSE;
4076 if (ValidNumber == TRUE){
4078 NoteListPref->erase(*NoteCount);
4079 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4083 } else if (PropertyName == wxT("LANGUAGE")){
4085 NoteListLanguage->erase(*NoteCount);
4086 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4090 // Something else we don't know about so append
4091 // to the tokens variable.
4093 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4095 if (FirstToken == TRUE){
4097 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4102 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4112 // Add the data to the General/Home/Work address variables.
4114 CaptureString(&PropertySeg2, FALSE);
4116 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4118 if (!PropertyTokens.IsEmpty()){
4120 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4126 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4128 std::map<int, int> SplitPoints;
4129 std::map<int, int> SplitLength;
4130 std::map<int, int>::iterator SLiter;
4131 wxString PropertyData;
4132 wxString PropertyName;
4133 wxString PropertyValue;
4134 wxString PropertyTokens;
4135 bool FirstToken = TRUE;
4136 int intPrevValue = 12;
4141 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4145 PropertyType PropType = PROPERTY_NONE;
4147 // Look for type before continuing.
4149 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4151 // Setup blank lines for later on.
4157 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4160 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4166 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4167 intiter != SplitPoints.end(); ++intiter){
4169 SLiter = SplitLength.find(intiter->first);
4171 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4173 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4174 PropertyName = PropertyElement.GetNextToken();
4175 PropertyValue = PropertyElement.GetNextToken();
4177 intPrevValue = intiter->second;
4179 // Process properties.
4181 size_t intPropertyValueLen = PropertyValue.Len();
4183 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4185 PropertyValue.Trim();
4186 PropertyValue.RemoveLast();
4190 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4192 PropertyValue.Remove(0, 1);
4196 CaptureString(&PropertyValue, FALSE);
4198 if (PropertyName == wxT("ALTID")){
4200 CategoriesListAltID.erase(*CategoryCount);
4201 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4203 } else if (PropertyName == wxT("PID")){
4205 CategoriesListPID.erase(*CategoryCount);
4206 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4208 } else if (PropertyName == wxT("PREF")){
4210 int PriorityNumber = 0;
4211 bool ValidNumber = TRUE;
4214 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4217 catch(std::invalid_argument &e){
4218 ValidNumber = FALSE;
4221 if (ValidNumber == TRUE){
4223 CategoriesListPref.erase(*CategoryCount);
4224 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4228 } else if (PropertyName == wxT("LANGUAGE")){
4230 CategoriesListLanguage.erase(*CategoryCount);
4231 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4235 // Something else we don't know about so append
4236 // to the tokens variable.
4238 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4240 if (FirstToken == TRUE){
4242 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4247 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4257 // Deal with multiple categories.
4259 int intOrigCatCount = *CategoryCount;
4260 bool FirstCategoryProcessed = TRUE;
4261 bool AfterFirstToken = FALSE;
4262 int intSplitSize = 0;
4263 int intSplitsFound = 0;
4264 int intSplitSeek = 0;
4265 int intPropertyLen = PropertySeg2.Len();
4267 SplitPoints.clear();
4268 SplitLength.clear();
4271 for (int i = 0; i <= intPropertyLen; i++){
4273 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4281 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4283 if (AfterFirstToken == TRUE){
4285 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4286 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4290 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4291 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4292 AfterFirstToken = TRUE;
4304 if (SplitPoints.size() > 0){
4306 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4307 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4311 if (SplitPoints.size() == 0){
4313 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4315 if (!PropertyTokens.IsEmpty()){
4317 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4323 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4324 intiter != SplitPoints.end(); ++intiter){
4326 SLiter = SplitLength.find(intiter->first);
4328 intPrevValue = intiter->second;
4330 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4332 // Add the data to the General/Home/Work address variables.
4334 // Trim any whitespace from the start and end.
4336 PropertyData = PropertyData.Trim(FALSE);
4337 PropertyData = PropertyData.Trim(TRUE);
4339 CaptureString(&PropertyData, FALSE);
4341 if (FirstCategoryProcessed == TRUE){
4343 FirstCategoryProcessed = FALSE;
4345 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4347 if (!PropertyTokens.IsEmpty()){
4349 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4359 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4361 if (!PropertyTokens.IsEmpty()){
4363 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4369 // Copy the properties to each of the categories (if it exists).
4371 if (!PropertyTokens.IsEmpty()){
4373 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4377 // Check if ALTID was used.
4379 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4381 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4385 // Check if PID was used.
4387 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4389 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4393 // Check if PREF was used.
4395 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4397 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4401 // Check if LANGUAGE was used.
4403 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4405 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4409 // Check if TYPE was used.
4415 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4418 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4426 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4428 size_t intPropertyLen = PropertySeg1.Len();
4429 std::map<int, int> SplitPoints;
4430 std::map<int, int> SplitLength;
4431 std::map<int, int>::iterator SLiter;
4432 wxString PropertyData;
4433 wxString PropertyName;
4434 wxString PropertyValue;
4435 wxString PropertyTokens;
4436 bool FirstToken = TRUE;
4437 int intSplitsFound = 0;
4438 int intSplitSize = 0;
4439 int intPrevValue = 7;
4443 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4447 PropertyType PropType = PROPERTY_NONE;
4449 // Look for type before continuing.
4451 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4455 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4456 intiter != SplitPoints.end(); ++intiter){
4458 SLiter = SplitLength.find(intiter->first);
4460 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4462 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4463 PropertyName = PropertyElement.GetNextToken();
4464 PropertyValue = PropertyElement.GetNextToken();
4466 intPrevValue = intiter->second;
4468 // Process properties.
4470 size_t intPropertyValueLen = PropertyValue.Len();
4472 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4474 PropertyValue.Trim();
4475 PropertyValue.RemoveLast();
4479 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4481 PropertyValue.Remove(0, 1);
4485 CaptureString(&PropertyValue, FALSE);
4487 if (PropertyName == wxT("ALTID")){
4489 PicturesListAltID.erase(*PhotoCount);
4490 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4492 } else if (PropertyName == wxT("PID")){
4494 PicturesListPID.erase(*PhotoCount);
4495 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4497 } else if (PropertyName == wxT("PREF")){
4499 int PriorityNumber = 0;
4500 bool ValidNumber = TRUE;
4503 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4506 catch(std::invalid_argument &e){
4507 ValidNumber = FALSE;
4510 if (ValidNumber == TRUE){
4512 PicturesListPref.erase(*PhotoCount);
4513 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4517 } else if (PropertyName == wxT("MEDIATYPE")){
4519 PicturesListMediatype.erase(*PhotoCount);
4520 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4524 // Something else we don't know about so append
4525 // to the tokens variable.
4527 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4529 if (FirstToken == TRUE){
4531 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4536 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4546 intPropertyLen = PropertySeg2.Len();
4547 SplitPoints.clear();
4548 SplitLength.clear();
4553 CaptureString(&PropertySeg2, FALSE);
4555 for (int i = 0; i <= intPropertyLen; i++){
4559 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4562 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4564 if (intSplitsFound == 6){
4566 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4571 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4581 wxString wxSPhotoURI;
4582 wxString wxSPhotoMIME;
4583 wxString wxSPhotoEncoding;
4584 wxString wxSPhotoData;
4585 std::string base64enc;
4587 if (intSplitsFound == 0){
4591 std::map<int, int>::iterator striter;
4593 striter = SplitLength.find(1);
4595 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4597 while (wSTDataType.HasMoreTokens() == TRUE){
4599 wxSPhotoURI = wSTDataType.GetNextToken();
4600 wxSPhotoMIME = wSTDataType.GetNextToken();
4605 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4607 while (wSTDataInfo.HasMoreTokens() == TRUE){
4609 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4610 wxSPhotoData = wSTDataInfo.GetNextToken();
4611 base64enc = wxSPhotoData.mb_str();
4618 // Add the data to the General/Home/Work address variables.
4620 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4621 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4622 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4628 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4631 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4635 if (!PropertyTokens.IsEmpty()){
4637 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4643 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4645 size_t intPropertyLen = PropertySeg1.Len();
4646 std::map<int, int> SplitPoints;
4647 std::map<int, int> SplitLength;
4648 std::map<int, int>::iterator SLiter;
4649 wxString PropertyData;
4650 wxString PropertyName;
4651 wxString PropertyValue;
4652 wxString PropertyTokens;
4653 bool FirstToken = TRUE;
4654 int intSplitsFound = 0;
4655 int intSplitSize = 0;
4656 int intPrevValue = 6;
4660 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4664 PropertyType PropType = PROPERTY_NONE;
4666 // Look for type before continuing.
4668 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4672 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4673 intiter != SplitPoints.end(); ++intiter){
4675 SLiter = SplitLength.find(intiter->first);
4677 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4679 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4680 PropertyName = PropertyElement.GetNextToken();
4681 PropertyValue = PropertyElement.GetNextToken();
4683 intPrevValue = intiter->second;
4685 // Process properties.
4687 size_t intPropertyValueLen = PropertyValue.Len();
4689 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4691 PropertyValue.Trim();
4692 PropertyValue.RemoveLast();
4696 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4698 PropertyValue.Remove(0, 1);
4702 CaptureString(&PropertyValue, FALSE);
4704 if (PropertyName == wxT("ALTID")){
4706 LogosListAltID.erase(*LogoCount);
4707 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4709 } else if (PropertyName == wxT("PID")){
4711 LogosListPID.erase(*LogoCount);
4712 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4714 } else if (PropertyName == wxT("PREF")){
4716 int PriorityNumber = 0;
4717 bool ValidNumber = TRUE;
4720 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4723 catch(std::invalid_argument &e){
4724 ValidNumber = FALSE;
4727 if (ValidNumber == TRUE){
4729 LogosListPref.erase(*LogoCount);
4730 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4734 } else if (PropertyName == wxT("MEDIATYPE")){
4736 LogosListMediatype.erase(*LogoCount);
4737 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4741 // Something else we don't know about so append
4742 // to the tokens variable.
4744 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4746 if (FirstToken == TRUE){
4748 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4753 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4763 intPropertyLen = PropertySeg2.Len();
4764 SplitPoints.clear();
4765 SplitLength.clear();
4770 CaptureString(&PropertySeg2, FALSE);
4772 for (int i = 0; i <= intPropertyLen; i++){
4776 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4779 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4781 if (intSplitsFound == 6){
4783 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4788 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4798 wxString wxSPhotoURI;
4799 wxString wxSPhotoMIME;
4800 wxString wxSPhotoEncoding;
4801 wxString wxSPhotoData;
4802 std::string base64enc;
4804 if (intSplitsFound == 0){
4808 std::map<int, int>::iterator striter;
4810 striter = SplitLength.find(1);
4812 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4814 while (wSTDataType.HasMoreTokens() == TRUE){
4816 wxSPhotoURI = wSTDataType.GetNextToken();
4817 wxSPhotoMIME = wSTDataType.GetNextToken();
4822 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4824 while (wSTDataInfo.HasMoreTokens() == TRUE){
4826 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4827 wxSPhotoData = wSTDataInfo.GetNextToken();
4828 base64enc = wxSPhotoData.mb_str();
4835 // Add the data to the General/Home/Work address variables.
4837 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4838 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4839 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4845 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4848 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4852 if (!PropertyTokens.IsEmpty()){
4854 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4860 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4862 size_t intPropertyLen = PropertySeg1.Len();
4863 std::map<int, int> SplitPoints;
4864 std::map<int, int> SplitLength;
4865 std::map<int, int>::iterator SLiter;
4866 wxString PropertyData;
4867 wxString PropertyName;
4868 wxString PropertyValue;
4869 wxString PropertyTokens;
4870 bool FirstToken = TRUE;
4871 int intSplitsFound = 0;
4872 int intSplitSize = 0;
4873 int intPrevValue = 7;
4877 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4881 PropertyType PropType = PROPERTY_NONE;
4883 // Look for type before continuing.
4885 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4889 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4890 intiter != SplitPoints.end(); ++intiter){
4892 SLiter = SplitLength.find(intiter->first);
4894 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4896 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4897 PropertyName = PropertyElement.GetNextToken();
4898 PropertyValue = PropertyElement.GetNextToken();
4900 intPrevValue = intiter->second;
4902 // Process properties.
4904 size_t intPropertyValueLen = PropertyValue.Len();
4906 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4908 PropertyValue.Trim();
4909 PropertyValue.RemoveLast();
4913 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4915 PropertyValue.Remove(0, 1);
4919 CaptureString(&PropertyValue, FALSE);
4921 if (PropertyName == wxT("ALTID")){
4923 SoundsListAltID.erase(*SoundCount);
4924 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4926 } else if (PropertyName == wxT("PID")){
4928 SoundsListPID.erase(*SoundCount);
4929 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4931 } else if (PropertyName == wxT("PREF")){
4933 int PriorityNumber = 0;
4934 bool ValidNumber = TRUE;
4937 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4940 catch(std::invalid_argument &e){
4941 ValidNumber = FALSE;
4944 if (ValidNumber == TRUE){
4946 SoundsListPref.erase(*SoundCount);
4947 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4951 } else if (PropertyName == wxT("MEDIATYPE")){
4953 SoundsListMediatype.erase(*SoundCount);
4954 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4956 } else if (PropertyName == wxT("LANGUAGE")){
4958 SoundsListLanguage.erase(*SoundCount);
4959 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4963 // Something else we don't know about so append
4964 // to the tokens variable.
4966 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4968 if (FirstToken == TRUE){
4970 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4975 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4985 intPropertyLen = PropertySeg2.Len();
4986 SplitPoints.clear();
4987 SplitLength.clear();
4992 CaptureString(&PropertySeg2, FALSE);
4994 for (int i = 0; i <= intPropertyLen; i++){
4998 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5001 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5003 if (intSplitsFound == 6){
5005 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5010 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5020 wxString wxSSoundURI;
5021 wxString wxSSoundMIME;
5022 wxString wxSSoundEncoding;
5023 wxString wxSSoundData;
5024 std::string base64enc;
5026 if (intSplitsFound == 0){
5030 std::map<int, int>::iterator striter;
5032 striter = SplitLength.find(1);
5034 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5036 while (wSTDataType.HasMoreTokens() == TRUE){
5038 wxSSoundURI = wSTDataType.GetNextToken();
5039 wxSSoundMIME = wSTDataType.GetNextToken();
5044 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5046 while (wSTDataInfo.HasMoreTokens() == TRUE){
5048 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5049 wxSSoundData = wSTDataInfo.GetNextToken();
5050 base64enc = wxSSoundData.mb_str();
5057 // Add the data to the General/Home/Work address variables.
5063 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5066 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5070 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5071 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5072 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5074 if (!PropertyTokens.IsEmpty()){
5076 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5082 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5084 size_t intPropertyLen = PropertySeg1.Len();
5085 std::map<int, int> SplitPoints;
5086 std::map<int, int> SplitLength;
5087 std::map<int, int>::iterator SLiter;
5088 wxString PropertyData;
5089 wxString PropertyName;
5090 wxString PropertyValue;
5091 wxString PropertyTokens;
5092 bool FirstToken = TRUE;
5093 int intSplitsFound = 0;
5094 int intSplitSize = 0;
5095 int intPrevValue = 8;
5099 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5103 PropertyType PropType = PROPERTY_NONE;
5105 // Look for type before continuing.
5107 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5111 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5112 intiter != SplitPoints.end(); ++intiter){
5114 SLiter = SplitLength.find(intiter->first);
5116 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5118 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5119 PropertyName = PropertyElement.GetNextToken();
5120 PropertyValue = PropertyElement.GetNextToken();
5122 intPrevValue = intiter->second;
5124 // Process properties.
5126 size_t intPropertyValueLen = PropertyValue.Len();
5128 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5130 PropertyValue.Trim();
5131 PropertyValue.RemoveLast();
5135 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5137 PropertyValue.Remove(0, 1);
5141 CaptureString(&PropertyValue, FALSE);
5143 if (PropertyName == wxT("ALTID")){
5145 CalendarListAltID.erase(*CalURICount);
5146 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5148 } else if (PropertyName == wxT("PID")){
5150 CalendarListPID.erase(*CalURICount);
5151 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5153 } else if (PropertyName == wxT("PREF")){
5155 int PriorityNumber = 0;
5156 bool ValidNumber = TRUE;
5159 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5162 catch(std::invalid_argument &e){
5163 ValidNumber = FALSE;
5166 if (ValidNumber == TRUE){
5168 CalendarListPref.erase(*CalURICount);
5169 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5173 } else if (PropertyName == wxT("MEDIATYPE")){
5175 CalendarListMediatype.erase(*CalURICount);
5176 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5180 // Something else we don't know about so append
5181 // to the tokens variable.
5183 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5185 if (FirstToken == TRUE){
5187 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5192 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5202 intPropertyLen = PropertySeg2.Len();
5203 SplitPoints.clear();
5204 SplitLength.clear();
5209 CaptureString(&PropertySeg2, FALSE);
5211 // Add the data to the General/Home/Work address variables.
5217 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5220 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5224 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5226 if (!PropertyTokens.IsEmpty()){
5228 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5234 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5236 size_t intPropertyLen = PropertySeg1.Len();
5237 std::map<int, int> SplitPoints;
5238 std::map<int, int> SplitLength;
5239 std::map<int, int>::iterator SLiter;
5240 wxString PropertyData;
5241 wxString PropertyName;
5242 wxString PropertyValue;
5243 wxString PropertyTokens;
5244 bool FirstToken = TRUE;
5245 int intSplitsFound = 0;
5246 int intSplitSize = 0;
5247 int intPrevValue = 8;
5251 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5255 PropertyType PropType = PROPERTY_NONE;
5257 // Look for type before continuing.
5259 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5263 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5264 intiter != SplitPoints.end(); ++intiter){
5266 SLiter = SplitLength.find(intiter->first);
5268 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5270 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5271 PropertyName = PropertyElement.GetNextToken();
5272 PropertyValue = PropertyElement.GetNextToken();
5274 intPrevValue = intiter->second;
5276 // Process properties.
5278 size_t intPropertyValueLen = PropertyValue.Len();
5280 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5282 PropertyValue.Trim();
5283 PropertyValue.RemoveLast();
5287 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5289 PropertyValue.Remove(0, 1);
5293 CaptureString(&PropertyValue, FALSE);
5295 if (PropertyName == wxT("ALTID")){
5297 CalendarRequestListAltID.erase(*CalAdrURICount);
5298 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5300 } else if (PropertyName == wxT("PID")){
5302 CalendarRequestListPID.erase(*CalAdrURICount);
5303 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5305 } else if (PropertyName == wxT("PREF")){
5307 int PriorityNumber = 0;
5308 bool ValidNumber = TRUE;
5311 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5314 catch(std::invalid_argument &e){
5315 ValidNumber = FALSE;
5318 if (ValidNumber == TRUE){
5320 CalendarRequestListPref.erase(*CalAdrURICount);
5321 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5325 } else if (PropertyName == wxT("MEDIATYPE")){
5327 CalendarRequestListMediatype.erase(*CalAdrURICount);
5328 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5332 // Something else we don't know about so append
5333 // to the tokens variable.
5335 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5337 if (FirstToken == TRUE){
5339 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5344 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5354 intPropertyLen = PropertySeg2.Len();
5355 SplitPoints.clear();
5356 SplitLength.clear();
5361 CaptureString(&PropertySeg2, FALSE);
5363 // Add the data to the General/Home/Work address variables.
5369 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5372 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5376 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5378 if (!PropertyTokens.IsEmpty()){
5380 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5386 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5388 size_t intPropertyLen = PropertySeg1.Len();
5389 std::map<int, int> SplitPoints;
5390 std::map<int, int> SplitLength;
5391 std::map<int, int>::iterator SLiter;
5392 wxString PropertyData;
5393 wxString PropertyName;
5394 wxString PropertyValue;
5395 wxString PropertyTokens;
5396 bool FirstToken = TRUE;
5397 int intSplitsFound = 0;
5398 int intSplitSize = 0;
5399 int intPrevValue = 7;
5403 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5407 PropertyType PropType = PROPERTY_NONE;
5409 // Look for type before continuing.
5411 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5415 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5416 intiter != SplitPoints.end(); ++intiter){
5418 SLiter = SplitLength.find(intiter->first);
5420 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5422 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5423 PropertyName = PropertyElement.GetNextToken();
5424 PropertyValue = PropertyElement.GetNextToken();
5426 intPrevValue = intiter->second;
5428 // Process properties.
5430 size_t intPropertyValueLen = PropertyValue.Len();
5432 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5434 PropertyValue.Trim();
5435 PropertyValue.RemoveLast();
5439 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5441 PropertyValue.Remove(0, 1);
5445 CaptureString(&PropertyValue, FALSE);
5447 if (PropertyName == wxT("ALTID")){
5449 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5450 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5452 } else if (PropertyName == wxT("PID")){
5454 FreeBusyListPID.erase(*FreeBusyAddressCount);
5455 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5457 } else if (PropertyName == wxT("PREF")){
5459 int PriorityNumber = 0;
5460 bool ValidNumber = TRUE;
5463 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5466 catch(std::invalid_argument &e){
5467 ValidNumber = FALSE;
5470 if (ValidNumber == TRUE){
5472 FreeBusyListPref.erase(*FreeBusyAddressCount);
5473 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5477 } else if (PropertyName == wxT("MEDIATYPE")){
5479 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5480 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5484 // Something else we don't know about so append
5485 // to the tokens variable.
5487 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5489 if (FirstToken == TRUE){
5491 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5496 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5506 intPropertyLen = PropertySeg2.Len();
5507 SplitPoints.clear();
5508 SplitLength.clear();
5513 CaptureString(&PropertySeg2, FALSE);
5515 // Add the data to the General/Home/Work address variables.
5521 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5524 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5528 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5530 if (!PropertyTokens.IsEmpty()){
5532 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5538 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5540 size_t intPropertyLen = PropertySeg1.Len();
5541 std::map<int, int> SplitPoints;
5542 std::map<int, int> SplitLength;
5543 std::map<int, int>::iterator SLiter;
5544 wxString PropertyData;
5545 wxString PropertyName;
5546 wxString PropertyValue;
5547 wxString PropertyTokens;
5548 bool FirstToken = TRUE;
5549 int intSplitsFound = 0;
5550 int intSplitSize = 0;
5551 int intPrevValue = 5;
5556 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5560 PropertyType PropType = PROPERTY_NONE;
5562 // Look for type before continuing.
5564 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5568 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5569 intiter != SplitPoints.end(); ++intiter){
5571 SLiter = SplitLength.find(intiter->first);
5573 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5575 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5576 PropertyName = PropertyElement.GetNextToken();
5577 PropertyValue = PropertyElement.GetNextToken();
5579 intPrevValue = intiter->second;
5581 // Process properties.
5583 size_t intPropertyValueLen = PropertyValue.Len();
5585 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5587 PropertyValue.Trim();
5588 PropertyValue.RemoveLast();
5592 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5594 PropertyValue.Remove(0, 1);
5598 if (PropertyName == wxT("ALTID")){
5600 KeyListAltID.erase(*KeyCount);
5601 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5603 } else if (PropertyName == wxT("PID")){
5605 KeyListPID.erase(*KeyCount);
5606 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5608 } else if (PropertyName == wxT("PREF")){
5610 int PriorityNumber = 0;
5611 bool ValidNumber = TRUE;
5614 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5617 catch(std::invalid_argument &e){
5618 ValidNumber = FALSE;
5621 if (ValidNumber == TRUE){
5623 KeyListPref.erase(*KeyCount);
5624 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5630 // Something else we don't know about so append
5631 // to the tokens variable.
5633 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5635 if (FirstToken == TRUE){
5637 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5642 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5652 intPropertyLen = PropertySeg2.Len();
5653 SplitPoints.clear();
5654 SplitLength.clear();
5659 for (int i = 0; i <= intPropertyLen; i++){
5663 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5666 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5668 if (intSplitsFound == 6){
5670 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5675 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5686 wxString wxSKeyMIME;
5687 wxString wxSKeyEncoding;
5688 wxString wxSKeyData;
5689 std::string base64enc;
5691 if (intSplitsFound == 0){
5695 std::map<int, int>::iterator striter;
5697 striter = SplitLength.find(1);
5699 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5701 while (wSTDataType.HasMoreTokens() == TRUE){
5703 wxSKeyURI = wSTDataType.GetNextToken();
5704 wxSKeyMIME = wSTDataType.GetNextToken();
5709 if (wxSKeyURI == wxT("data")){
5711 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5713 while (wSTDataInfo.HasMoreTokens() == TRUE){
5715 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5716 wxSKeyData = wSTDataInfo.GetNextToken();
5725 // Add the data to the General/Home/Work address variables.
5727 if (wxSKeyURI == wxT("data")){
5729 KeyListDataEncType.erase(*KeyCount);
5730 KeyListKeyType.erase(*KeyCount);
5731 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5732 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5734 KeyList.erase(*KeyCount);
5735 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5739 KeyList.erase(*KeyCount);
5740 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5744 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5750 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5753 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5757 if (!PropertyTokens.IsEmpty()){
5759 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5765 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5767 // Split the Vendor three ways.
5769 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5772 wxString wxSVNDPropName;
5775 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5777 wSTVendorDetails.GetNextToken();
5778 wxSVNDID = wSTVendorDetails.GetNextToken();
5779 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5784 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5786 // Add the data to the vendor variables.
5788 VendorList.erase(*VendorCount);
5789 VendorListPEN.erase(*VendorCount);
5790 VendorListElement.erase(*VendorCount);
5792 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5793 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5794 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5800 void ProcessIntegerValue(ContactDataObject *ContactData,
5801 std::map<int,int> *PrefPtr,
5802 wxString *PropertyValue,
5805 int PriorityNumber = 0;
5806 bool ValidNumber = TRUE;
5809 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5812 catch(std::invalid_argument &e){
5813 ValidNumber = FALSE;
5816 if (ValidNumber == TRUE){
5818 PrefPtr->erase(*ItemCount);
5819 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5825 void SplitValues(wxString *PropertyLine,
5826 std::map<int,int> *SplitPoints,
5827 std::map<int,int> *SplitLength,
5830 size_t intPropertyLen = PropertyLine->Len();
5831 int intSplitsFound = 0;
5832 int intSplitSize = 0;
5833 int intSplitSeek = 0;
5835 for (int i = intSize; i <= intPropertyLen; i++){
5839 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5840 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5842 if (intSplitsFound == 0){
5844 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5848 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5852 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5862 if (intSplitsFound == 0){
5864 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5865 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5869 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5870 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5876 void CheckType(wxString *PropertySeg1,
5877 std::map<int,int> *SplitPoints,
5878 std::map<int,int> *SplitLength,
5880 PropertyType *PropType){
5882 wxString PropertyData;
5883 wxString PropertyName;
5884 wxString PropertyValue;
5885 std::map<int,int>::iterator SLiter;
5887 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5888 intiter != SplitPoints->end(); ++intiter){
5890 SLiter = SplitLength->find(intiter->first);
5892 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5894 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5895 PropertyName = PropertyElement.GetNextToken();
5896 PropertyValue = PropertyElement.GetNextToken();
5898 *intPrevValue = intiter->second;
5900 if (PropertyName == wxT("TYPE")){
5902 if (PropertyValue == wxT("work")){
5904 *PropType = PROPERTY_WORK;
5906 } else if (PropertyValue == wxT("home")){
5908 *PropType = PROPERTY_HOME;
5912 *PropType = PROPERTY_NONE;