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 int PriorityNumber = 0;
1705 bool ValidNumber = TRUE;
1708 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1711 catch(std::invalid_argument &e){
1712 ValidNumber = FALSE;
1715 if (ValidNumber == TRUE){
1717 TZListPref->erase(*TimeZoneCount);
1718 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1722 } else if (PropertyName == wxT("MEDIATYPE")){
1724 TZListMediatype->erase(*TimeZoneCount);
1725 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1729 // Something else we don't know about so append
1730 // to the tokens variable.
1732 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1734 if (FirstToken == TRUE){
1736 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1741 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1751 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1753 // Add the name token data.
1755 if (!PropertyTokens.IsEmpty()){
1757 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1764 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1766 size_t intPropertyLen = PropertySeg1.Len();
1767 std::map<int, int> SplitPoints;
1768 std::map<int, int> SplitLength;
1769 std::map<int, int>::iterator SLiter;
1770 wxString PropertyData;
1771 wxString PropertyName;
1772 wxString PropertyValue;
1773 wxString PropertyTokens;
1774 wxString AddressLabel;
1775 wxString AddressLang;
1776 wxString AddressAltID;
1777 wxString AddressPID;
1778 wxString AddressTokens;
1779 wxString AddressGeo;
1780 wxString AddressTimezone;
1781 wxString AddressType;
1782 wxString AddressMediatype;
1783 wxString AddressPOBox;
1784 wxString AddressExtended;
1785 wxString AddressStreet;
1786 wxString AddressLocality;
1787 wxString AddressCity;
1788 wxString AddressRegion;
1789 wxString AddressPostalCode;
1790 wxString AddressCountry;
1791 bool FirstToken = TRUE;
1792 int intSplitsFound = 0;
1793 int intSplitSize = 0;
1794 int intPrevValue = 5;
1799 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1803 PropertyType PropType = PROPERTY_NONE;
1805 // Look for type before continuing.
1807 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1811 std::map<int, wxString> *AddressList = NULL;
1812 std::map<int, wxString> *AddressListTown = NULL;
1813 std::map<int, wxString> *AddressListCounty = NULL;
1814 std::map<int, wxString> *AddressListPostCode = NULL;
1815 std::map<int, wxString> *AddressListCountry = NULL;
1816 std::map<int, wxString> *AddressListLabel = NULL;
1817 std::map<int, wxString> *AddressListLang = NULL;
1818 std::map<int, wxString> *AddressListAltID = NULL;
1819 std::map<int, wxString> *AddressListPID = NULL;
1820 std::map<int, wxString> *AddressListTokens = NULL;
1821 std::map<int, wxString> *AddressListGeo = NULL;
1822 std::map<int, wxString> *AddressListTimezone = NULL;
1823 std::map<int, wxString> *AddressListType = NULL;
1824 std::map<int, wxString> *AddressListMediatype = NULL;
1825 std::map<int, int> *AddressListPref = NULL;
1829 AddressList = &GeneralAddressList;
1830 AddressListTown = &GeneralAddressListTown;
1831 AddressListCounty = &GeneralAddressListCounty;
1832 AddressListPostCode = &GeneralAddressListPostCode;
1833 AddressListCountry = &GeneralAddressListCountry;
1834 AddressListLabel = &GeneralAddressListLabel;
1835 AddressListLang = &GeneralAddressListLang;
1836 AddressListAltID = &GeneralAddressListAltID;
1837 AddressListPID = &GeneralAddressListPID;
1838 AddressListTokens = &GeneralAddressListTokens;
1839 AddressListGeo = &GeneralAddressListGeo;
1840 AddressListTimezone = &GeneralAddressListTimezone;
1841 AddressListType = &GeneralAddressListType;
1842 AddressListMediatype = &GeneralAddressListMediatype;
1843 AddressListPref = &GeneralAddressListPref;
1846 AddressList = &HomeAddressList;
1847 AddressListTown = &HomeAddressListTown;
1848 AddressListCounty = &HomeAddressListCounty;
1849 AddressListPostCode = &HomeAddressListPostCode;
1850 AddressListCountry = &HomeAddressListCountry;
1851 AddressListLabel = &HomeAddressListLabel;
1852 AddressListLang = &HomeAddressListLang;
1853 AddressListAltID = &HomeAddressListAltID;
1854 AddressListPID = &HomeAddressListPID;
1855 AddressListTokens = &HomeAddressListTokens;
1856 AddressListGeo = &HomeAddressListGeo;
1857 AddressListTimezone = &HomeAddressListTimezone;
1858 AddressListType = &HomeAddressListType;
1859 AddressListMediatype = &HomeAddressListMediatype;
1860 AddressListPref = &HomeAddressListPref;
1863 AddressList = &BusinessAddressList;
1864 AddressListTown = &BusinessAddressListTown;
1865 AddressListCounty = &BusinessAddressListCounty;
1866 AddressListPostCode = &BusinessAddressListPostCode;
1867 AddressListCountry = &BusinessAddressListCountry;
1868 AddressListLabel = &BusinessAddressListLabel;
1869 AddressListLang = &BusinessAddressListLang;
1870 AddressListAltID = &BusinessAddressListAltID;
1871 AddressListPID = &BusinessAddressListPID;
1872 AddressListTokens = &BusinessAddressListTokens;
1873 AddressListGeo = &BusinessAddressListGeo;
1874 AddressListTimezone = &BusinessAddressListTimezone;
1875 AddressListType = &BusinessAddressListType;
1876 AddressListMediatype = &BusinessAddressListMediatype;
1877 AddressListPref = &BusinessAddressListPref;
1883 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1884 intiter != SplitPoints.end(); ++intiter){
1886 SLiter = SplitLength.find(intiter->first);
1888 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1890 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1891 PropertyName = PropertyElement.GetNextToken();
1892 PropertyValue = PropertyElement.GetNextToken();
1894 intPrevValue = intiter->second;
1896 CaptureString(&PropertyValue, FALSE);
1898 // Process properties.
1900 if (PropertyName == wxT("LABEL")){
1902 AddressListLabel->erase(*AddressCount);
1903 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1905 } else if (PropertyName == wxT("LANGUAGE")){
1907 AddressListLang->erase(*AddressCount);
1908 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1910 } else if (PropertyName == wxT("ALTID")){
1912 AddressListAltID->erase(*AddressCount);
1913 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1915 } else if (PropertyName == wxT("PID")){
1917 AddressListPID->erase(*AddressCount);
1918 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1920 } else if (PropertyName == wxT("GEO")){
1922 AddressListGeo->erase(*AddressCount);
1923 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1925 } else if (PropertyName == wxT("TZ")){
1927 AddressListTimezone->erase(*AddressCount);
1928 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1930 } else if (PropertyName == wxT("MEDIATYPE")){
1932 AddressListMediatype->erase(*AddressCount);
1933 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1935 } else if (PropertyName == wxT("PREF")){
1937 int PriorityNumber = 0;
1938 bool ValidNumber = TRUE;
1941 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1944 catch(std::invalid_argument &e){
1945 ValidNumber = FALSE;
1948 if (ValidNumber == TRUE){
1950 AddressListPref->erase(*AddressCount);
1951 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1957 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1959 if (FirstToken == TRUE){
1961 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1966 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1976 // Split the address.
1978 //std::map<int, int>::iterator SLiter;
1979 intPropertyLen = PropertySeg2.Len();
1980 SplitPoints.clear();
1981 SplitLength.clear();
1986 for (int i = 0; i <= intPropertyLen; i++){
1990 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1993 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1995 if (intSplitsFound == 6){
1997 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2002 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2012 // Split the data into several parts.
2014 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2015 intiter != SplitPoints.end(); ++intiter){
2017 if (intiter->first == 1){
2019 // Deal with PO Box.
2021 SLiter = SplitLength.find(1);
2023 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2024 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2025 intPrevValue = intiter->second;
2027 } else if (intiter->first == 2){
2029 // Deal with extended address.
2031 SLiter = SplitLength.find(2);
2033 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2034 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2035 intPrevValue = intiter->second;
2037 } else if (intiter->first == 3){
2039 // Deal with street address.
2041 SLiter = SplitLength.find(3);
2043 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2044 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2045 intPrevValue = intiter->second;
2047 } else if (intiter->first == 4){
2049 // Deal with locality
2051 SLiter = SplitLength.find(4);
2053 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2054 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2055 intPrevValue = intiter->second;
2057 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2059 } else if (intiter->first == 5){
2061 // Deal with region.
2063 SLiter = SplitLength.find(5);
2065 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2066 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2067 intPrevValue = intiter->second;
2069 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2071 } else if (intiter->first == 6){
2073 // Deal with post code.
2075 SLiter = SplitLength.find(6);
2077 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2078 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2079 intPrevValue = intiter->second;
2081 // Deal with country.
2083 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2084 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2092 // Add the data to the General/Home/Work address variables.
2094 CaptureString(&AddressStreet, FALSE);
2095 CaptureString(&AddressLocality, FALSE);
2096 CaptureString(&AddressRegion, FALSE);
2097 CaptureString(&AddressPostalCode, FALSE);
2098 CaptureString(&AddressCountry, FALSE);
2100 if (!PropertyTokens.IsEmpty()){
2102 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2106 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2107 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2108 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2109 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2110 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2114 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2117 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2120 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2124 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2128 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2130 std::map<int, int> SplitPoints;
2131 std::map<int, int> SplitLength;
2133 int intPrevValue = 7;
2136 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2140 PropertyType PropType = PROPERTY_NONE;
2142 // Look for type before continuing.
2144 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2146 std::map<int, wxString> *EmailList = NULL;
2147 std::map<int, wxString> *EmailListType = NULL;
2148 std::map<int, wxString> *EmailListAltID = NULL;
2149 std::map<int, wxString> *EmailListPID = NULL;
2150 std::map<int, wxString> *EmailListTokens = NULL;
2151 std::map<int, int> *EmailListPref = NULL;
2155 EmailList = &GeneralEmailList;
2156 EmailListType = &GeneralEmailListType;
2157 EmailListAltID = &GeneralEmailListAltID;
2158 EmailListPID = &GeneralEmailListPID;
2159 EmailListTokens = &GeneralEmailListTokens;
2160 EmailListPref = &GeneralEmailListPref;
2163 EmailList = &HomeEmailList;
2164 EmailListType = &HomeEmailListType;
2165 EmailListAltID = &HomeEmailListAltID;
2166 EmailListPID = &HomeEmailListPID;
2167 EmailListTokens = &HomeEmailListTokens;
2168 EmailListPref = &HomeEmailListPref;
2171 EmailList = &BusinessEmailList;
2172 EmailListType = &BusinessEmailListType;
2173 EmailListAltID = &BusinessEmailListAltID;
2174 EmailListPID = &BusinessEmailListPID;
2175 EmailListTokens = &BusinessEmailListTokens;
2176 EmailListPref = &BusinessEmailListPref;
2182 std::map<int,int>::iterator SLiter;
2183 wxString PropertyData;
2184 wxString PropertyName;
2185 wxString PropertyValue;
2186 wxString PropertyTokens;
2187 bool FirstToken = TRUE;
2189 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2190 intiter != SplitPoints.end(); ++intiter){
2192 SLiter = SplitLength.find(intiter->first);
2194 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2196 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2197 PropertyName = PropertyElement.GetNextToken();
2198 PropertyValue = PropertyElement.GetNextToken();
2200 intPrevValue = intiter->second;
2202 CaptureString(&PropertyValue, FALSE);
2204 // Process properties.
2206 if (PropertyName == wxT("ALTID")){
2208 EmailListAltID->erase(*EmailCount);
2209 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2211 } else if (PropertyName == wxT("PID")){
2213 EmailListPID->erase(*EmailCount);
2214 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2216 } else if (PropertyName == wxT("PREF")){
2218 int PriorityNumber = 0;
2219 bool ValidNumber = TRUE;
2222 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2225 catch(std::invalid_argument &e){
2226 ValidNumber = FALSE;
2229 if (ValidNumber == TRUE){
2231 EmailListPref->erase(*EmailCount);
2232 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2238 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2240 if (FirstToken == TRUE){
2242 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2247 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2257 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2259 // Add the name token data.
2261 if (!PropertyTokens.IsEmpty()){
2263 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2270 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2272 std::map<int, int> SplitPoints;
2273 std::map<int, int> SplitLength;
2275 int intPrevValue = 6;
2278 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2282 PropertyType PropType = PROPERTY_NONE;
2284 // Look for type before continuing.
2286 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2288 std::map<int, wxString> *IMList = NULL;
2289 std::map<int, wxString> *IMListType = NULL;
2290 std::map<int, wxString> *IMListAltID = NULL;
2291 std::map<int, wxString> *IMListPID = NULL;
2292 std::map<int, wxString> *IMListTokens = NULL;
2293 std::map<int, wxString> *IMListMediatype = NULL;
2294 std::map<int, int> *IMListPref = NULL;
2298 IMList = &GeneralIMList;
2299 IMListType = &GeneralIMListType;
2300 IMListAltID = &GeneralIMListAltID;
2301 IMListPID = &GeneralIMListPID;
2302 IMListTokens = &GeneralIMListTokens;
2303 IMListMediatype = &GeneralIMListMediatype;
2304 IMListPref = &GeneralIMListPref;
2307 IMList = &HomeIMList;
2308 IMListType = &HomeIMListType;
2309 IMListAltID = &HomeIMListAltID;
2310 IMListPID = &HomeIMListPID;
2311 IMListTokens = &HomeIMListTokens;
2312 IMListMediatype = &HomeIMListMediatype;
2313 IMListPref = &HomeIMListPref;
2316 IMList = &BusinessIMList;
2317 IMListType = &BusinessIMListType;
2318 IMListAltID = &BusinessIMListAltID;
2319 IMListPID = &BusinessIMListPID;
2320 IMListTokens = &BusinessIMListTokens;
2321 IMListMediatype = &BusinessIMListMediatype;
2322 IMListPref = &BusinessIMListPref;
2328 std::map<int,int>::iterator SLiter;
2329 wxString PropertyData;
2330 wxString PropertyName;
2331 wxString PropertyValue;
2332 wxString PropertyTokens;
2333 bool FirstToken = TRUE;
2335 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2336 intiter != SplitPoints.end(); ++intiter){
2338 SLiter = SplitLength.find(intiter->first);
2340 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2342 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2343 PropertyName = PropertyElement.GetNextToken();
2344 PropertyValue = PropertyElement.GetNextToken();
2346 intPrevValue = intiter->second;
2348 CaptureString(&PropertyValue, FALSE);
2350 // Process properties.
2352 if (PropertyName == wxT("ALTID")){
2354 IMListAltID->erase(*IMCount);
2355 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2357 } else if (PropertyName == wxT("PID")){
2359 IMListPID->erase(*IMCount);
2360 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2362 } else if (PropertyName == wxT("MEDIATYPE")){
2364 IMListMediatype->erase(*IMCount);
2365 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2367 } else if (PropertyName == wxT("PREF")){
2369 int PriorityNumber = 0;
2370 bool ValidNumber = TRUE;
2373 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2376 catch(std::invalid_argument &e){
2377 ValidNumber = FALSE;
2380 if (ValidNumber == TRUE){
2382 IMListPref->erase(*IMCount);
2383 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2389 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2391 if (FirstToken == TRUE){
2393 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2398 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2408 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2410 // Add the name token data.
2412 if (!PropertyTokens.IsEmpty()){
2414 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2420 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2422 std::map<int, int> SplitPoints;
2423 std::map<int, int> SplitLength;
2424 std::map<int, int>::iterator SLiter;
2428 PropertyType PropType = PROPERTY_NONE;
2430 // Look for type before continuing.
2433 wxString TelTypeDetail;
2434 wxString PropertyData;
2435 wxString PropertyName;
2436 wxString PropertyValue;
2437 wxString PropertyTokens;
2439 std::map<int,int> TypeSplitPoints;
2440 std::map<int,int> TypeSplitLength;
2441 std::map<int,int>::iterator TSLiter;
2443 int intSplitSize = 0;
2444 int intSplitsFound = 0;
2445 int intSplitPoint = 0;
2447 int intPrevValue = 5;
2449 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2453 // Look for type before continuing.
2455 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2456 intiter != SplitPoints.end(); ++intiter){
2458 SLiter = SplitLength.find(intiter->first);
2460 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2462 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2463 PropertyName = PropertyElement.GetNextToken();
2464 PropertyValue = PropertyElement.GetNextToken();
2466 intPrevValue = intiter->second;
2468 if (PropertyName == wxT("TYPE")){
2470 // Process each value in type and translate each
2473 // Strip out the quotes if they are there.
2475 size_t intPropertyValueLen = PropertyValue.Len();
2477 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2479 PropertyValue.Trim();
2480 PropertyValue.RemoveLast();
2484 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2486 PropertyValue.Remove(0, 1);
2490 TelTypeDetail = PropertyValue;
2496 for (int i = 0; i <= intPropertyValueLen; i++){
2500 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2502 if (intSplitsFound == 0){
2504 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2505 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2509 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2510 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2523 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2524 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2526 int intTypeSeek = 0;
2528 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2529 typeiter != TypeSplitPoints.end(); ++typeiter){
2531 wxString TypePropertyName;
2533 TSLiter = TypeSplitLength.find(typeiter->first);
2535 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2537 if (intTypeSeek == 0){
2542 TelTypeUI.Append(wxT(","));
2546 if (TypePropertyName == wxT("home")){
2548 PropType = PROPERTY_HOME;
2550 } else if (TypePropertyName == wxT("work")){
2552 PropType = PROPERTY_WORK;
2557 if (TypePropertyName == wxT("text")){
2559 TelTypeUI.Append(_("text"));
2562 } else if (TypePropertyName == wxT("voice")){
2564 TelTypeUI.Append(_("voice"));
2567 } else if (TypePropertyName == wxT("fax")){
2569 TelTypeUI.Append(_("fax"));
2572 } else if (TypePropertyName == wxT("cell")){
2574 TelTypeUI.Append(_("mobile"));
2577 } else if (TypePropertyName == wxT("video")){
2579 TelTypeUI.Append(_("video"));
2582 } else if (TypePropertyName == wxT("pager")){
2584 TelTypeUI.Append(_("pager"));
2587 } else if (TypePropertyName == wxT("textphone")){
2589 TelTypeUI.Append(_("textphone"));
2600 std::map<int, wxString> *TelephoneList = NULL;
2601 std::map<int, wxString> *TelephoneListType = NULL;
2602 std::map<int, wxString> *TelephoneListAltID = NULL;
2603 std::map<int, wxString> *TelephoneListPID = NULL;
2604 std::map<int, wxString> *TelephoneListTokens = NULL;
2605 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2606 std::map<int, int> *TelephoneListPref = NULL;
2610 TelephoneList = &GeneralTelephoneList;
2611 TelephoneListType = &GeneralTelephoneListType;
2612 TelephoneListAltID = &GeneralTelephoneListAltID;
2613 TelephoneListPID = &GeneralTelephoneListPID;
2614 TelephoneListTokens = &GeneralTelephoneListTokens;
2615 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2616 TelephoneListPref = &GeneralTelephoneListPref;
2619 TelephoneList = &HomeTelephoneList;
2620 TelephoneListType = &HomeTelephoneListType;
2621 TelephoneListAltID = &HomeTelephoneListAltID;
2622 TelephoneListPID = &HomeTelephoneListPID;
2623 TelephoneListTokens = &HomeTelephoneListTokens;
2624 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2625 TelephoneListPref = &HomeTelephoneListPref;
2628 TelephoneList = &BusinessTelephoneList;
2629 TelephoneListType = &BusinessTelephoneListType;
2630 TelephoneListAltID = &BusinessTelephoneListAltID;
2631 TelephoneListPID = &BusinessTelephoneListPID;
2632 TelephoneListTokens = &BusinessTelephoneListTokens;
2633 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2634 TelephoneListPref = &BusinessTelephoneListPref;
2638 // Process the properties.
2640 bool FirstToken = TRUE;
2643 SplitPoints.clear();
2644 SplitLength.clear();
2646 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2650 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2651 intiter != SplitPoints.end(); ++intiter){
2653 SLiter = SplitLength.find(intiter->first);
2655 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2657 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2658 PropertyName = PropertyElement.GetNextToken();
2659 PropertyValue = PropertyElement.GetNextToken();
2661 intPrevValue = intiter->second;
2663 CaptureString(&PropertyValue, FALSE);
2665 // Process properties.
2667 if (PropertyName == wxT("ALTID")){
2669 TelephoneListAltID->erase(*TelephoneCount);
2670 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2672 } else if (PropertyName == wxT("PID")){
2674 TelephoneListPID->erase(*TelephoneCount);
2675 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2677 } else if (PropertyName == wxT("PREF")){
2679 int PriorityNumber = 0;
2680 bool ValidNumber = TRUE;
2683 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2686 catch(std::invalid_argument &e){
2687 ValidNumber = FALSE;
2690 if (ValidNumber == TRUE){
2692 TelephoneListPref->erase(*TelephoneCount);
2693 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2699 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2701 if (FirstToken == TRUE){
2703 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2708 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2718 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2719 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2721 // Add the name token data.
2723 if (!PropertyTokens.IsEmpty()){
2725 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2731 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2733 std::map<int, int> SplitPoints;
2734 std::map<int, int> SplitLength;
2736 int intPrevValue = 6;
2739 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2743 PropertyType PropType = PROPERTY_NONE;
2745 // Look for type before continuing.
2747 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2749 std::map<int, wxString> *LanguageList = NULL;
2750 std::map<int, wxString> *LanguageListType = NULL;
2751 std::map<int, wxString> *LanguageListAltID = NULL;
2752 std::map<int, wxString> *LanguageListPID = NULL;
2753 std::map<int, wxString> *LanguageListTokens = NULL;
2754 std::map<int, int> *LanguageListPref = NULL;
2758 LanguageList = &GeneralLanguageList;
2759 LanguageListType = &GeneralLanguageListType;
2760 LanguageListAltID = &GeneralLanguageListAltID;
2761 LanguageListPID = &GeneralLanguageListPID;
2762 LanguageListTokens = &GeneralLanguageListTokens;
2763 LanguageListPref = &GeneralLanguageListPref;
2766 LanguageList = &HomeLanguageList;
2767 LanguageListType = &HomeLanguageListType;
2768 LanguageListAltID = &HomeLanguageListAltID;
2769 LanguageListPID = &HomeLanguageListPID;
2770 LanguageListTokens = &HomeLanguageListTokens;
2771 LanguageListPref = &HomeLanguageListPref;
2774 LanguageList = &BusinessLanguageList;
2775 LanguageListType = &BusinessLanguageListType;
2776 LanguageListAltID = &BusinessLanguageListAltID;
2777 LanguageListPID = &BusinessLanguageListPID;
2778 LanguageListTokens = &BusinessLanguageListTokens;
2779 LanguageListPref = &BusinessLanguageListPref;
2785 std::map<int,int>::iterator SLiter;
2786 wxString PropertyData;
2787 wxString PropertyName;
2788 wxString PropertyValue;
2789 wxString PropertyTokens;
2790 bool FirstToken = TRUE;
2792 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2793 intiter != SplitPoints.end(); ++intiter){
2795 SLiter = SplitLength.find(intiter->first);
2797 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2799 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2800 PropertyName = PropertyElement.GetNextToken();
2801 PropertyValue = PropertyElement.GetNextToken();
2803 intPrevValue = intiter->second;
2805 CaptureString(&PropertyValue, FALSE);
2807 // Process properties.
2809 if (PropertyName == wxT("ALTID")){
2811 LanguageListAltID->erase(*LanguageCount);
2812 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2814 } else if (PropertyName == wxT("PID")){
2816 LanguageListPID->erase(*LanguageCount);
2817 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2819 } else if (PropertyName == wxT("PREF")){
2821 int PriorityNumber = 0;
2822 bool ValidNumber = TRUE;
2825 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2828 catch(std::invalid_argument &e){
2829 ValidNumber = FALSE;
2832 if (ValidNumber == TRUE){
2834 LanguageListPref->erase(*LanguageCount);
2835 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2841 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2843 if (FirstToken == TRUE){
2845 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2850 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2860 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2862 // Add the name token data.
2864 if (!PropertyTokens.IsEmpty()){
2866 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2872 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2874 std::map<int, int> SplitPoints;
2875 std::map<int, int> SplitLength;
2877 int intPrevValue = 5;
2880 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2884 PropertyType PropType = PROPERTY_NONE;
2886 // Look for type before continuing.
2888 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2890 std::map<int, wxString> *GeopositionList = NULL;
2891 std::map<int, wxString> *GeopositionListType = NULL;
2892 std::map<int, wxString> *GeopositionListAltID = NULL;
2893 std::map<int, wxString> *GeopositionListPID = NULL;
2894 std::map<int, wxString> *GeopositionListTokens = NULL;
2895 std::map<int, wxString> *GeopositionListMediatype = NULL;
2896 std::map<int, int> *GeopositionListPref = NULL;
2900 GeopositionList = &GeneralGeographyList;
2901 GeopositionListType = &GeneralGeographyListType;
2902 GeopositionListAltID = &GeneralGeographyListAltID;
2903 GeopositionListPID = &GeneralGeographyListPID;
2904 GeopositionListTokens = &GeneralGeographyListTokens;
2905 GeopositionListMediatype = &GeneralGeographyListMediatype;
2906 GeopositionListPref = &GeneralGeographyListPref;
2909 GeopositionList = &HomeGeographyList;
2910 GeopositionListType = &HomeGeographyListType;
2911 GeopositionListAltID = &HomeGeographyListAltID;
2912 GeopositionListPID = &HomeGeographyListPID;
2913 GeopositionListTokens = &HomeGeographyListTokens;
2914 GeopositionListMediatype = &HomeGeographyListMediatype;
2915 GeopositionListPref = &HomeGeographyListPref;
2918 GeopositionList = &BusinessGeographyList;
2919 GeopositionListType = &BusinessGeographyListType;
2920 GeopositionListAltID = &BusinessGeographyListAltID;
2921 GeopositionListPID = &BusinessGeographyListPID;
2922 GeopositionListTokens = &BusinessGeographyListTokens;
2923 GeopositionListMediatype = &BusinessGeographyListMediatype;
2924 GeopositionListPref = &BusinessGeographyListPref;
2930 std::map<int,int>::iterator SLiter;
2931 wxString PropertyData;
2932 wxString PropertyName;
2933 wxString PropertyValue;
2934 wxString PropertyTokens;
2935 bool FirstToken = TRUE;
2937 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2938 intiter != SplitPoints.end(); ++intiter){
2940 SLiter = SplitLength.find(intiter->first);
2942 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2944 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2945 PropertyName = PropertyElement.GetNextToken();
2946 PropertyValue = PropertyElement.GetNextToken();
2948 intPrevValue = intiter->second;
2950 CaptureString(&PropertyValue, FALSE);
2952 // Process properties.
2954 if (PropertyName == wxT("ALTID")){
2956 GeopositionListAltID->erase(*GeographicCount);
2957 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2959 } else if (PropertyName == wxT("PID")){
2961 GeopositionListPID->erase(*GeographicCount);
2962 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2964 } else if (PropertyName == wxT("MEDIATYPE")){
2966 GeopositionListMediatype->erase(*GeographicCount);
2967 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2969 } else if (PropertyName == wxT("PREF")){
2971 int PriorityNumber = 0;
2972 bool ValidNumber = TRUE;
2975 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2978 catch(std::invalid_argument &e){
2979 ValidNumber = FALSE;
2982 if (ValidNumber == TRUE){
2984 GeopositionListPref->erase(*GeographicCount);
2985 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2991 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2993 if (FirstToken == TRUE){
2995 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3000 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3010 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3012 // Add the name token data.
3014 if (!PropertyTokens.IsEmpty()){
3016 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3022 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3024 size_t intPropertyLen = PropertySeg1.Len();
3025 std::map<int, int> SplitPoints;
3026 std::map<int, int> SplitLength;
3027 std::map<int, int>::iterator SLiter;
3028 wxString PropertyData;
3029 wxString PropertyName;
3030 wxString PropertyValue;
3031 wxString PropertyTokens;
3032 wxString RelatedType;
3033 wxString RelatedTypeOriginal;
3034 wxString RelatedName;
3035 bool FirstToken = TRUE;
3036 int intSplitsFound = 0;
3037 int intSplitSize = 0;
3038 int intPrevValue = 9;
3042 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3046 // Look for type before continuing.
3048 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3049 intiter != SplitPoints.end(); ++intiter){
3051 SLiter = SplitLength.find(intiter->first);
3053 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3055 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3056 PropertyName = PropertyElement.GetNextToken();
3057 PropertyValue = PropertyElement.GetNextToken();
3059 intPrevValue = intiter->second;
3063 RelatedTypeOriginal = PropertyValue;
3065 if (PropertyName == wxT("TYPE")){
3067 if (PropertyValue == wxT("contact")){
3069 RelatedType = _("Contact");
3071 } else if (PropertyValue == wxT("acquaintance")){
3073 RelatedType = _("Acquaintance");
3075 } else if (PropertyValue == wxT("friend")){
3077 RelatedType = _("Friend");
3079 } else if (PropertyValue == wxT("met")){
3081 RelatedType = _("Met");
3083 } else if (PropertyValue == wxT("co-worker")){
3085 RelatedType = _("Co-worker");
3087 } else if (PropertyValue == wxT("colleague")){
3089 RelatedType = _("Colleague");
3091 } else if (PropertyValue == wxT("co-resident")){
3093 RelatedType = _("Co-resident");
3095 } else if (PropertyValue == wxT("neighbor")){
3097 RelatedType = _("Neighbour");
3099 } else if (PropertyValue == wxT("child")){
3101 RelatedType = _("Child");
3103 } else if (PropertyValue == wxT("parent")){
3105 RelatedType = _("Parent");
3107 } else if (PropertyValue == wxT("sibling")){
3109 RelatedType = _("Sibling");
3111 } else if (PropertyValue == wxT("spouse")){
3113 RelatedType = _("Spouse");
3115 } else if (PropertyValue == wxT("kin")){
3117 RelatedType = _("Kin");
3119 } else if (PropertyValue == wxT("muse")){
3121 RelatedType = _("Muse");
3123 } else if (PropertyValue == wxT("crush")){
3125 RelatedType = _("Crush");
3127 } else if (PropertyValue == wxT("date")){
3129 RelatedType = _("Date");
3131 } else if (PropertyValue == wxT("sweetheart")){
3133 RelatedType = _("Sweetheart");
3135 } else if (PropertyValue == wxT("me")){
3137 RelatedType = _("Me");
3139 } else if (PropertyValue == wxT("agent")){
3141 RelatedType = _("Agent");
3143 } else if (PropertyValue == wxT("emergency")){
3145 RelatedType = _("Emergency");
3149 RelatedType = PropertyValue;
3159 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3160 intiter != SplitPoints.end(); ++intiter){
3162 SLiter = SplitLength.find(intiter->first);
3164 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3166 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3167 PropertyName = PropertyElement.GetNextToken();
3168 PropertyValue = PropertyElement.GetNextToken();
3170 intPrevValue = intiter->second;
3172 // Process properties.
3174 size_t intPropertyValueLen = PropertyValue.Len();
3176 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3178 PropertyValue.Trim();
3179 PropertyValue.RemoveLast();
3183 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3185 PropertyValue.Remove(0, 1);
3189 CaptureString(&PropertyValue, FALSE);
3191 if (PropertyName == wxT("ALTID")){
3193 GeneralRelatedListAltID.erase(*RelatedCount);
3194 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3196 } else if (PropertyName == wxT("PID")){
3198 GeneralRelatedListPID.erase(*RelatedCount);
3199 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3201 } else if (PropertyName == wxT("PREF")){
3203 int PriorityNumber = 0;
3204 bool ValidNumber = TRUE;
3207 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3210 catch(std::invalid_argument &e){
3211 ValidNumber = FALSE;
3214 if (ValidNumber == TRUE){
3216 GeneralRelatedListPref.erase(*RelatedCount);
3217 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3221 } else if (PropertyName == wxT("LANGUAGE")){
3223 GeneralRelatedListLanguage.erase(*RelatedCount);
3224 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3226 } else if (PropertyName != wxT("TYPE")) {
3228 // Something else we don't know about so append
3229 // to the tokens variable.
3231 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3233 if (FirstToken == TRUE){
3235 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3240 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3250 // Add the data to the General/Home/Work address variables.
3252 GeneralRelatedList.erase(*RelatedCount);
3253 GeneralRelatedListRelType.erase(*RelatedCount);
3254 GeneralRelatedListType.erase(*RelatedCount);
3255 GeneralRelatedListTokens.erase(*RelatedCount);
3256 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3257 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3258 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3259 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3263 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3265 std::map<int, int> SplitPoints;
3266 std::map<int, int> SplitLength;
3267 std::map<int, int>::iterator SLiter;
3268 wxString PropertyData;
3269 wxString PropertyName;
3270 wxString PropertyValue;
3271 wxString PropertyTokens;
3272 bool FirstToken = TRUE;
3273 int intPrevValue = 5;
3278 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3282 PropertyType PropType = PROPERTY_NONE;
3284 // Look for type before continuing.
3286 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3288 // Setup the pointers.
3290 std::map<int, wxString> *WebsiteList = NULL;
3291 std::map<int, wxString> *WebsiteListAltID = NULL;
3292 std::map<int, wxString> *WebsiteListPID = NULL;
3293 std::map<int, wxString> *WebsiteListType = NULL;
3294 std::map<int, wxString> *WebsiteListTokens = NULL;
3295 std::map<int, wxString> *WebsiteListMediatype = NULL;
3296 std::map<int, int> *WebsiteListPref = NULL;
3298 // Setup blank lines for later on.
3302 WebsiteList = &GeneralWebsiteList;
3303 WebsiteListType = &GeneralWebsiteListType;
3304 WebsiteListAltID = &GeneralWebsiteListAltID;
3305 WebsiteListPID = &GeneralWebsiteListPID;
3306 WebsiteListTokens = &GeneralWebsiteListTokens;
3307 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3308 WebsiteListPref = &GeneralWebsiteListPref;
3311 WebsiteList = &HomeWebsiteList;
3312 WebsiteListType = &HomeWebsiteListType;
3313 WebsiteListAltID = &HomeWebsiteListAltID;
3314 WebsiteListPID = &HomeWebsiteListPID;
3315 WebsiteListTokens = &HomeWebsiteListTokens;
3316 WebsiteListMediatype = &HomeWebsiteListMediatype;
3317 WebsiteListPref = &HomeWebsiteListPref;
3320 WebsiteList = &BusinessWebsiteList;
3321 WebsiteListType = &BusinessWebsiteListType;
3322 WebsiteListAltID = &BusinessWebsiteListAltID;
3323 WebsiteListPID = &BusinessWebsiteListPID;
3324 WebsiteListTokens = &BusinessWebsiteListTokens;
3325 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3326 WebsiteListPref = &BusinessWebsiteListPref;
3332 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3333 intiter != SplitPoints.end(); ++intiter){
3335 SLiter = SplitLength.find(intiter->first);
3337 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3339 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3340 PropertyName = PropertyElement.GetNextToken();
3341 PropertyValue = PropertyElement.GetNextToken();
3343 intPrevValue = intiter->second;
3345 // Process properties.
3347 size_t intPropertyValueLen = PropertyValue.Len();
3349 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3351 PropertyValue.Trim();
3352 PropertyValue.RemoveLast();
3356 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3358 PropertyValue.Remove(0, 1);
3362 CaptureString(&PropertyValue, FALSE);
3364 if (PropertyName == wxT("ALTID")){
3366 WebsiteListAltID->erase(*URLCount);
3367 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3369 } else if (PropertyName == wxT("PID")){
3371 WebsiteListPID->erase(*URLCount);
3372 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3374 } else if (PropertyName == wxT("PREF")){
3376 int PriorityNumber = 0;
3377 bool ValidNumber = TRUE;
3380 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3383 catch(std::invalid_argument &e){
3384 ValidNumber = FALSE;
3387 if (ValidNumber == TRUE){
3389 WebsiteListPref->erase(*URLCount);
3390 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3394 } else if (PropertyName == wxT("MEDIATYPE")){
3396 WebsiteListMediatype->erase(*URLCount);
3397 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3401 // Something else we don't know about so append
3402 // to the tokens variable.
3404 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3406 if (FirstToken == TRUE){
3408 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3413 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3423 // Add the data to the General/Home/Work address variables.
3425 CaptureString(&PropertySeg2, FALSE);
3427 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3429 if (!PropertyTokens.IsEmpty()){
3431 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3437 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3439 std::map<int, int> SplitPoints;
3440 std::map<int, int> SplitLength;
3441 std::map<int, int>::iterator SLiter;
3442 wxString PropertyData;
3443 wxString PropertyName;
3444 wxString PropertyValue;
3445 wxString PropertyTokens;
3446 bool FirstToken = TRUE;
3447 int intPrevValue = 7;
3452 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3456 PropertyType PropType = PROPERTY_NONE;
3458 // Look for type before continuing.
3460 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3462 // Setup the pointers.
3464 std::map<int, wxString> *TitleList = NULL;
3465 std::map<int, wxString> *TitleListAltID = NULL;
3466 std::map<int, wxString> *TitleListPID = NULL;
3467 std::map<int, wxString> *TitleListType = NULL;
3468 std::map<int, wxString> *TitleListTokens = NULL;
3469 std::map<int, wxString> *TitleListLanguage = NULL;
3470 std::map<int, int> *TitleListPref = NULL;
3472 // Setup blank lines for later on.
3476 TitleList = &GeneralTitleList;
3477 TitleListType = &GeneralTitleListType;
3478 TitleListAltID = &GeneralTitleListAltID;
3479 TitleListPID = &GeneralTitleListPID;
3480 TitleListTokens = &GeneralTitleListTokens;
3481 TitleListLanguage = &GeneralTitleListLanguage;
3482 TitleListPref = &GeneralTitleListPref;
3485 TitleList = &HomeTitleList;
3486 TitleListType = &HomeTitleListType;
3487 TitleListAltID = &HomeTitleListAltID;
3488 TitleListPID = &HomeTitleListPID;
3489 TitleListTokens = &HomeTitleListTokens;
3490 TitleListLanguage = &HomeTitleListLanguage;
3491 TitleListPref = &HomeTitleListPref;
3494 TitleList = &BusinessTitleList;
3495 TitleListType = &BusinessTitleListType;
3496 TitleListAltID = &BusinessTitleListAltID;
3497 TitleListPID = &BusinessTitleListPID;
3498 TitleListTokens = &BusinessTitleListTokens;
3499 TitleListLanguage = &BusinessTitleListLanguage;
3500 TitleListPref = &BusinessTitleListPref;
3506 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3507 intiter != SplitPoints.end(); ++intiter){
3509 SLiter = SplitLength.find(intiter->first);
3511 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3513 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3514 PropertyName = PropertyElement.GetNextToken();
3515 PropertyValue = PropertyElement.GetNextToken();
3517 intPrevValue = intiter->second;
3519 // Process properties.
3521 size_t intPropertyValueLen = PropertyValue.Len();
3523 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3525 PropertyValue.Trim();
3526 PropertyValue.RemoveLast();
3530 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3532 PropertyValue.Remove(0, 1);
3536 CaptureString(&PropertyValue, FALSE);
3538 if (PropertyName == wxT("ALTID")){
3540 TitleListAltID->erase(*TitleCount);
3541 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3543 } else if (PropertyName == wxT("PID")){
3545 TitleListPID->erase(*TitleCount);
3546 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3548 } else if (PropertyName == wxT("PREF")){
3550 int PriorityNumber = 0;
3551 bool ValidNumber = TRUE;
3554 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3557 catch(std::invalid_argument &e){
3558 ValidNumber = FALSE;
3561 if (ValidNumber == TRUE){
3563 TitleListPref->erase(*TitleCount);
3564 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3568 } else if (PropertyName == wxT("LANGUAGE")){
3570 TitleListLanguage->erase(*TitleCount);
3571 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3575 // Something else we don't know about so append
3576 // to the tokens variable.
3578 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3580 if (FirstToken == TRUE){
3582 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3587 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3597 // Add the data to the General/Home/Work address variables.
3599 CaptureString(&PropertySeg2, FALSE);
3601 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3603 if (!PropertyTokens.IsEmpty()){
3605 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3611 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3613 std::map<int, int> SplitPoints;
3614 std::map<int, int> SplitLength;
3615 std::map<int, int>::iterator SLiter;
3616 wxString PropertyData;
3617 wxString PropertyName;
3618 wxString PropertyValue;
3619 wxString PropertyTokens;
3620 bool FirstToken = TRUE;
3621 int intPrevValue = 6;
3626 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3630 PropertyType PropType = PROPERTY_NONE;
3632 // Look for type before continuing.
3634 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3636 // Setup the pointers.
3638 std::map<int, wxString> *RoleList = NULL;
3639 std::map<int, wxString> *RoleListAltID = NULL;
3640 std::map<int, wxString> *RoleListPID = NULL;
3641 std::map<int, wxString> *RoleListType = NULL;
3642 std::map<int, wxString> *RoleListTokens = NULL;
3643 std::map<int, wxString> *RoleListLanguage = NULL;
3644 std::map<int, int> *RoleListPref = NULL;
3646 // Setup blank lines for later on.
3650 RoleList = &GeneralRoleList;
3651 RoleListType = &GeneralRoleListType;
3652 RoleListAltID = &GeneralRoleListAltID;
3653 RoleListPID = &GeneralRoleListPID;
3654 RoleListTokens = &GeneralRoleListTokens;
3655 RoleListLanguage = &GeneralRoleListLanguage;
3656 RoleListPref = &GeneralRoleListPref;
3659 RoleList = &HomeRoleList;
3660 RoleListType = &HomeRoleListType;
3661 RoleListAltID = &HomeRoleListAltID;
3662 RoleListPID = &HomeRoleListPID;
3663 RoleListTokens = &HomeRoleListTokens;
3664 RoleListLanguage = &HomeRoleListLanguage;
3665 RoleListPref = &HomeRoleListPref;
3668 RoleList = &BusinessRoleList;
3669 RoleListType = &BusinessRoleListType;
3670 RoleListAltID = &BusinessRoleListAltID;
3671 RoleListPID = &BusinessRoleListPID;
3672 RoleListTokens = &BusinessRoleListTokens;
3673 RoleListLanguage = &BusinessRoleListLanguage;
3674 RoleListPref = &BusinessRoleListPref;
3680 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3681 intiter != SplitPoints.end(); ++intiter){
3683 SLiter = SplitLength.find(intiter->first);
3685 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3687 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3688 PropertyName = PropertyElement.GetNextToken();
3689 PropertyValue = PropertyElement.GetNextToken();
3691 intPrevValue = intiter->second;
3693 // Process properties.
3695 size_t intPropertyValueLen = PropertyValue.Len();
3697 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3699 PropertyValue.Trim();
3700 PropertyValue.RemoveLast();
3704 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3706 PropertyValue.Remove(0, 1);
3710 CaptureString(&PropertyValue, FALSE);
3712 if (PropertyName == wxT("ALTID")){
3714 RoleListAltID->erase(*RoleCount);
3715 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3717 } else if (PropertyName == wxT("PID")){
3719 RoleListPID->erase(*RoleCount);
3720 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3722 } else if (PropertyName == wxT("PREF")){
3724 int PriorityNumber = 0;
3725 bool ValidNumber = TRUE;
3728 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3731 catch(std::invalid_argument &e){
3732 ValidNumber = FALSE;
3735 if (ValidNumber == TRUE){
3737 RoleListPref->erase(*RoleCount);
3738 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3742 } else if (PropertyName == wxT("LANGUAGE")){
3744 RoleListLanguage->erase(*RoleCount);
3745 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3749 // Something else we don't know about so append
3750 // to the tokens variable.
3752 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3754 if (FirstToken == TRUE){
3756 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3761 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3771 // Add the data to the General/Home/Work address variables.
3773 CaptureString(&PropertySeg2, FALSE);
3775 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3777 if (!PropertyTokens.IsEmpty()){
3779 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3785 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3787 std::map<int, int> SplitPoints;
3788 std::map<int, int> SplitLength;
3789 std::map<int, int>::iterator SLiter;
3790 wxString PropertyData;
3791 wxString PropertyName;
3792 wxString PropertyValue;
3793 wxString PropertyTokens;
3794 bool FirstToken = TRUE;
3795 int intPrevValue = 5;
3800 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3804 PropertyType PropType = PROPERTY_NONE;
3806 // Look for type before continuing.
3808 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3810 // Setup the pointers.
3812 std::map<int, wxString> *OrganisationsList = NULL;
3813 std::map<int, wxString> *OrganisationsListAltID = NULL;
3814 std::map<int, wxString> *OrganisationsListPID = NULL;
3815 std::map<int, wxString> *OrganisationsListType = NULL;
3816 std::map<int, wxString> *OrganisationsListTokens = NULL;
3817 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3818 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3819 std::map<int, int> *OrganisationsListPref = NULL;
3821 // Setup blank lines for later on.
3825 OrganisationsList = &GeneralOrganisationsList;
3826 OrganisationsListType = &GeneralOrganisationsListType;
3827 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3828 OrganisationsListPID = &GeneralOrganisationsListPID;
3829 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3830 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3831 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3832 OrganisationsListPref = &GeneralOrganisationsListPref;
3835 OrganisationsList = &HomeOrganisationsList;
3836 OrganisationsListType = &HomeOrganisationsListType;
3837 OrganisationsListAltID = &HomeOrganisationsListAltID;
3838 OrganisationsListPID = &HomeOrganisationsListPID;
3839 OrganisationsListTokens = &HomeOrganisationsListTokens;
3840 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3841 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3842 OrganisationsListPref = &HomeOrganisationsListPref;
3845 OrganisationsList = &BusinessOrganisationsList;
3846 OrganisationsListType = &BusinessOrganisationsListType;
3847 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3848 OrganisationsListPID = &BusinessOrganisationsListPID;
3849 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3850 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3851 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3852 OrganisationsListPref = &BusinessOrganisationsListPref;
3858 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3859 intiter != SplitPoints.end(); ++intiter){
3861 SLiter = SplitLength.find(intiter->first);
3863 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3865 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3866 PropertyName = PropertyElement.GetNextToken();
3867 PropertyValue = PropertyElement.GetNextToken();
3869 intPrevValue = intiter->second;
3871 // Process properties.
3873 size_t intPropertyValueLen = PropertyValue.Len();
3875 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3877 PropertyValue.Trim();
3878 PropertyValue.RemoveLast();
3882 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3884 PropertyValue.Remove(0, 1);
3888 CaptureString(&PropertyValue, FALSE);
3890 if (PropertyName == wxT("ALTID")){
3892 OrganisationsListAltID->erase(*OrganisationCount);
3893 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3895 } else if (PropertyName == wxT("PID")){
3897 OrganisationsListPID->erase(*OrganisationCount);
3898 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3900 } else if (PropertyName == wxT("SORT-AS")){
3902 OrganisationsListSortAs->erase(*OrganisationCount);
3903 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3905 } else if (PropertyName == wxT("PREF")){
3907 int PriorityNumber = 0;
3908 bool ValidNumber = TRUE;
3911 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3914 catch(std::invalid_argument &e){
3915 ValidNumber = FALSE;
3918 if (ValidNumber == TRUE){
3920 OrganisationsListPref->erase(*OrganisationCount);
3921 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3925 } else if (PropertyName == wxT("LANGUAGE")){
3927 OrganisationsListLanguage->erase(*OrganisationCount);
3928 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3932 // Something else we don't know about so append
3933 // to the tokens variable.
3935 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3937 if (FirstToken == TRUE){
3939 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3944 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3954 // Add the data to the General/Home/Work address variables.
3956 CaptureString(&PropertySeg2, FALSE);
3958 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3960 if (!PropertyTokens.IsEmpty()){
3962 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3968 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3970 std::map<int, int> SplitPoints;
3971 std::map<int, int> SplitLength;
3972 std::map<int, int>::iterator SLiter;
3973 wxString PropertyData;
3974 wxString PropertyName;
3975 wxString PropertyValue;
3976 wxString PropertyTokens;
3977 bool FirstToken = TRUE;
3978 int intPrevValue = 6;
3983 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3987 PropertyType PropType = PROPERTY_NONE;
3989 // Look for type before continuing.
3991 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3993 // Setup the pointers.
3995 std::map<int, wxString> *NoteList = NULL;
3996 std::map<int, wxString> *NoteListAltID = NULL;
3997 std::map<int, wxString> *NoteListPID = NULL;
3998 std::map<int, wxString> *NoteListType = NULL;
3999 std::map<int, wxString> *NoteListTokens = NULL;
4000 std::map<int, wxString> *NoteListLanguage = NULL;
4001 std::map<int, int> *NoteListPref = NULL;
4003 // Setup blank lines for later on.
4007 NoteList = &GeneralNoteList;
4008 NoteListType = &GeneralNoteListType;
4009 NoteListAltID = &GeneralNoteListAltID;
4010 NoteListPID = &GeneralNoteListPID;
4011 NoteListTokens = &GeneralNoteListTokens;
4012 NoteListLanguage = &GeneralNoteListLanguage;
4013 NoteListPref = &GeneralNoteListPref;
4016 NoteList = &HomeNoteList;
4017 NoteListType = &HomeNoteListType;
4018 NoteListAltID = &HomeNoteListAltID;
4019 NoteListPID = &HomeNoteListPID;
4020 NoteListTokens = &HomeNoteListTokens;
4021 NoteListLanguage = &HomeNoteListLanguage;
4022 NoteListPref = &HomeNoteListPref;
4025 NoteList = &BusinessNoteList;
4026 NoteListType = &BusinessNoteListType;
4027 NoteListAltID = &BusinessNoteListAltID;
4028 NoteListPID = &BusinessNoteListPID;
4029 NoteListTokens = &BusinessNoteListTokens;
4030 NoteListLanguage = &BusinessNoteListLanguage;
4031 NoteListPref = &BusinessNoteListPref;
4037 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4038 intiter != SplitPoints.end(); ++intiter){
4040 SLiter = SplitLength.find(intiter->first);
4042 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4044 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4045 PropertyName = PropertyElement.GetNextToken();
4046 PropertyValue = PropertyElement.GetNextToken();
4048 intPrevValue = intiter->second;
4050 // Process properties.
4052 size_t intPropertyValueLen = PropertyValue.Len();
4054 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4056 PropertyValue.Trim();
4057 PropertyValue.RemoveLast();
4061 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4063 PropertyValue.Remove(0, 1);
4067 CaptureString(&PropertyValue, FALSE);
4069 if (PropertyName == wxT("ALTID")){
4071 NoteListAltID->erase(*NoteCount);
4072 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4074 } else if (PropertyName == wxT("PID")){
4076 NoteListPID->erase(*NoteCount);
4077 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4079 } else if (PropertyName == wxT("PREF")){
4081 int PriorityNumber = 0;
4082 bool ValidNumber = TRUE;
4085 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4088 catch(std::invalid_argument &e){
4089 ValidNumber = FALSE;
4092 if (ValidNumber == TRUE){
4094 NoteListPref->erase(*NoteCount);
4095 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4099 } else if (PropertyName == wxT("LANGUAGE")){
4101 NoteListLanguage->erase(*NoteCount);
4102 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4106 // Something else we don't know about so append
4107 // to the tokens variable.
4109 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4111 if (FirstToken == TRUE){
4113 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4118 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4128 // Add the data to the General/Home/Work address variables.
4130 CaptureString(&PropertySeg2, FALSE);
4132 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4134 if (!PropertyTokens.IsEmpty()){
4136 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4142 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4144 std::map<int, int> SplitPoints;
4145 std::map<int, int> SplitLength;
4146 std::map<int, int>::iterator SLiter;
4147 wxString PropertyData;
4148 wxString PropertyName;
4149 wxString PropertyValue;
4150 wxString PropertyTokens;
4151 bool FirstToken = TRUE;
4152 int intPrevValue = 12;
4157 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4161 PropertyType PropType = PROPERTY_NONE;
4163 // Look for type before continuing.
4165 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4167 // Setup blank lines for later on.
4173 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4176 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4182 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4183 intiter != SplitPoints.end(); ++intiter){
4185 SLiter = SplitLength.find(intiter->first);
4187 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4189 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4190 PropertyName = PropertyElement.GetNextToken();
4191 PropertyValue = PropertyElement.GetNextToken();
4193 intPrevValue = intiter->second;
4195 // Process properties.
4197 size_t intPropertyValueLen = PropertyValue.Len();
4199 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4201 PropertyValue.Trim();
4202 PropertyValue.RemoveLast();
4206 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4208 PropertyValue.Remove(0, 1);
4212 CaptureString(&PropertyValue, FALSE);
4214 if (PropertyName == wxT("ALTID")){
4216 CategoriesListAltID.erase(*CategoryCount);
4217 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4219 } else if (PropertyName == wxT("PID")){
4221 CategoriesListPID.erase(*CategoryCount);
4222 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4224 } else if (PropertyName == wxT("PREF")){
4226 int PriorityNumber = 0;
4227 bool ValidNumber = TRUE;
4230 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4233 catch(std::invalid_argument &e){
4234 ValidNumber = FALSE;
4237 if (ValidNumber == TRUE){
4239 CategoriesListPref.erase(*CategoryCount);
4240 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4244 } else if (PropertyName == wxT("LANGUAGE")){
4246 CategoriesListLanguage.erase(*CategoryCount);
4247 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4251 // Something else we don't know about so append
4252 // to the tokens variable.
4254 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4256 if (FirstToken == TRUE){
4258 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4263 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4273 // Deal with multiple categories.
4275 int intOrigCatCount = *CategoryCount;
4276 bool FirstCategoryProcessed = TRUE;
4277 bool AfterFirstToken = FALSE;
4278 int intSplitSize = 0;
4279 int intSplitsFound = 0;
4280 int intSplitSeek = 0;
4281 int intPropertyLen = PropertySeg2.Len();
4283 SplitPoints.clear();
4284 SplitLength.clear();
4287 for (int i = 0; i <= intPropertyLen; i++){
4289 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4297 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4299 if (AfterFirstToken == TRUE){
4301 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4302 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4306 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4307 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4308 AfterFirstToken = TRUE;
4320 if (SplitPoints.size() > 0){
4322 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4323 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4327 if (SplitPoints.size() == 0){
4329 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4331 if (!PropertyTokens.IsEmpty()){
4333 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4339 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4340 intiter != SplitPoints.end(); ++intiter){
4342 SLiter = SplitLength.find(intiter->first);
4344 intPrevValue = intiter->second;
4346 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4348 // Add the data to the General/Home/Work address variables.
4350 // Trim any whitespace from the start and end.
4352 PropertyData = PropertyData.Trim(FALSE);
4353 PropertyData = PropertyData.Trim(TRUE);
4355 CaptureString(&PropertyData, FALSE);
4357 if (FirstCategoryProcessed == TRUE){
4359 FirstCategoryProcessed = FALSE;
4361 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4363 if (!PropertyTokens.IsEmpty()){
4365 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4375 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4377 if (!PropertyTokens.IsEmpty()){
4379 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4385 // Copy the properties to each of the categories (if it exists).
4387 if (!PropertyTokens.IsEmpty()){
4389 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4393 // Check if ALTID was used.
4395 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4397 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4401 // Check if PID was used.
4403 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4405 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4409 // Check if PREF was used.
4411 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4413 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4417 // Check if LANGUAGE was used.
4419 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4421 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4425 // Check if TYPE was used.
4431 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4434 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4442 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4444 size_t intPropertyLen = PropertySeg1.Len();
4445 std::map<int, int> SplitPoints;
4446 std::map<int, int> SplitLength;
4447 std::map<int, int>::iterator SLiter;
4448 wxString PropertyData;
4449 wxString PropertyName;
4450 wxString PropertyValue;
4451 wxString PropertyTokens;
4452 bool FirstToken = TRUE;
4453 int intSplitsFound = 0;
4454 int intSplitSize = 0;
4455 int intPrevValue = 7;
4459 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4463 PropertyType PropType = PROPERTY_NONE;
4465 // Look for type before continuing.
4467 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4471 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4472 intiter != SplitPoints.end(); ++intiter){
4474 SLiter = SplitLength.find(intiter->first);
4476 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4478 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4479 PropertyName = PropertyElement.GetNextToken();
4480 PropertyValue = PropertyElement.GetNextToken();
4482 intPrevValue = intiter->second;
4484 // Process properties.
4486 size_t intPropertyValueLen = PropertyValue.Len();
4488 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4490 PropertyValue.Trim();
4491 PropertyValue.RemoveLast();
4495 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4497 PropertyValue.Remove(0, 1);
4501 CaptureString(&PropertyValue, FALSE);
4503 if (PropertyName == wxT("ALTID")){
4505 PicturesListAltID.erase(*PhotoCount);
4506 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4508 } else if (PropertyName == wxT("PID")){
4510 PicturesListPID.erase(*PhotoCount);
4511 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4513 } else if (PropertyName == wxT("PREF")){
4515 int PriorityNumber = 0;
4516 bool ValidNumber = TRUE;
4519 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4522 catch(std::invalid_argument &e){
4523 ValidNumber = FALSE;
4526 if (ValidNumber == TRUE){
4528 PicturesListPref.erase(*PhotoCount);
4529 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4533 } else if (PropertyName == wxT("MEDIATYPE")){
4535 PicturesListMediatype.erase(*PhotoCount);
4536 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4540 // Something else we don't know about so append
4541 // to the tokens variable.
4543 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4545 if (FirstToken == TRUE){
4547 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4552 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4562 intPropertyLen = PropertySeg2.Len();
4563 SplitPoints.clear();
4564 SplitLength.clear();
4569 CaptureString(&PropertySeg2, FALSE);
4571 for (int i = 0; i <= intPropertyLen; i++){
4575 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4578 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4580 if (intSplitsFound == 6){
4582 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4587 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4597 wxString wxSPhotoURI;
4598 wxString wxSPhotoMIME;
4599 wxString wxSPhotoEncoding;
4600 wxString wxSPhotoData;
4601 std::string base64enc;
4603 if (intSplitsFound == 0){
4607 std::map<int, int>::iterator striter;
4609 striter = SplitLength.find(1);
4611 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4613 while (wSTDataType.HasMoreTokens() == TRUE){
4615 wxSPhotoURI = wSTDataType.GetNextToken();
4616 wxSPhotoMIME = wSTDataType.GetNextToken();
4621 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4623 while (wSTDataInfo.HasMoreTokens() == TRUE){
4625 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4626 wxSPhotoData = wSTDataInfo.GetNextToken();
4627 base64enc = wxSPhotoData.mb_str();
4634 // Add the data to the General/Home/Work address variables.
4636 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4637 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4638 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4644 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4647 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4651 if (!PropertyTokens.IsEmpty()){
4653 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4659 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4661 size_t intPropertyLen = PropertySeg1.Len();
4662 std::map<int, int> SplitPoints;
4663 std::map<int, int> SplitLength;
4664 std::map<int, int>::iterator SLiter;
4665 wxString PropertyData;
4666 wxString PropertyName;
4667 wxString PropertyValue;
4668 wxString PropertyTokens;
4669 bool FirstToken = TRUE;
4670 int intSplitsFound = 0;
4671 int intSplitSize = 0;
4672 int intPrevValue = 6;
4676 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4680 PropertyType PropType = PROPERTY_NONE;
4682 // Look for type before continuing.
4684 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4688 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4689 intiter != SplitPoints.end(); ++intiter){
4691 SLiter = SplitLength.find(intiter->first);
4693 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4695 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4696 PropertyName = PropertyElement.GetNextToken();
4697 PropertyValue = PropertyElement.GetNextToken();
4699 intPrevValue = intiter->second;
4701 // Process properties.
4703 size_t intPropertyValueLen = PropertyValue.Len();
4705 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4707 PropertyValue.Trim();
4708 PropertyValue.RemoveLast();
4712 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4714 PropertyValue.Remove(0, 1);
4718 CaptureString(&PropertyValue, FALSE);
4720 if (PropertyName == wxT("ALTID")){
4722 LogosListAltID.erase(*LogoCount);
4723 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4725 } else if (PropertyName == wxT("PID")){
4727 LogosListPID.erase(*LogoCount);
4728 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4730 } else if (PropertyName == wxT("PREF")){
4732 int PriorityNumber = 0;
4733 bool ValidNumber = TRUE;
4736 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4739 catch(std::invalid_argument &e){
4740 ValidNumber = FALSE;
4743 if (ValidNumber == TRUE){
4745 LogosListPref.erase(*LogoCount);
4746 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4750 } else if (PropertyName == wxT("MEDIATYPE")){
4752 LogosListMediatype.erase(*LogoCount);
4753 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4757 // Something else we don't know about so append
4758 // to the tokens variable.
4760 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4762 if (FirstToken == TRUE){
4764 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4769 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4779 intPropertyLen = PropertySeg2.Len();
4780 SplitPoints.clear();
4781 SplitLength.clear();
4786 CaptureString(&PropertySeg2, FALSE);
4788 for (int i = 0; i <= intPropertyLen; i++){
4792 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4795 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4797 if (intSplitsFound == 6){
4799 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4804 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4814 wxString wxSPhotoURI;
4815 wxString wxSPhotoMIME;
4816 wxString wxSPhotoEncoding;
4817 wxString wxSPhotoData;
4818 std::string base64enc;
4820 if (intSplitsFound == 0){
4824 std::map<int, int>::iterator striter;
4826 striter = SplitLength.find(1);
4828 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4830 while (wSTDataType.HasMoreTokens() == TRUE){
4832 wxSPhotoURI = wSTDataType.GetNextToken();
4833 wxSPhotoMIME = wSTDataType.GetNextToken();
4838 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4840 while (wSTDataInfo.HasMoreTokens() == TRUE){
4842 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4843 wxSPhotoData = wSTDataInfo.GetNextToken();
4844 base64enc = wxSPhotoData.mb_str();
4851 // Add the data to the General/Home/Work address variables.
4853 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4854 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4855 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4861 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4864 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4868 if (!PropertyTokens.IsEmpty()){
4870 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4876 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4878 size_t intPropertyLen = PropertySeg1.Len();
4879 std::map<int, int> SplitPoints;
4880 std::map<int, int> SplitLength;
4881 std::map<int, int>::iterator SLiter;
4882 wxString PropertyData;
4883 wxString PropertyName;
4884 wxString PropertyValue;
4885 wxString PropertyTokens;
4886 bool FirstToken = TRUE;
4887 int intSplitsFound = 0;
4888 int intSplitSize = 0;
4889 int intPrevValue = 7;
4893 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4897 PropertyType PropType = PROPERTY_NONE;
4899 // Look for type before continuing.
4901 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4905 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4906 intiter != SplitPoints.end(); ++intiter){
4908 SLiter = SplitLength.find(intiter->first);
4910 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4912 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4913 PropertyName = PropertyElement.GetNextToken();
4914 PropertyValue = PropertyElement.GetNextToken();
4916 intPrevValue = intiter->second;
4918 // Process properties.
4920 size_t intPropertyValueLen = PropertyValue.Len();
4922 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4924 PropertyValue.Trim();
4925 PropertyValue.RemoveLast();
4929 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4931 PropertyValue.Remove(0, 1);
4935 CaptureString(&PropertyValue, FALSE);
4937 if (PropertyName == wxT("ALTID")){
4939 SoundsListAltID.erase(*SoundCount);
4940 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4942 } else if (PropertyName == wxT("PID")){
4944 SoundsListPID.erase(*SoundCount);
4945 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4947 } else if (PropertyName == wxT("PREF")){
4949 int PriorityNumber = 0;
4950 bool ValidNumber = TRUE;
4953 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4956 catch(std::invalid_argument &e){
4957 ValidNumber = FALSE;
4960 if (ValidNumber == TRUE){
4962 SoundsListPref.erase(*SoundCount);
4963 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4967 } else if (PropertyName == wxT("MEDIATYPE")){
4969 SoundsListMediatype.erase(*SoundCount);
4970 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4972 } else if (PropertyName == wxT("LANGUAGE")){
4974 SoundsListLanguage.erase(*SoundCount);
4975 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4979 // Something else we don't know about so append
4980 // to the tokens variable.
4982 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4984 if (FirstToken == TRUE){
4986 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4991 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5001 intPropertyLen = PropertySeg2.Len();
5002 SplitPoints.clear();
5003 SplitLength.clear();
5008 CaptureString(&PropertySeg2, FALSE);
5010 for (int i = 0; i <= intPropertyLen; i++){
5014 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5017 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5019 if (intSplitsFound == 6){
5021 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5026 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5036 wxString wxSSoundURI;
5037 wxString wxSSoundMIME;
5038 wxString wxSSoundEncoding;
5039 wxString wxSSoundData;
5040 std::string base64enc;
5042 if (intSplitsFound == 0){
5046 std::map<int, int>::iterator striter;
5048 striter = SplitLength.find(1);
5050 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5052 while (wSTDataType.HasMoreTokens() == TRUE){
5054 wxSSoundURI = wSTDataType.GetNextToken();
5055 wxSSoundMIME = wSTDataType.GetNextToken();
5060 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5062 while (wSTDataInfo.HasMoreTokens() == TRUE){
5064 wxSSoundEncoding = wSTDataInfo.GetNextToken();
5065 wxSSoundData = wSTDataInfo.GetNextToken();
5066 base64enc = wxSSoundData.mb_str();
5073 // Add the data to the General/Home/Work address variables.
5079 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5082 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5086 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5087 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5088 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5090 if (!PropertyTokens.IsEmpty()){
5092 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5098 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5100 size_t intPropertyLen = PropertySeg1.Len();
5101 std::map<int, int> SplitPoints;
5102 std::map<int, int> SplitLength;
5103 std::map<int, int>::iterator SLiter;
5104 wxString PropertyData;
5105 wxString PropertyName;
5106 wxString PropertyValue;
5107 wxString PropertyTokens;
5108 bool FirstToken = TRUE;
5109 int intSplitsFound = 0;
5110 int intSplitSize = 0;
5111 int intPrevValue = 8;
5115 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5119 PropertyType PropType = PROPERTY_NONE;
5121 // Look for type before continuing.
5123 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5127 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5128 intiter != SplitPoints.end(); ++intiter){
5130 SLiter = SplitLength.find(intiter->first);
5132 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5134 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5135 PropertyName = PropertyElement.GetNextToken();
5136 PropertyValue = PropertyElement.GetNextToken();
5138 intPrevValue = intiter->second;
5140 // Process properties.
5142 size_t intPropertyValueLen = PropertyValue.Len();
5144 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5146 PropertyValue.Trim();
5147 PropertyValue.RemoveLast();
5151 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5153 PropertyValue.Remove(0, 1);
5157 CaptureString(&PropertyValue, FALSE);
5159 if (PropertyName == wxT("ALTID")){
5161 CalendarListAltID.erase(*CalURICount);
5162 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5164 } else if (PropertyName == wxT("PID")){
5166 CalendarListPID.erase(*CalURICount);
5167 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5169 } else if (PropertyName == wxT("PREF")){
5171 int PriorityNumber = 0;
5172 bool ValidNumber = TRUE;
5175 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5178 catch(std::invalid_argument &e){
5179 ValidNumber = FALSE;
5182 if (ValidNumber == TRUE){
5184 CalendarListPref.erase(*CalURICount);
5185 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5189 } else if (PropertyName == wxT("MEDIATYPE")){
5191 CalendarListMediatype.erase(*CalURICount);
5192 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5196 // Something else we don't know about so append
5197 // to the tokens variable.
5199 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5201 if (FirstToken == TRUE){
5203 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5208 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5218 intPropertyLen = PropertySeg2.Len();
5219 SplitPoints.clear();
5220 SplitLength.clear();
5225 CaptureString(&PropertySeg2, FALSE);
5227 // Add the data to the General/Home/Work address variables.
5233 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5236 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5240 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5242 if (!PropertyTokens.IsEmpty()){
5244 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5250 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5252 size_t intPropertyLen = PropertySeg1.Len();
5253 std::map<int, int> SplitPoints;
5254 std::map<int, int> SplitLength;
5255 std::map<int, int>::iterator SLiter;
5256 wxString PropertyData;
5257 wxString PropertyName;
5258 wxString PropertyValue;
5259 wxString PropertyTokens;
5260 bool FirstToken = TRUE;
5261 int intSplitsFound = 0;
5262 int intSplitSize = 0;
5263 int intPrevValue = 8;
5267 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5271 PropertyType PropType = PROPERTY_NONE;
5273 // Look for type before continuing.
5275 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5279 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5280 intiter != SplitPoints.end(); ++intiter){
5282 SLiter = SplitLength.find(intiter->first);
5284 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5286 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5287 PropertyName = PropertyElement.GetNextToken();
5288 PropertyValue = PropertyElement.GetNextToken();
5290 intPrevValue = intiter->second;
5292 // Process properties.
5294 size_t intPropertyValueLen = PropertyValue.Len();
5296 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5298 PropertyValue.Trim();
5299 PropertyValue.RemoveLast();
5303 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5305 PropertyValue.Remove(0, 1);
5309 CaptureString(&PropertyValue, FALSE);
5311 if (PropertyName == wxT("ALTID")){
5313 CalendarRequestListAltID.erase(*CalAdrURICount);
5314 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5316 } else if (PropertyName == wxT("PID")){
5318 CalendarRequestListPID.erase(*CalAdrURICount);
5319 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5321 } else if (PropertyName == wxT("PREF")){
5323 int PriorityNumber = 0;
5324 bool ValidNumber = TRUE;
5327 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5330 catch(std::invalid_argument &e){
5331 ValidNumber = FALSE;
5334 if (ValidNumber == TRUE){
5336 CalendarRequestListPref.erase(*CalAdrURICount);
5337 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5341 } else if (PropertyName == wxT("MEDIATYPE")){
5343 CalendarRequestListMediatype.erase(*CalAdrURICount);
5344 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5348 // Something else we don't know about so append
5349 // to the tokens variable.
5351 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5353 if (FirstToken == TRUE){
5355 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5360 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5370 intPropertyLen = PropertySeg2.Len();
5371 SplitPoints.clear();
5372 SplitLength.clear();
5377 CaptureString(&PropertySeg2, FALSE);
5379 // Add the data to the General/Home/Work address variables.
5385 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5388 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5392 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5394 if (!PropertyTokens.IsEmpty()){
5396 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5402 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5404 size_t intPropertyLen = PropertySeg1.Len();
5405 std::map<int, int> SplitPoints;
5406 std::map<int, int> SplitLength;
5407 std::map<int, int>::iterator SLiter;
5408 wxString PropertyData;
5409 wxString PropertyName;
5410 wxString PropertyValue;
5411 wxString PropertyTokens;
5412 bool FirstToken = TRUE;
5413 int intSplitsFound = 0;
5414 int intSplitSize = 0;
5415 int intPrevValue = 7;
5419 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5423 PropertyType PropType = PROPERTY_NONE;
5425 // Look for type before continuing.
5427 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5431 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5432 intiter != SplitPoints.end(); ++intiter){
5434 SLiter = SplitLength.find(intiter->first);
5436 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5438 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5439 PropertyName = PropertyElement.GetNextToken();
5440 PropertyValue = PropertyElement.GetNextToken();
5442 intPrevValue = intiter->second;
5444 // Process properties.
5446 size_t intPropertyValueLen = PropertyValue.Len();
5448 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5450 PropertyValue.Trim();
5451 PropertyValue.RemoveLast();
5455 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5457 PropertyValue.Remove(0, 1);
5461 CaptureString(&PropertyValue, FALSE);
5463 if (PropertyName == wxT("ALTID")){
5465 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5466 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5468 } else if (PropertyName == wxT("PID")){
5470 FreeBusyListPID.erase(*FreeBusyAddressCount);
5471 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5473 } else if (PropertyName == wxT("PREF")){
5475 int PriorityNumber = 0;
5476 bool ValidNumber = TRUE;
5479 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5482 catch(std::invalid_argument &e){
5483 ValidNumber = FALSE;
5486 if (ValidNumber == TRUE){
5488 FreeBusyListPref.erase(*FreeBusyAddressCount);
5489 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5493 } else if (PropertyName == wxT("MEDIATYPE")){
5495 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5496 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5500 // Something else we don't know about so append
5501 // to the tokens variable.
5503 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5505 if (FirstToken == TRUE){
5507 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5512 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5522 intPropertyLen = PropertySeg2.Len();
5523 SplitPoints.clear();
5524 SplitLength.clear();
5529 CaptureString(&PropertySeg2, FALSE);
5531 // Add the data to the General/Home/Work address variables.
5537 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5540 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5544 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5546 if (!PropertyTokens.IsEmpty()){
5548 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5554 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5556 size_t intPropertyLen = PropertySeg1.Len();
5557 std::map<int, int> SplitPoints;
5558 std::map<int, int> SplitLength;
5559 std::map<int, int>::iterator SLiter;
5560 wxString PropertyData;
5561 wxString PropertyName;
5562 wxString PropertyValue;
5563 wxString PropertyTokens;
5564 bool FirstToken = TRUE;
5565 int intSplitsFound = 0;
5566 int intSplitSize = 0;
5567 int intPrevValue = 5;
5572 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5576 PropertyType PropType = PROPERTY_NONE;
5578 // Look for type before continuing.
5580 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5584 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5585 intiter != SplitPoints.end(); ++intiter){
5587 SLiter = SplitLength.find(intiter->first);
5589 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5591 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5592 PropertyName = PropertyElement.GetNextToken();
5593 PropertyValue = PropertyElement.GetNextToken();
5595 intPrevValue = intiter->second;
5597 // Process properties.
5599 size_t intPropertyValueLen = PropertyValue.Len();
5601 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5603 PropertyValue.Trim();
5604 PropertyValue.RemoveLast();
5608 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5610 PropertyValue.Remove(0, 1);
5614 if (PropertyName == wxT("ALTID")){
5616 KeyListAltID.erase(*KeyCount);
5617 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5619 } else if (PropertyName == wxT("PID")){
5621 KeyListPID.erase(*KeyCount);
5622 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5624 } else if (PropertyName == wxT("PREF")){
5626 int PriorityNumber = 0;
5627 bool ValidNumber = TRUE;
5630 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5633 catch(std::invalid_argument &e){
5634 ValidNumber = FALSE;
5637 if (ValidNumber == TRUE){
5639 KeyListPref.erase(*KeyCount);
5640 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5646 // Something else we don't know about so append
5647 // to the tokens variable.
5649 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5651 if (FirstToken == TRUE){
5653 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5658 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5668 intPropertyLen = PropertySeg2.Len();
5669 SplitPoints.clear();
5670 SplitLength.clear();
5675 for (int i = 0; i <= intPropertyLen; i++){
5679 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5682 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5684 if (intSplitsFound == 6){
5686 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5691 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5702 wxString wxSKeyMIME;
5703 wxString wxSKeyEncoding;
5704 wxString wxSKeyData;
5705 std::string base64enc;
5707 if (intSplitsFound == 0){
5711 std::map<int, int>::iterator striter;
5713 striter = SplitLength.find(1);
5715 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5717 while (wSTDataType.HasMoreTokens() == TRUE){
5719 wxSKeyURI = wSTDataType.GetNextToken();
5720 wxSKeyMIME = wSTDataType.GetNextToken();
5725 if (wxSKeyURI == wxT("data")){
5727 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5729 while (wSTDataInfo.HasMoreTokens() == TRUE){
5731 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5732 wxSKeyData = wSTDataInfo.GetNextToken();
5741 // Add the data to the General/Home/Work address variables.
5743 if (wxSKeyURI == wxT("data")){
5745 KeyListDataEncType.erase(*KeyCount);
5746 KeyListKeyType.erase(*KeyCount);
5747 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5748 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5750 KeyList.erase(*KeyCount);
5751 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5755 KeyList.erase(*KeyCount);
5756 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5760 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5766 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5769 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5773 if (!PropertyTokens.IsEmpty()){
5775 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5781 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5783 // Split the Vendor three ways.
5785 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5788 wxString wxSVNDPropName;
5791 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5793 wSTVendorDetails.GetNextToken();
5794 wxSVNDID = wSTVendorDetails.GetNextToken();
5795 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5800 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5802 // Add the data to the vendor variables.
5804 VendorList.erase(*VendorCount);
5805 VendorListPEN.erase(*VendorCount);
5806 VendorListElement.erase(*VendorCount);
5808 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5809 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5810 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5816 void ProcessIntegerValue(ContactDataObject *ContactData,
5817 std::map<int,int> *PrefPtr,
5818 wxString *PropertyValue,
5821 int PriorityNumber = 0;
5822 bool ValidNumber = TRUE;
5825 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5828 catch(std::invalid_argument &e){
5829 ValidNumber = FALSE;
5832 if (ValidNumber == TRUE){
5834 PrefPtr->erase(*ItemCount);
5835 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5841 void SplitValues(wxString *PropertyLine,
5842 std::map<int,int> *SplitPoints,
5843 std::map<int,int> *SplitLength,
5846 size_t intPropertyLen = PropertyLine->Len();
5847 int intSplitsFound = 0;
5848 int intSplitSize = 0;
5849 int intSplitSeek = 0;
5851 for (int i = intSize; i <= intPropertyLen; i++){
5855 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5856 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5858 if (intSplitsFound == 0){
5860 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5864 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5868 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5878 if (intSplitsFound == 0){
5880 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5881 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5885 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5886 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5892 void CheckType(wxString *PropertySeg1,
5893 std::map<int,int> *SplitPoints,
5894 std::map<int,int> *SplitLength,
5896 PropertyType *PropType){
5898 wxString PropertyData;
5899 wxString PropertyName;
5900 wxString PropertyValue;
5901 std::map<int,int>::iterator SLiter;
5903 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5904 intiter != SplitPoints->end(); ++intiter){
5906 SLiter = SplitLength->find(intiter->first);
5908 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5910 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5911 PropertyName = PropertyElement.GetNextToken();
5912 PropertyValue = PropertyElement.GetNextToken();
5914 *intPrevValue = intiter->second;
5916 if (PropertyName == wxT("TYPE")){
5918 if (PropertyValue == wxT("work")){
5920 *PropType = PROPERTY_WORK;
5922 } else if (PropertyValue == wxT("home")){
5924 *PropType = PROPERTY_HOME;
5928 *PropType = PROPERTY_NONE;