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 int ContactLineLen = 0;
83 int QuoteBreakPoint = 0;
86 int NicknameCount = 0;
87 int TimeZoneCount = 0;
91 int TelephoneCount = 0;
92 int LanguageCount = 0;
93 int GeographicCount = 0;
98 int OrganisationCount = 0;
100 int CategoryCount = 0;
104 int CalendarCount = 0;
105 int CalendarAddressCount = 0;
106 int FreeBusyAddressCount = 0;
110 wxString ContactLine;
111 wxString PropertyLine;
112 wxString PropertySeg1;
113 wxString PropertySeg2;
114 wxString PropertyNextLine;
117 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
118 iter != ContactFileLines.end(); ++iter){
120 ExtraLineSeek = TRUE;
126 PropertyLine.Clear();
127 PropertySeg1.Clear();
128 PropertySeg2.Clear();
131 ContactLine = iter->second;
133 while (ExtraLineSeek == TRUE){
135 // Check if there is extra data on the next line
136 // (indicated by space or tab at the start) and add data.
140 if (iter == ContactFileLines.end()){
147 PropertyNextLine = iter->second;
149 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
151 PropertyNextLine.Remove(0, 1);
152 ContactLine.Append(PropertyNextLine);
157 ExtraLineSeek = FALSE;
163 ContactLineLen = ContactLine.Len();
165 // Make sure we are not in quotation mode.
166 // Make sure colon does not have \ or \\ before it.
168 for (int i = 0; i <= ContactLineLen; i++){
170 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
172 PropertyFind = FALSE;
174 } else if (PropertyFind == TRUE){
176 Property.Append(ContactLine.Mid(i, 1));
180 if (ContactLine.Mid(i, 1) == wxT("\"")){
182 if (QuoteMode == TRUE){
194 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
203 // Split that line at the point into two variables (ignore the colon).
205 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
206 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
208 if (Property == wxT("KIND") && KindProcessed == FALSE){
210 ProcessKind(PropertySeg2);
212 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
214 UIDToken = PropertySeg2;
217 } else if (Property == wxT("MEMBER")){
219 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
222 } else if (Property == wxT("FN")){
224 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
227 } else if (Property == wxT("N") && NameProcessed == FALSE){
229 ProcessN(PropertySeg1, PropertySeg2);
230 NameProcessed = TRUE;
232 } else if (Property == wxT("NICKNAME")){
234 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
237 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
239 ProcessGender(PropertySeg1, PropertySeg2);
240 GenderProcessed = TRUE;
242 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
244 ProcessBirthday(PropertySeg1, PropertySeg2);
245 BirthdayProcessed = TRUE;
247 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
249 ProcessAnniversary(PropertySeg1, PropertySeg2);
250 AnniversaryProcessed = TRUE;
252 } else if (Property == wxT("TZ")){
254 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
257 } else if (Property == wxT("ADR")){
259 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
262 } else if (Property == wxT("EMAIL")){
264 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
267 } else if (Property == wxT("IMPP")){
269 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
272 } else if (Property == wxT("TEL")){
274 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
277 } else if (Property == wxT("LANG")){
279 // See frmContactEditor-LoadLanguage.cpp
281 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
284 } else if (Property == wxT("GEO")){
286 // See frmContactEditor-LoadGeo.cpp
288 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
291 } else if (Property == wxT("RELATED")){
293 // See fromContactEditor-LoadRelated.cpp
295 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
298 } else if (Property == wxT("URL")){
300 // See frmContactEditor-LoadURL.cpp
302 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
305 } else if (Property == wxT("TITLE")) {
307 // See frmContactEditor-LoadTitle.cpp
309 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
312 } else if (Property == wxT("ROLE")) {
314 // See frmContactEditor-LoadTitle.cpp
316 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
319 } else if (Property == wxT("ORG")) {
321 // See frmContactEditor-LoadOrg.cpp
323 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
326 } else if (Property == wxT("NOTE")) {
328 // See frmContactEditor-LoadNote.cpp
330 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
333 } else if (Property == wxT("CATEGORIES")) {
335 // See frmContactEditor-LoadCategory.cpp
337 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
340 } else if (Property == wxT("PHOTO")) {
342 // See frmContactEditor-LoadPhoto.cpp
344 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
347 } else if (Property == wxT("LOGO")) {
349 // See frmContactEditor-LoadPhoto.cpp
351 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
354 } else if (Property == wxT("LOGO")) {
356 // See frmContactEditor-LoadPhoto.cpp
358 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
361 } else if (Property == wxT("SOUND")) {
363 // See frmContactEditor-LoadSound.cpp
365 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
368 } else if (Property == wxT("CALURI")){
370 // See frmContactEditor-LoadCalendar.cpp
372 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
375 } else if (Property == wxT("CALADRURI")){
377 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
378 CalendarAddressCount++;
380 } else if (Property == wxT("FBURL")){
382 // See frmContactEditor-LoadCalendar.cpp
384 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
385 FreeBusyAddressCount++;
387 } else if (Property == wxT("KEY")){
389 // See frmContactEditor-LoadKey.cpp
391 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
394 } else if (Property.Mid(0, 3) == wxT("VND")){
396 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
399 } else if (Property.Mid(0, 2) == wxT("X-")){
401 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
402 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
409 return CONTACTLOAD_OK;
413 void ContactDataObject::ProcessKind(wxString KindType){
415 if (KindType == wxT("individual")){
417 ContactKind = CONTACTKIND_INDIVIDUAL;
419 } else if (KindType == wxT("group")){
421 ContactKind = CONTACTKIND_GROUP;
423 } else if (KindType == wxT("org")){
425 ContactKind = CONTACTKIND_ORGANISATION;
427 } else if (KindType == wxT("location")){
429 ContactKind = CONTACTKIND_LOCATION;
433 ContactKind = CONTACTKIND_NONE;
438 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
440 std::map<int, int> SplitPoints;
441 std::map<int, int> SplitLength;
443 int intPrevValue = 8;
447 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
451 wxString PropertyName;
452 wxString PropertyValue;
453 wxString PropertyData;
454 wxString PropertyTokens;
455 std::map<int,int>::iterator SLiter;
456 bool FirstToken = TRUE;
458 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
459 intiter != SplitPoints.end(); ++intiter){
461 SLiter = SplitLength.find(intiter->first);
463 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
465 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
466 PropertyName = PropertyElement.GetNextToken();
467 PropertyValue = PropertyElement.GetNextToken();
469 intPrevValue = intiter->second;
471 CaptureString(&PropertyValue, FALSE);
473 if (PropertyName == wxT("ALTID")){
475 GroupsListAltID.erase(*GroupCount);
476 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
478 } else if (PropertyName == wxT("PID")){
480 GroupsListPID.erase(*GroupCount);
481 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
483 } else if (PropertyName == wxT("PREF")){
485 int PriorityNumber = 0;
486 bool ValidNumber = TRUE;
489 PriorityNumber = std::stoi(PropertyValue.ToStdString());
492 catch(std::invalid_argument &e){
496 if (ValidNumber == TRUE){
498 GroupsListPref.erase(*GroupCount);
499 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
503 } else if (PropertyName == wxT("MEDIATYPE")){
505 GroupsListMediaType.erase(*GroupCount);
506 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
508 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
510 if (FirstToken == TRUE){
512 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
517 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
525 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
527 if (!PropertyTokens.IsEmpty()){
529 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
536 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
538 std::map<int, int> SplitPoints;
539 std::map<int, int> SplitLength;
541 int intPrevValue = 4;
545 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
549 wxString PropertyName;
550 wxString PropertyValue;
551 wxString PropertyData;
552 wxString PropertyTokens;
553 std::map<int,int>::iterator SLiter;
554 bool FirstToken = TRUE;
556 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
557 intiter != SplitPoints.end(); ++intiter){
559 SLiter = SplitLength.find(intiter->first);
561 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
563 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
564 PropertyName = PropertyElement.GetNextToken();
565 PropertyValue = PropertyElement.GetNextToken();
567 intPrevValue = intiter->second;
569 CaptureString(&PropertyValue, FALSE);
571 if (PropertyName == wxT("TYPE")){
573 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
574 PropertyValue == wxT("work") ){
576 FullNamesListType.erase(*FNCount);
577 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
581 } else if (PropertyName == wxT("LANGUAGE")){
583 FullNamesListLanguage.erase(*FNCount);
584 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
586 } else if (PropertyName == wxT("ALTID")){
588 FullNamesListAltID.erase(*FNCount);
589 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
591 } else if (PropertyName == wxT("PID")){
593 FullNamesListPID.erase(*FNCount);
594 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
596 } else if (PropertyName == wxT("PREF")){
598 int PriorityNumber = 0;
599 bool ValidNumber = TRUE;
602 PriorityNumber = std::stoi(PropertyValue.ToStdString());
605 catch(std::invalid_argument &e){
609 if (ValidNumber == TRUE){
611 FullNamesListPref.erase(*FNCount);
612 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
616 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
618 if (FirstToken == TRUE){
620 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
625 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
633 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
635 if (!PropertyTokens.IsEmpty()){
637 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
643 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
645 std::map<int, int> SplitPoints;
646 std::map<int, int> SplitLength;
648 int intPrevValue = 3;
652 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
656 wxString PropertyName;
657 wxString PropertyValue;
658 wxString PropertyData;
659 wxString PropertyTokens;
660 std::map<int,int>::iterator SLiter;
661 bool FirstToken = TRUE;
663 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
664 intiter != SplitPoints.end(); ++intiter){
666 SLiter = SplitLength.find(intiter->first);
668 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
670 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
671 PropertyName = PropertyElement.GetNextToken();
672 PropertyValue = PropertyElement.GetNextToken();
674 intPrevValue = intiter->second;
676 CaptureString(&PropertyValue, FALSE);
678 if (PropertyName == wxT("ALTID")){
680 NameAltID = PropertyValue;
682 } else if (PropertyName == wxT("LANGUAGE")){
684 NameLanguage = PropertyValue;
686 } else if (PropertyName == wxT("SORT-AS")){
688 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
689 PropertyValue.Len() >= 3){
690 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
693 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
695 if (FirstToken == TRUE){
697 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
702 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
710 // Split the name data.
712 int intSplitSeek = 0;
713 int intSplitsFound = 0;
714 int intSplitSize = 0;
715 int intPropertyLen = PropertySeg2.Len();
717 std::map<int,wxString> NameValues;
720 for (int i = 0; i <= intPropertyLen; i++){
722 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
724 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
729 if (intSplitsFound == 4){
731 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
745 // Split the data into several parts.
747 for (std::map<int, wxString>::iterator iter = NameValues.begin();
748 iter != NameValues.end(); ++iter){
750 if (iter->first == 1){
752 // Deal with family name.
754 NameSurname = iter->second;
756 } else if (iter->first == 2){
758 // Deal with given names.
760 NameForename = iter->second;
762 } else if (iter->first == 3){
764 // Deal with additional names.
766 NameOtherNames = iter->second;
768 } else if (iter->first == 4){
770 // Deal with honorifix prefixes and suffixes.
772 NameTitle = iter->second;
776 if (iter == NameValues.end()){
782 NameSuffix = iter->second;
788 // Add the name token data.
790 if (!PropertyTokens.IsEmpty()){
792 NameTokens = PropertyTokens;
798 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
800 std::map<int, int> SplitPoints;
801 std::map<int, int> SplitLength;
803 int intPrevValue = 10;
806 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
810 PropertyType PropType = PROPERTY_NONE;
812 // Look for type before continuing.
814 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
818 std::map<int, wxString> *NicknamesList = NULL;
819 std::map<int, wxString> *NicknamesListType = NULL;
820 std::map<int, wxString> *NicknamesListLanguage = NULL;
821 std::map<int, wxString> *NicknamesListAltID = NULL;
822 std::map<int, wxString> *NicknamesListPID = NULL;
823 std::map<int, wxString> *NicknamesListTokens = NULL;
824 std::map<int, int> *NicknamesListPref = NULL;
828 NicknamesList = &GeneralNicknamesList;
829 NicknamesListType = &GeneralNicknamesListType;
830 NicknamesListLanguage = &GeneralNicknamesListLanguage;
831 NicknamesListAltID = &GeneralNicknamesListAltID;
832 NicknamesListPID = &GeneralNicknamesListPID;
833 NicknamesListTokens = &GeneralNicknamesListTokens;
834 NicknamesListPref = &GeneralNicknamesListPref;
837 NicknamesList = &HomeNicknamesList;
838 NicknamesListType = &HomeNicknamesListType;
839 NicknamesListLanguage = &HomeNicknamesListLanguage;
840 NicknamesListAltID = &HomeNicknamesListAltID;
841 NicknamesListPID = &HomeNicknamesListPID;
842 NicknamesListTokens = &HomeNicknamesListTokens;
843 NicknamesListPref = &HomeNicknamesListPref;
846 NicknamesList = &BusinessNicknamesList;
847 NicknamesListType = &BusinessNicknamesListType;
848 NicknamesListLanguage = &BusinessNicknamesListLanguage;
849 NicknamesListAltID = &BusinessNicknamesListAltID;
850 NicknamesListPID = &BusinessNicknamesListPID;
851 NicknamesListTokens = &BusinessNicknamesListTokens;
852 NicknamesListPref = &BusinessNicknamesListPref;
856 std::map<int, int>::iterator SLiter;
857 wxString PropertyData;
858 wxString PropertyName;
859 wxString PropertyValue;
860 wxString PropertyTokens;
861 bool FirstToken = TRUE;
863 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
864 intiter != SplitPoints.end(); ++intiter){
866 SLiter = SplitLength.find(intiter->first);
868 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
870 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
871 PropertyName = PropertyElement.GetNextToken();
872 PropertyValue = PropertyElement.GetNextToken();
874 intPrevValue = intiter->second;
876 CaptureString(&PropertyValue, FALSE);
878 if (PropertyName == wxT("ALTID")){
880 NicknamesListAltID->erase(*NicknameCount);
881 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
883 } else if (PropertyName == wxT("PID")){
885 NicknamesListPID->erase(*NicknameCount);
886 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
888 } else if (PropertyName == wxT("PREF")){
890 int PriorityNumber = 0;
891 bool ValidNumber = TRUE;
894 PriorityNumber = std::stoi(PropertyValue.ToStdString());
897 catch(std::invalid_argument &e){
901 if (ValidNumber == TRUE){
903 NicknamesListPref->erase(*NicknameCount);
904 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
908 } else if (PropertyName == wxT("LANGUAGE")){
910 NicknamesListLanguage->erase(*NicknameCount);
911 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
915 // Something else we don't know about so append
916 // to the tokens variable.
918 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
920 if (FirstToken == TRUE){
922 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
927 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
937 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
939 // Add the name token data.
941 if (!PropertyTokens.IsEmpty()){
943 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
949 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
951 std::map<int, int> SplitPoints;
952 std::map<int, int> SplitLength;
953 std::map<int, int>::iterator SLiter;
954 wxString PropertyData;
955 wxString PropertyName;
956 wxString PropertyValue;
957 wxString PropertyTokens;
958 bool FirstToken = TRUE;
959 int intPrevValue = 8;
961 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
965 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
966 intiter != SplitPoints.end(); ++intiter){
968 SLiter = SplitLength.find(intiter->first);
970 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
972 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
973 PropertyName = PropertyElement.GetNextToken();
974 PropertyValue = PropertyElement.GetNextToken();
976 intPrevValue = intiter->second;
978 // Process properties.
980 size_t intPropertyValueLen = PropertyValue.Len();
982 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
984 PropertyValue.Trim();
985 PropertyValue.RemoveLast();
989 if (PropertyValue.Mid(0, 1) == wxT("\"")){
991 PropertyValue.Remove(0, 1);
995 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
997 if (FirstToken == TRUE){
999 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1004 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1012 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1014 wxString GenderComponent;
1016 if (GenderData.CountTokens() >= 2){
1018 Gender = GenderData.GetNextToken();
1019 GenderDetails = GenderData.GetString();
1021 CaptureString(&GenderDetails, FALSE);
1025 Gender = GenderData.GetNextToken();
1029 if (!PropertyTokens.IsEmpty()){
1031 GenderTokens = PropertyTokens;
1037 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1039 // Process date. Preserve the remainder in the string.
1041 std::map<int, int> SplitPoints;
1042 std::map<int, int> SplitLength;
1043 std::map<int, int>::iterator SLiter;
1044 wxString PropertyData;
1045 wxString PropertyName;
1046 wxString PropertyValue;
1047 wxString PropertyTokens;
1048 bool BirthdayText = FALSE;
1049 int intPrevValue = 6;
1051 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1055 // Look for type before continuing.
1057 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1058 intiter != SplitPoints.end(); ++intiter){
1060 SLiter = SplitLength.find(intiter->first);
1062 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1064 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1065 PropertyName = PropertyElement.GetNextToken();
1066 PropertyValue = PropertyElement.GetNextToken();
1068 intPrevValue = intiter->second;
1070 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1072 CaptureString(&PropertySeg2, FALSE);
1073 Birthday = PropertySeg2;
1074 BirthdayText = TRUE;
1080 // Setup blank lines for later on.
1083 bool FirstToken = TRUE;
1085 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1086 intiter != SplitPoints.end(); ++intiter){
1088 SLiter = SplitLength.find(intiter->first);
1090 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1092 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1093 PropertyName = PropertyElement.GetNextToken();
1094 PropertyValue = PropertyElement.GetNextToken();
1096 intPrevValue = intiter->second;
1098 // Process properties.
1100 CaptureString(&PropertyValue, FALSE);
1102 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1104 PropertyValue.Trim();
1105 PropertyValue.RemoveLast();
1109 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1111 PropertyValue.Remove(0, 1);
1115 if (PropertyName == wxT("ALTID")){
1117 BirthdayAltID = PropertyValue;
1119 } else if (PropertyName == wxT("CALSCALE")){
1121 BirthdayCalScale = PropertyValue;
1123 } else if (PropertyName != wxT("VALUE")) {
1125 // Something else we don't know about so append
1126 // to the tokens variable.
1128 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1130 if (FirstToken == TRUE){
1132 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1137 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1147 // Add the data to the variables and form.
1149 if (BirthdayText == FALSE){
1151 Birthday = PropertySeg2;
1155 if (!PropertyTokens.IsEmpty()){
1157 BirthdayTokens = PropertyTokens;
1163 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1165 // Process date. Preserve the remainder in the string.
1167 std::map<int, int> SplitPoints;
1168 std::map<int, int> SplitLength;
1169 std::map<int, int>::iterator SLiter;
1170 wxString PropertyData;
1171 wxString PropertyName;
1172 wxString PropertyValue;
1173 wxString PropertyTokens;
1174 bool AnniversaryText = FALSE;
1175 int intPrevValue = 13;
1177 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1181 // Look for type before continuing.
1183 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1184 intiter != SplitPoints.end(); ++intiter){
1186 SLiter = SplitLength.find(intiter->first);
1188 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1190 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1191 PropertyName = PropertyElement.GetNextToken();
1192 PropertyValue = PropertyElement.GetNextToken();
1194 intPrevValue = intiter->second;
1196 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1198 CaptureString(&PropertySeg2, FALSE);
1199 Anniversary = PropertySeg2;
1200 AnniversaryText = TRUE;
1206 // Setup blank lines for later on.
1209 bool FirstToken = TRUE;
1211 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1212 intiter != SplitPoints.end(); ++intiter){
1214 SLiter = SplitLength.find(intiter->first);
1216 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1218 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1219 PropertyName = PropertyElement.GetNextToken();
1220 PropertyValue = PropertyElement.GetNextToken();
1222 intPrevValue = intiter->second;
1224 // Process properties.
1226 CaptureString(&PropertyValue, FALSE);
1228 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1230 PropertyValue.Trim();
1231 PropertyValue.RemoveLast();
1235 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1237 PropertyValue.Remove(0, 1);
1241 if (PropertyName == wxT("ALTID")){
1243 AnniversaryAltID = PropertyValue;
1245 } else if (PropertyName == wxT("CALSCALE")){
1247 AnniversaryCalScale = PropertyValue;
1249 } else if (PropertyName != wxT("VALUE")) {
1251 // Something else we don't know about so append
1252 // to the tokens variable.
1254 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1256 if (FirstToken == TRUE){
1258 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1263 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1273 // Add the data to the variables and form.
1275 if (AnniversaryText == FALSE){
1277 Anniversary = PropertySeg2;
1281 if (!PropertyTokens.IsEmpty()){
1283 AnniversaryTokens = PropertyTokens;
1289 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1291 std::map<int, int> SplitPoints;
1292 std::map<int, int> SplitLength;
1294 int intPrevValue = 4;
1297 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1301 PropertyType PropType = PROPERTY_NONE;
1303 // Look for type before continuing.
1305 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1309 std::map<int, wxString> *TZList = NULL;
1310 std::map<int, wxString> *TZListType = NULL;
1311 std::map<int, wxString> *TZListMediatype = NULL;
1312 std::map<int, wxString> *TZListAltID = NULL;
1313 std::map<int, wxString> *TZListPID = NULL;
1314 std::map<int, wxString> *TZListTokens = NULL;
1315 std::map<int, int> *TZListPref = NULL;
1319 TZList = &GeneralTZList;
1320 TZListType = &GeneralTZListType;
1321 TZListMediatype = &GeneralTZListMediatype;
1322 TZListAltID = &GeneralTZListAltID;
1323 TZListPID = &GeneralTZListPID;
1324 TZListTokens = &GeneralTZListTokens;
1325 TZListPref = &GeneralTZListPref;
1328 TZList = &HomeTZList;
1329 TZListType = &HomeTZListType;
1330 TZListMediatype = &HomeTZListMediatype;
1331 TZListAltID = &HomeTZListAltID;
1332 TZListPID = &HomeTZListPID;
1333 TZListTokens = &HomeTZListTokens;
1334 TZListPref = &HomeTZListPref;
1337 TZList = &BusinessTZList;
1338 TZListType = &BusinessTZListType;
1339 TZListMediatype = &BusinessTZListMediatype;
1340 TZListAltID = &BusinessTZListAltID;
1341 TZListPID = &BusinessTZListPID;
1342 TZListTokens = &BusinessTZListTokens;
1343 TZListPref = &BusinessTZListPref;
1347 std::map<int, int>::iterator SLiter;
1348 wxString PropertyData;
1349 wxString PropertyName;
1350 wxString PropertyValue;
1351 wxString PropertyTokens;
1352 bool FirstToken = TRUE;
1354 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1355 intiter != SplitPoints.end(); ++intiter){
1357 SLiter = SplitLength.find(intiter->first);
1359 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1361 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1362 PropertyName = PropertyElement.GetNextToken();
1363 PropertyValue = PropertyElement.GetNextToken();
1365 intPrevValue = intiter->second;
1367 CaptureString(&PropertyValue, FALSE);
1369 if (PropertyName == wxT("ALTID")){
1371 TZListAltID->erase(*TimeZoneCount);
1372 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1374 } else if (PropertyName == wxT("PID")){
1376 TZListPID->erase(*TimeZoneCount);
1377 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1379 } else if (PropertyName == wxT("PREF")){
1381 int PriorityNumber = 0;
1382 bool ValidNumber = TRUE;
1385 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1388 catch(std::invalid_argument &e){
1389 ValidNumber = FALSE;
1392 if (ValidNumber == TRUE){
1394 TZListPref->erase(*TimeZoneCount);
1395 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1399 } else if (PropertyName == wxT("MEDIATYPE")){
1401 TZListMediatype->erase(*TimeZoneCount);
1402 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1406 // Something else we don't know about so append
1407 // to the tokens variable.
1409 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1411 if (FirstToken == TRUE){
1413 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1418 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1428 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1430 // Add the name token data.
1432 if (!PropertyTokens.IsEmpty()){
1434 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1441 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1443 size_t intPropertyLen = PropertySeg1.Len();
1444 std::map<int, int> SplitPoints;
1445 std::map<int, int> SplitLength;
1446 std::map<int, int>::iterator SLiter;
1447 wxString PropertyData;
1448 wxString PropertyName;
1449 wxString PropertyValue;
1450 wxString PropertyTokens;
1451 wxString AddressLabel;
1452 wxString AddressLang;
1453 wxString AddressAltID;
1454 wxString AddressPID;
1455 wxString AddressTokens;
1456 wxString AddressGeo;
1457 wxString AddressTimezone;
1458 wxString AddressType;
1459 wxString AddressMediatype;
1460 wxString AddressPOBox;
1461 wxString AddressExtended;
1462 wxString AddressStreet;
1463 wxString AddressLocality;
1464 wxString AddressCity;
1465 wxString AddressRegion;
1466 wxString AddressPostalCode;
1467 wxString AddressCountry;
1468 bool FirstToken = TRUE;
1469 int intSplitsFound = 0;
1470 int intSplitSize = 0;
1471 int intPrevValue = 5;
1476 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1480 PropertyType PropType = PROPERTY_NONE;
1482 // Look for type before continuing.
1484 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1488 std::map<int, wxString> *AddressList = NULL;
1489 std::map<int, wxString> *AddressListTown = NULL;
1490 std::map<int, wxString> *AddressListCounty = NULL;
1491 std::map<int, wxString> *AddressListPostCode = NULL;
1492 std::map<int, wxString> *AddressListCountry = NULL;
1493 std::map<int, wxString> *AddressListLabel = NULL;
1494 std::map<int, wxString> *AddressListLang = NULL;
1495 std::map<int, wxString> *AddressListAltID = NULL;
1496 std::map<int, wxString> *AddressListPID = NULL;
1497 std::map<int, wxString> *AddressListTokens = NULL;
1498 std::map<int, wxString> *AddressListGeo = NULL;
1499 std::map<int, wxString> *AddressListTimezone = NULL;
1500 std::map<int, wxString> *AddressListType = NULL;
1501 std::map<int, wxString> *AddressListMediatype = NULL;
1502 std::map<int, int> *AddressListPref = NULL;
1506 AddressList = &GeneralAddressList;
1507 AddressListTown = &GeneralAddressListTown;
1508 AddressListCounty = &GeneralAddressListCounty;
1509 AddressListPostCode = &GeneralAddressListPostCode;
1510 AddressListCountry = &GeneralAddressListCountry;
1511 AddressListLabel = &GeneralAddressListLabel;
1512 AddressListLang = &GeneralAddressListLang;
1513 AddressListAltID = &GeneralAddressListAltID;
1514 AddressListPID = &GeneralAddressListPID;
1515 AddressListTokens = &GeneralAddressListTokens;
1516 AddressListGeo = &GeneralAddressListGeo;
1517 AddressListTimezone = &GeneralAddressListTimezone;
1518 AddressListType = &GeneralAddressListType;
1519 AddressListMediatype = &GeneralAddressListMediatype;
1520 AddressListPref = &GeneralAddressListPref;
1523 AddressList = &HomeAddressList;
1524 AddressListTown = &HomeAddressListTown;
1525 AddressListCounty = &HomeAddressListCounty;
1526 AddressListPostCode = &HomeAddressListPostCode;
1527 AddressListCountry = &HomeAddressListCountry;
1528 AddressListLabel = &HomeAddressListLabel;
1529 AddressListLang = &HomeAddressListLang;
1530 AddressListAltID = &HomeAddressListAltID;
1531 AddressListPID = &HomeAddressListPID;
1532 AddressListTokens = &HomeAddressListTokens;
1533 AddressListGeo = &HomeAddressListGeo;
1534 AddressListTimezone = &HomeAddressListTimezone;
1535 AddressListType = &HomeAddressListType;
1536 AddressListMediatype = &HomeAddressListMediatype;
1537 AddressListPref = &HomeAddressListPref;
1540 AddressList = &BusinessAddressList;
1541 AddressListTown = &BusinessAddressListTown;
1542 AddressListCounty = &BusinessAddressListCounty;
1543 AddressListPostCode = &BusinessAddressListPostCode;
1544 AddressListCountry = &BusinessAddressListCountry;
1545 AddressListLabel = &BusinessAddressListLabel;
1546 AddressListLang = &BusinessAddressListLang;
1547 AddressListAltID = &BusinessAddressListAltID;
1548 AddressListPID = &BusinessAddressListPID;
1549 AddressListTokens = &BusinessAddressListTokens;
1550 AddressListGeo = &BusinessAddressListGeo;
1551 AddressListTimezone = &BusinessAddressListTimezone;
1552 AddressListType = &BusinessAddressListType;
1553 AddressListMediatype = &BusinessAddressListMediatype;
1554 AddressListPref = &BusinessAddressListPref;
1560 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1561 intiter != SplitPoints.end(); ++intiter){
1563 SLiter = SplitLength.find(intiter->first);
1565 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1567 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1568 PropertyName = PropertyElement.GetNextToken();
1569 PropertyValue = PropertyElement.GetNextToken();
1571 intPrevValue = intiter->second;
1573 CaptureString(&PropertyValue, FALSE);
1575 // Process properties.
1577 if (PropertyName == wxT("LABEL")){
1579 AddressListLabel->erase(*AddressCount);
1580 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1582 } else if (PropertyName == wxT("LANGUAGE")){
1584 AddressListLang->erase(*AddressCount);
1585 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1587 } else if (PropertyName == wxT("ALTID")){
1589 AddressListAltID->erase(*AddressCount);
1590 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1592 } else if (PropertyName == wxT("PID")){
1594 AddressListPID->erase(*AddressCount);
1595 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1597 } else if (PropertyName == wxT("GEO")){
1599 AddressListGeo->erase(*AddressCount);
1600 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1602 } else if (PropertyName == wxT("TZ")){
1604 AddressListTimezone->erase(*AddressCount);
1605 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1607 } else if (PropertyName == wxT("MEDIATYPE")){
1609 AddressListMediatype->erase(*AddressCount);
1610 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1612 } else if (PropertyName == wxT("PREF")){
1614 int PriorityNumber = 0;
1615 bool ValidNumber = TRUE;
1618 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1621 catch(std::invalid_argument &e){
1622 ValidNumber = FALSE;
1625 if (ValidNumber == TRUE){
1627 AddressListPref->erase(*AddressCount);
1628 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1634 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1636 if (FirstToken == TRUE){
1638 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1643 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1653 // Split the address.
1655 //std::map<int, int>::iterator SLiter;
1656 intPropertyLen = PropertySeg2.Len();
1657 SplitPoints.clear();
1658 SplitLength.clear();
1663 for (int i = 0; i <= intPropertyLen; i++){
1667 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1670 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1672 if (intSplitsFound == 6){
1674 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1679 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1689 // Split the data into several parts.
1691 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1692 intiter != SplitPoints.end(); ++intiter){
1694 if (intiter->first == 1){
1696 // Deal with PO Box.
1698 SLiter = SplitLength.find(1);
1700 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1701 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1702 intPrevValue = intiter->second;
1704 } else if (intiter->first == 2){
1706 // Deal with extended address.
1708 SLiter = SplitLength.find(2);
1710 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1711 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1712 intPrevValue = intiter->second;
1714 } else if (intiter->first == 3){
1716 // Deal with street address.
1718 SLiter = SplitLength.find(3);
1720 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1721 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1722 intPrevValue = intiter->second;
1724 } else if (intiter->first == 4){
1726 // Deal with locality
1728 SLiter = SplitLength.find(4);
1730 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1731 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1732 intPrevValue = intiter->second;
1734 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1736 } else if (intiter->first == 5){
1738 // Deal with region.
1740 SLiter = SplitLength.find(5);
1742 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1743 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1744 intPrevValue = intiter->second;
1746 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1748 } else if (intiter->first == 6){
1750 // Deal with post code.
1752 SLiter = SplitLength.find(6);
1754 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1755 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1756 intPrevValue = intiter->second;
1758 // Deal with country.
1760 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1761 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1769 // Add the data to the General/Home/Work address variables.
1771 CaptureString(&AddressStreet, FALSE);
1772 CaptureString(&AddressLocality, FALSE);
1773 CaptureString(&AddressRegion, FALSE);
1774 CaptureString(&AddressPostalCode, FALSE);
1775 CaptureString(&AddressCountry, FALSE);
1777 if (!PropertyTokens.IsEmpty()){
1779 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1783 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1784 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1785 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1786 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1787 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1791 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1794 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1797 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1801 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1805 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1807 std::map<int, int> SplitPoints;
1808 std::map<int, int> SplitLength;
1810 int intPrevValue = 7;
1813 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1817 PropertyType PropType = PROPERTY_NONE;
1819 // Look for type before continuing.
1821 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1823 std::map<int, wxString> *EmailList = NULL;
1824 std::map<int, wxString> *EmailListType = NULL;
1825 std::map<int, wxString> *EmailListAltID = NULL;
1826 std::map<int, wxString> *EmailListPID = NULL;
1827 std::map<int, wxString> *EmailListTokens = NULL;
1828 std::map<int, int> *EmailListPref = NULL;
1832 EmailList = &GeneralEmailList;
1833 EmailListType = &GeneralEmailListType;
1834 EmailListAltID = &GeneralEmailListAltID;
1835 EmailListPID = &GeneralEmailListPID;
1836 EmailListTokens = &GeneralEmailListTokens;
1837 EmailListPref = &GeneralEmailListPref;
1840 EmailList = &HomeEmailList;
1841 EmailListType = &HomeEmailListType;
1842 EmailListAltID = &HomeEmailListAltID;
1843 EmailListPID = &HomeEmailListPID;
1844 EmailListTokens = &HomeEmailListTokens;
1845 EmailListPref = &HomeEmailListPref;
1848 EmailList = &BusinessEmailList;
1849 EmailListType = &BusinessEmailListType;
1850 EmailListAltID = &BusinessEmailListAltID;
1851 EmailListPID = &BusinessEmailListPID;
1852 EmailListTokens = &BusinessEmailListTokens;
1853 EmailListPref = &BusinessEmailListPref;
1859 std::map<int,int>::iterator SLiter;
1860 wxString PropertyData;
1861 wxString PropertyName;
1862 wxString PropertyValue;
1863 wxString PropertyTokens;
1864 bool FirstToken = TRUE;
1866 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1867 intiter != SplitPoints.end(); ++intiter){
1869 SLiter = SplitLength.find(intiter->first);
1871 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1873 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1874 PropertyName = PropertyElement.GetNextToken();
1875 PropertyValue = PropertyElement.GetNextToken();
1877 intPrevValue = intiter->second;
1879 CaptureString(&PropertyValue, FALSE);
1881 // Process properties.
1883 if (PropertyName == wxT("ALTID")){
1885 EmailListAltID->erase(*EmailCount);
1886 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1888 } else if (PropertyName == wxT("PID")){
1890 EmailListPID->erase(*EmailCount);
1891 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1893 } else if (PropertyName == wxT("PREF")){
1895 int PriorityNumber = 0;
1896 bool ValidNumber = TRUE;
1899 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1902 catch(std::invalid_argument &e){
1903 ValidNumber = FALSE;
1906 if (ValidNumber == TRUE){
1908 EmailListPref->erase(*EmailCount);
1909 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1915 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1917 if (FirstToken == TRUE){
1919 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1924 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1934 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1936 // Add the name token data.
1938 if (!PropertyTokens.IsEmpty()){
1940 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1947 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1949 std::map<int, int> SplitPoints;
1950 std::map<int, int> SplitLength;
1952 int intPrevValue = 6;
1955 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1959 PropertyType PropType = PROPERTY_NONE;
1961 // Look for type before continuing.
1963 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1965 std::map<int, wxString> *IMList = NULL;
1966 std::map<int, wxString> *IMListType = NULL;
1967 std::map<int, wxString> *IMListAltID = NULL;
1968 std::map<int, wxString> *IMListPID = NULL;
1969 std::map<int, wxString> *IMListTokens = NULL;
1970 std::map<int, wxString> *IMListMediatype = NULL;
1971 std::map<int, int> *IMListPref = NULL;
1975 IMList = &GeneralIMList;
1976 IMListType = &GeneralIMListType;
1977 IMListAltID = &GeneralIMListAltID;
1978 IMListPID = &GeneralIMListPID;
1979 IMListTokens = &GeneralIMListTokens;
1980 IMListMediatype = &GeneralIMListMediatype;
1981 IMListPref = &GeneralIMListPref;
1984 IMList = &HomeIMList;
1985 IMListType = &HomeIMListType;
1986 IMListAltID = &HomeIMListAltID;
1987 IMListPID = &HomeIMListPID;
1988 IMListTokens = &HomeIMListTokens;
1989 IMListMediatype = &HomeIMListMediatype;
1990 IMListPref = &HomeIMListPref;
1993 IMList = &BusinessIMList;
1994 IMListType = &BusinessIMListType;
1995 IMListAltID = &BusinessIMListAltID;
1996 IMListPID = &BusinessIMListPID;
1997 IMListTokens = &BusinessIMListTokens;
1998 IMListMediatype = &BusinessIMListMediatype;
1999 IMListPref = &BusinessIMListPref;
2005 std::map<int,int>::iterator SLiter;
2006 wxString PropertyData;
2007 wxString PropertyName;
2008 wxString PropertyValue;
2009 wxString PropertyTokens;
2010 bool FirstToken = TRUE;
2012 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2013 intiter != SplitPoints.end(); ++intiter){
2015 SLiter = SplitLength.find(intiter->first);
2017 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2019 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2020 PropertyName = PropertyElement.GetNextToken();
2021 PropertyValue = PropertyElement.GetNextToken();
2023 intPrevValue = intiter->second;
2025 CaptureString(&PropertyValue, FALSE);
2027 // Process properties.
2029 if (PropertyName == wxT("ALTID")){
2031 IMListAltID->erase(*IMCount);
2032 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2034 } else if (PropertyName == wxT("PID")){
2036 IMListPID->erase(*IMCount);
2037 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2039 } else if (PropertyName == wxT("MEDIATYPE")){
2041 IMListMediatype->erase(*IMCount);
2042 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2044 } else if (PropertyName == wxT("PREF")){
2046 int PriorityNumber = 0;
2047 bool ValidNumber = TRUE;
2050 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2053 catch(std::invalid_argument &e){
2054 ValidNumber = FALSE;
2057 if (ValidNumber == TRUE){
2059 IMListPref->erase(*IMCount);
2060 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2066 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2068 if (FirstToken == TRUE){
2070 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2075 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2085 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2087 // Add the name token data.
2089 if (!PropertyTokens.IsEmpty()){
2091 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2097 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2099 std::map<int, int> SplitPoints;
2100 std::map<int, int> SplitLength;
2101 std::map<int, int>::iterator SLiter;
2105 PropertyType PropType = PROPERTY_NONE;
2107 // Look for type before continuing.
2110 wxString TelTypeDetail;
2111 wxString PropertyData;
2112 wxString PropertyName;
2113 wxString PropertyValue;
2114 wxString PropertyTokens;
2116 std::map<int,int> TypeSplitPoints;
2117 std::map<int,int> TypeSplitLength;
2118 std::map<int,int>::iterator TSLiter;
2120 int intSplitSize = 0;
2121 int intSplitsFound = 0;
2122 int intSplitPoint = 0;
2124 int intPrevValue = 5;
2126 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2130 // Look for type before continuing.
2132 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2133 intiter != SplitPoints.end(); ++intiter){
2135 SLiter = SplitLength.find(intiter->first);
2137 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2139 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2140 PropertyName = PropertyElement.GetNextToken();
2141 PropertyValue = PropertyElement.GetNextToken();
2143 intPrevValue = intiter->second;
2145 if (PropertyName == wxT("TYPE")){
2147 // Process each value in type and translate each
2150 // Strip out the quotes if they are there.
2152 size_t intPropertyValueLen = PropertyValue.Len();
2154 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2156 PropertyValue.Trim();
2157 PropertyValue.RemoveLast();
2161 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2163 PropertyValue.Remove(0, 1);
2167 TelTypeDetail = PropertyValue;
2173 for (int i = 0; i <= intPropertyValueLen; i++){
2177 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2179 if (intSplitsFound == 0){
2181 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2182 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2186 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2187 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2200 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2201 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2203 int intTypeSeek = 0;
2205 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2206 typeiter != TypeSplitPoints.end(); ++typeiter){
2208 wxString TypePropertyName;
2210 TSLiter = TypeSplitLength.find(typeiter->first);
2212 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2214 if (intTypeSeek == 0){
2219 TelTypeUI.Append(wxT(","));
2223 if (TypePropertyName == wxT("home")){
2225 PropType = PROPERTY_HOME;
2227 } else if (TypePropertyName == wxT("work")){
2229 PropType = PROPERTY_WORK;
2234 if (TypePropertyName == wxT("text")){
2236 TelTypeUI.Append(_("text"));
2239 } else if (TypePropertyName == wxT("voice")){
2241 TelTypeUI.Append(_("voice"));
2244 } else if (TypePropertyName == wxT("fax")){
2246 TelTypeUI.Append(_("fax"));
2249 } else if (TypePropertyName == wxT("cell")){
2251 TelTypeUI.Append(_("mobile"));
2254 } else if (TypePropertyName == wxT("video")){
2256 TelTypeUI.Append(_("video"));
2259 } else if (TypePropertyName == wxT("pager")){
2261 TelTypeUI.Append(_("pager"));
2264 } else if (TypePropertyName == wxT("textphone")){
2266 TelTypeUI.Append(_("textphone"));
2277 std::map<int, wxString> *TelephoneList = NULL;
2278 std::map<int, wxString> *TelephoneListType = NULL;
2279 std::map<int, wxString> *TelephoneListAltID = NULL;
2280 std::map<int, wxString> *TelephoneListPID = NULL;
2281 std::map<int, wxString> *TelephoneListTokens = NULL;
2282 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2283 std::map<int, int> *TelephoneListPref = NULL;
2287 TelephoneList = &GeneralTelephoneList;
2288 TelephoneListType = &GeneralTelephoneListType;
2289 TelephoneListAltID = &GeneralTelephoneListAltID;
2290 TelephoneListPID = &GeneralTelephoneListPID;
2291 TelephoneListTokens = &GeneralTelephoneListTokens;
2292 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2293 TelephoneListPref = &GeneralTelephoneListPref;
2296 TelephoneList = &HomeTelephoneList;
2297 TelephoneListType = &HomeTelephoneListType;
2298 TelephoneListAltID = &HomeTelephoneListAltID;
2299 TelephoneListPID = &HomeTelephoneListPID;
2300 TelephoneListTokens = &HomeTelephoneListTokens;
2301 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2302 TelephoneListPref = &HomeTelephoneListPref;
2305 TelephoneList = &BusinessTelephoneList;
2306 TelephoneListType = &BusinessTelephoneListType;
2307 TelephoneListAltID = &BusinessTelephoneListAltID;
2308 TelephoneListPID = &BusinessTelephoneListPID;
2309 TelephoneListTokens = &BusinessTelephoneListTokens;
2310 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2311 TelephoneListPref = &BusinessTelephoneListPref;
2315 // Process the properties.
2317 bool FirstToken = TRUE;
2320 SplitPoints.clear();
2321 SplitLength.clear();
2323 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2327 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2328 intiter != SplitPoints.end(); ++intiter){
2330 SLiter = SplitLength.find(intiter->first);
2332 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2334 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2335 PropertyName = PropertyElement.GetNextToken();
2336 PropertyValue = PropertyElement.GetNextToken();
2338 intPrevValue = intiter->second;
2340 CaptureString(&PropertyValue, FALSE);
2342 // Process properties.
2344 if (PropertyName == wxT("ALTID")){
2346 TelephoneListAltID->erase(*TelephoneCount);
2347 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2349 } else if (PropertyName == wxT("PID")){
2351 TelephoneListPID->erase(*TelephoneCount);
2352 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2354 } else if (PropertyName == wxT("PREF")){
2356 int PriorityNumber = 0;
2357 bool ValidNumber = TRUE;
2360 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2363 catch(std::invalid_argument &e){
2364 ValidNumber = FALSE;
2367 if (ValidNumber == TRUE){
2369 TelephoneListPref->erase(*TelephoneCount);
2370 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2376 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2378 if (FirstToken == TRUE){
2380 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2385 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2395 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2396 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2398 // Add the name token data.
2400 if (!PropertyTokens.IsEmpty()){
2402 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2408 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2410 std::map<int, int> SplitPoints;
2411 std::map<int, int> SplitLength;
2413 int intPrevValue = 6;
2416 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2420 PropertyType PropType = PROPERTY_NONE;
2422 // Look for type before continuing.
2424 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2426 std::map<int, wxString> *LanguageList = NULL;
2427 std::map<int, wxString> *LanguageListType = NULL;
2428 std::map<int, wxString> *LanguageListAltID = NULL;
2429 std::map<int, wxString> *LanguageListPID = NULL;
2430 std::map<int, wxString> *LanguageListTokens = NULL;
2431 std::map<int, int> *LanguageListPref = NULL;
2435 LanguageList = &GeneralLanguageList;
2436 LanguageListType = &GeneralLanguageListType;
2437 LanguageListAltID = &GeneralLanguageListAltID;
2438 LanguageListPID = &GeneralLanguageListPID;
2439 LanguageListTokens = &GeneralLanguageListTokens;
2440 LanguageListPref = &GeneralLanguageListPref;
2443 LanguageList = &HomeLanguageList;
2444 LanguageListType = &HomeLanguageListType;
2445 LanguageListAltID = &HomeLanguageListAltID;
2446 LanguageListPID = &HomeLanguageListPID;
2447 LanguageListTokens = &HomeLanguageListTokens;
2448 LanguageListPref = &HomeLanguageListPref;
2451 LanguageList = &BusinessLanguageList;
2452 LanguageListType = &BusinessLanguageListType;
2453 LanguageListAltID = &BusinessLanguageListAltID;
2454 LanguageListPID = &BusinessLanguageListPID;
2455 LanguageListTokens = &BusinessLanguageListTokens;
2456 LanguageListPref = &BusinessLanguageListPref;
2462 std::map<int,int>::iterator SLiter;
2463 wxString PropertyData;
2464 wxString PropertyName;
2465 wxString PropertyValue;
2466 wxString PropertyTokens;
2467 bool FirstToken = TRUE;
2469 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2470 intiter != SplitPoints.end(); ++intiter){
2472 SLiter = SplitLength.find(intiter->first);
2474 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2476 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2477 PropertyName = PropertyElement.GetNextToken();
2478 PropertyValue = PropertyElement.GetNextToken();
2480 intPrevValue = intiter->second;
2482 CaptureString(&PropertyValue, FALSE);
2484 // Process properties.
2486 if (PropertyName == wxT("ALTID")){
2488 LanguageListAltID->erase(*LanguageCount);
2489 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2491 } else if (PropertyName == wxT("PID")){
2493 LanguageListPID->erase(*LanguageCount);
2494 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2496 } else if (PropertyName == wxT("PREF")){
2498 int PriorityNumber = 0;
2499 bool ValidNumber = TRUE;
2502 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2505 catch(std::invalid_argument &e){
2506 ValidNumber = FALSE;
2509 if (ValidNumber == TRUE){
2511 LanguageListPref->erase(*LanguageCount);
2512 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2518 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2520 if (FirstToken == TRUE){
2522 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2527 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2537 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2539 // Add the name token data.
2541 if (!PropertyTokens.IsEmpty()){
2543 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2549 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2551 std::map<int, int> SplitPoints;
2552 std::map<int, int> SplitLength;
2554 int intPrevValue = 5;
2557 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2561 PropertyType PropType = PROPERTY_NONE;
2563 // Look for type before continuing.
2565 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2567 std::map<int, wxString> *GeopositionList = NULL;
2568 std::map<int, wxString> *GeopositionListType = NULL;
2569 std::map<int, wxString> *GeopositionListAltID = NULL;
2570 std::map<int, wxString> *GeopositionListPID = NULL;
2571 std::map<int, wxString> *GeopositionListTokens = NULL;
2572 std::map<int, wxString> *GeopositionListMediatype = NULL;
2573 std::map<int, int> *GeopositionListPref = NULL;
2577 GeopositionList = &GeneralGeographyList;
2578 GeopositionListType = &GeneralGeographyListType;
2579 GeopositionListAltID = &GeneralGeographyListAltID;
2580 GeopositionListPID = &GeneralGeographyListPID;
2581 GeopositionListTokens = &GeneralGeographyListTokens;
2582 GeopositionListMediatype = &GeneralGeographyListMediatype;
2583 GeopositionListPref = &GeneralGeographyListPref;
2586 GeopositionList = &HomeGeographyList;
2587 GeopositionListType = &HomeGeographyListType;
2588 GeopositionListAltID = &HomeGeographyListAltID;
2589 GeopositionListPID = &HomeGeographyListPID;
2590 GeopositionListTokens = &HomeGeographyListTokens;
2591 GeopositionListMediatype = &HomeGeographyListMediatype;
2592 GeopositionListPref = &HomeGeographyListPref;
2595 GeopositionList = &BusinessGeographyList;
2596 GeopositionListType = &BusinessGeographyListType;
2597 GeopositionListAltID = &BusinessGeographyListAltID;
2598 GeopositionListPID = &BusinessGeographyListPID;
2599 GeopositionListTokens = &BusinessGeographyListTokens;
2600 GeopositionListMediatype = &BusinessGeographyListMediatype;
2601 GeopositionListPref = &BusinessGeographyListPref;
2607 std::map<int,int>::iterator SLiter;
2608 wxString PropertyData;
2609 wxString PropertyName;
2610 wxString PropertyValue;
2611 wxString PropertyTokens;
2612 bool FirstToken = TRUE;
2614 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2615 intiter != SplitPoints.end(); ++intiter){
2617 SLiter = SplitLength.find(intiter->first);
2619 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2621 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2622 PropertyName = PropertyElement.GetNextToken();
2623 PropertyValue = PropertyElement.GetNextToken();
2625 intPrevValue = intiter->second;
2627 CaptureString(&PropertyValue, FALSE);
2629 // Process properties.
2631 if (PropertyName == wxT("ALTID")){
2633 GeopositionListAltID->erase(*GeographicCount);
2634 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2636 } else if (PropertyName == wxT("PID")){
2638 GeopositionListPID->erase(*GeographicCount);
2639 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2641 } else if (PropertyName == wxT("MEDIATYPE")){
2643 GeopositionListMediatype->erase(*GeographicCount);
2644 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2646 } else if (PropertyName == wxT("PREF")){
2648 int PriorityNumber = 0;
2649 bool ValidNumber = TRUE;
2652 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2655 catch(std::invalid_argument &e){
2656 ValidNumber = FALSE;
2659 if (ValidNumber == TRUE){
2661 GeopositionListPref->erase(*GeographicCount);
2662 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2668 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2670 if (FirstToken == TRUE){
2672 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2677 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2687 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2689 // Add the name token data.
2691 if (!PropertyTokens.IsEmpty()){
2693 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2699 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2701 size_t intPropertyLen = PropertySeg1.Len();
2702 std::map<int, int> SplitPoints;
2703 std::map<int, int> SplitLength;
2704 std::map<int, int>::iterator SLiter;
2705 wxString PropertyData;
2706 wxString PropertyName;
2707 wxString PropertyValue;
2708 wxString PropertyTokens;
2709 wxString RelatedType;
2710 wxString RelatedTypeOriginal;
2711 wxString RelatedName;
2712 bool FirstToken = TRUE;
2713 int intSplitsFound = 0;
2714 int intSplitSize = 0;
2715 int intPrevValue = 9;
2719 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2723 // Look for type before continuing.
2725 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2726 intiter != SplitPoints.end(); ++intiter){
2728 SLiter = SplitLength.find(intiter->first);
2730 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2732 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2733 PropertyName = PropertyElement.GetNextToken();
2734 PropertyValue = PropertyElement.GetNextToken();
2736 intPrevValue = intiter->second;
2740 RelatedTypeOriginal = PropertyValue;
2742 if (PropertyName == wxT("TYPE")){
2744 if (PropertyValue == wxT("contact")){
2746 RelatedType = _("Contact");
2748 } else if (PropertyValue == wxT("acquaintance")){
2750 RelatedType = _("Acquaintance");
2752 } else if (PropertyValue == wxT("friend")){
2754 RelatedType = _("Friend");
2756 } else if (PropertyValue == wxT("met")){
2758 RelatedType = _("Met");
2760 } else if (PropertyValue == wxT("co-worker")){
2762 RelatedType = _("Co-worker");
2764 } else if (PropertyValue == wxT("colleague")){
2766 RelatedType = _("Colleague");
2768 } else if (PropertyValue == wxT("co-resident")){
2770 RelatedType = _("Co-resident");
2772 } else if (PropertyValue == wxT("neighbor")){
2774 RelatedType = _("Neighbour");
2776 } else if (PropertyValue == wxT("child")){
2778 RelatedType = _("Child");
2780 } else if (PropertyValue == wxT("parent")){
2782 RelatedType = _("Parent");
2784 } else if (PropertyValue == wxT("sibling")){
2786 RelatedType = _("Sibling");
2788 } else if (PropertyValue == wxT("spouse")){
2790 RelatedType = _("Spouse");
2792 } else if (PropertyValue == wxT("kin")){
2794 RelatedType = _("Kin");
2796 } else if (PropertyValue == wxT("muse")){
2798 RelatedType = _("Muse");
2800 } else if (PropertyValue == wxT("crush")){
2802 RelatedType = _("Crush");
2804 } else if (PropertyValue == wxT("date")){
2806 RelatedType = _("Date");
2808 } else if (PropertyValue == wxT("sweetheart")){
2810 RelatedType = _("Sweetheart");
2812 } else if (PropertyValue == wxT("me")){
2814 RelatedType = _("Me");
2816 } else if (PropertyValue == wxT("agent")){
2818 RelatedType = _("Agent");
2820 } else if (PropertyValue == wxT("emergency")){
2822 RelatedType = _("Emergency");
2826 RelatedType = PropertyValue;
2836 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2837 intiter != SplitPoints.end(); ++intiter){
2839 SLiter = SplitLength.find(intiter->first);
2841 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2843 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2844 PropertyName = PropertyElement.GetNextToken();
2845 PropertyValue = PropertyElement.GetNextToken();
2847 intPrevValue = intiter->second;
2849 // Process properties.
2851 size_t intPropertyValueLen = PropertyValue.Len();
2853 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2855 PropertyValue.Trim();
2856 PropertyValue.RemoveLast();
2860 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2862 PropertyValue.Remove(0, 1);
2866 CaptureString(&PropertyValue, FALSE);
2868 if (PropertyName == wxT("ALTID")){
2870 GeneralRelatedListAltID.erase(*RelatedCount);
2871 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2873 } else if (PropertyName == wxT("PID")){
2875 GeneralRelatedListPID.erase(*RelatedCount);
2876 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2878 } else if (PropertyName == wxT("PREF")){
2880 int PriorityNumber = 0;
2881 bool ValidNumber = TRUE;
2884 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2887 catch(std::invalid_argument &e){
2888 ValidNumber = FALSE;
2891 if (ValidNumber == TRUE){
2893 GeneralRelatedListPref.erase(*RelatedCount);
2894 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2898 } else if (PropertyName == wxT("LANGUAGE")){
2900 GeneralRelatedListLanguage.erase(*RelatedCount);
2901 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2903 } else if (PropertyName != wxT("TYPE")) {
2905 // Something else we don't know about so append
2906 // to the tokens variable.
2908 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2910 if (FirstToken == TRUE){
2912 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2917 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2927 // Add the data to the General/Home/Work address variables.
2929 GeneralRelatedList.erase(*RelatedCount);
2930 GeneralRelatedListRelType.erase(*RelatedCount);
2931 GeneralRelatedListType.erase(*RelatedCount);
2932 GeneralRelatedListTokens.erase(*RelatedCount);
2933 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2934 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2935 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2936 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2940 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2942 std::map<int, int> SplitPoints;
2943 std::map<int, int> SplitLength;
2944 std::map<int, int>::iterator SLiter;
2945 wxString PropertyData;
2946 wxString PropertyName;
2947 wxString PropertyValue;
2948 wxString PropertyTokens;
2949 bool FirstToken = TRUE;
2950 int intPrevValue = 5;
2955 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2959 PropertyType PropType = PROPERTY_NONE;
2961 // Look for type before continuing.
2963 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2965 // Setup the pointers.
2967 std::map<int, wxString> *WebsiteList = NULL;
2968 std::map<int, wxString> *WebsiteListAltID = NULL;
2969 std::map<int, wxString> *WebsiteListPID = NULL;
2970 std::map<int, wxString> *WebsiteListType = NULL;
2971 std::map<int, wxString> *WebsiteListTokens = NULL;
2972 std::map<int, wxString> *WebsiteListMediatype = NULL;
2973 std::map<int, int> *WebsiteListPref = NULL;
2975 // Setup blank lines for later on.
2979 WebsiteList = &GeneralWebsiteList;
2980 WebsiteListType = &GeneralWebsiteListType;
2981 WebsiteListAltID = &GeneralWebsiteListAltID;
2982 WebsiteListPID = &GeneralWebsiteListPID;
2983 WebsiteListTokens = &GeneralWebsiteListTokens;
2984 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2985 WebsiteListPref = &GeneralWebsiteListPref;
2988 WebsiteList = &HomeWebsiteList;
2989 WebsiteListType = &HomeWebsiteListType;
2990 WebsiteListAltID = &HomeWebsiteListAltID;
2991 WebsiteListPID = &HomeWebsiteListPID;
2992 WebsiteListTokens = &HomeWebsiteListTokens;
2993 WebsiteListMediatype = &HomeWebsiteListMediatype;
2994 WebsiteListPref = &HomeWebsiteListPref;
2997 WebsiteList = &BusinessWebsiteList;
2998 WebsiteListType = &BusinessWebsiteListType;
2999 WebsiteListAltID = &BusinessWebsiteListAltID;
3000 WebsiteListPID = &BusinessWebsiteListPID;
3001 WebsiteListTokens = &BusinessWebsiteListTokens;
3002 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3003 WebsiteListPref = &BusinessWebsiteListPref;
3009 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3010 intiter != SplitPoints.end(); ++intiter){
3012 SLiter = SplitLength.find(intiter->first);
3014 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3016 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3017 PropertyName = PropertyElement.GetNextToken();
3018 PropertyValue = PropertyElement.GetNextToken();
3020 intPrevValue = intiter->second;
3022 // Process properties.
3024 size_t intPropertyValueLen = PropertyValue.Len();
3026 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3028 PropertyValue.Trim();
3029 PropertyValue.RemoveLast();
3033 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3035 PropertyValue.Remove(0, 1);
3039 CaptureString(&PropertyValue, FALSE);
3041 if (PropertyName == wxT("ALTID")){
3043 WebsiteListAltID->erase(*URLCount);
3044 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3046 } else if (PropertyName == wxT("PID")){
3048 WebsiteListPID->erase(*URLCount);
3049 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3051 } else if (PropertyName == wxT("PREF")){
3053 int PriorityNumber = 0;
3054 bool ValidNumber = TRUE;
3057 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3060 catch(std::invalid_argument &e){
3061 ValidNumber = FALSE;
3064 if (ValidNumber == TRUE){
3066 WebsiteListPref->erase(*URLCount);
3067 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3071 } else if (PropertyName == wxT("MEDIATYPE")){
3073 WebsiteListMediatype->erase(*URLCount);
3074 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3078 // Something else we don't know about so append
3079 // to the tokens variable.
3081 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3083 if (FirstToken == TRUE){
3085 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3090 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3100 // Add the data to the General/Home/Work address variables.
3102 CaptureString(&PropertySeg2, FALSE);
3104 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3106 if (!PropertyTokens.IsEmpty()){
3108 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3114 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3116 std::map<int, int> SplitPoints;
3117 std::map<int, int> SplitLength;
3118 std::map<int, int>::iterator SLiter;
3119 wxString PropertyData;
3120 wxString PropertyName;
3121 wxString PropertyValue;
3122 wxString PropertyTokens;
3123 bool FirstToken = TRUE;
3124 int intPrevValue = 7;
3129 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3133 PropertyType PropType = PROPERTY_NONE;
3135 // Look for type before continuing.
3137 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3139 // Setup the pointers.
3141 std::map<int, wxString> *TitleList = NULL;
3142 std::map<int, wxString> *TitleListAltID = NULL;
3143 std::map<int, wxString> *TitleListPID = NULL;
3144 std::map<int, wxString> *TitleListType = NULL;
3145 std::map<int, wxString> *TitleListTokens = NULL;
3146 std::map<int, wxString> *TitleListLanguage = NULL;
3147 std::map<int, int> *TitleListPref = NULL;
3149 // Setup blank lines for later on.
3153 TitleList = &GeneralTitleList;
3154 TitleListType = &GeneralTitleListType;
3155 TitleListAltID = &GeneralTitleListAltID;
3156 TitleListPID = &GeneralTitleListPID;
3157 TitleListTokens = &GeneralTitleListTokens;
3158 TitleListLanguage = &GeneralTitleListLanguage;
3159 TitleListPref = &GeneralTitleListPref;
3162 TitleList = &HomeTitleList;
3163 TitleListType = &HomeTitleListType;
3164 TitleListAltID = &HomeTitleListAltID;
3165 TitleListPID = &HomeTitleListPID;
3166 TitleListTokens = &HomeTitleListTokens;
3167 TitleListLanguage = &HomeTitleListLanguage;
3168 TitleListPref = &HomeTitleListPref;
3171 TitleList = &BusinessTitleList;
3172 TitleListType = &BusinessTitleListType;
3173 TitleListAltID = &BusinessTitleListAltID;
3174 TitleListPID = &BusinessTitleListPID;
3175 TitleListTokens = &BusinessTitleListTokens;
3176 TitleListLanguage = &BusinessTitleListLanguage;
3177 TitleListPref = &BusinessTitleListPref;
3183 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3184 intiter != SplitPoints.end(); ++intiter){
3186 SLiter = SplitLength.find(intiter->first);
3188 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3190 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3191 PropertyName = PropertyElement.GetNextToken();
3192 PropertyValue = PropertyElement.GetNextToken();
3194 intPrevValue = intiter->second;
3196 // Process properties.
3198 size_t intPropertyValueLen = PropertyValue.Len();
3200 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3202 PropertyValue.Trim();
3203 PropertyValue.RemoveLast();
3207 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3209 PropertyValue.Remove(0, 1);
3213 CaptureString(&PropertyValue, FALSE);
3215 if (PropertyName == wxT("ALTID")){
3217 TitleListAltID->erase(*TitleCount);
3218 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3220 } else if (PropertyName == wxT("PID")){
3222 TitleListPID->erase(*TitleCount);
3223 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3225 } else if (PropertyName == wxT("PREF")){
3227 int PriorityNumber = 0;
3228 bool ValidNumber = TRUE;
3231 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3234 catch(std::invalid_argument &e){
3235 ValidNumber = FALSE;
3238 if (ValidNumber == TRUE){
3240 TitleListPref->erase(*TitleCount);
3241 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3245 } else if (PropertyName == wxT("LANGUAGE")){
3247 TitleListLanguage->erase(*TitleCount);
3248 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3252 // Something else we don't know about so append
3253 // to the tokens variable.
3255 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3257 if (FirstToken == TRUE){
3259 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3264 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3274 // Add the data to the General/Home/Work address variables.
3276 CaptureString(&PropertySeg2, FALSE);
3278 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3280 if (!PropertyTokens.IsEmpty()){
3282 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3288 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3290 std::map<int, int> SplitPoints;
3291 std::map<int, int> SplitLength;
3292 std::map<int, int>::iterator SLiter;
3293 wxString PropertyData;
3294 wxString PropertyName;
3295 wxString PropertyValue;
3296 wxString PropertyTokens;
3297 bool FirstToken = TRUE;
3298 int intPrevValue = 6;
3303 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3307 PropertyType PropType = PROPERTY_NONE;
3309 // Look for type before continuing.
3311 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3313 // Setup the pointers.
3315 std::map<int, wxString> *RoleList = NULL;
3316 std::map<int, wxString> *RoleListAltID = NULL;
3317 std::map<int, wxString> *RoleListPID = NULL;
3318 std::map<int, wxString> *RoleListType = NULL;
3319 std::map<int, wxString> *RoleListTokens = NULL;
3320 std::map<int, wxString> *RoleListLanguage = NULL;
3321 std::map<int, int> *RoleListPref = NULL;
3323 // Setup blank lines for later on.
3327 RoleList = &GeneralRoleList;
3328 RoleListType = &GeneralRoleListType;
3329 RoleListAltID = &GeneralRoleListAltID;
3330 RoleListPID = &GeneralRoleListPID;
3331 RoleListTokens = &GeneralRoleListTokens;
3332 RoleListLanguage = &GeneralRoleListLanguage;
3333 RoleListPref = &GeneralRoleListPref;
3336 RoleList = &HomeRoleList;
3337 RoleListType = &HomeRoleListType;
3338 RoleListAltID = &HomeRoleListAltID;
3339 RoleListPID = &HomeRoleListPID;
3340 RoleListTokens = &HomeRoleListTokens;
3341 RoleListLanguage = &HomeRoleListLanguage;
3342 RoleListPref = &HomeRoleListPref;
3345 RoleList = &BusinessRoleList;
3346 RoleListType = &BusinessRoleListType;
3347 RoleListAltID = &BusinessRoleListAltID;
3348 RoleListPID = &BusinessRoleListPID;
3349 RoleListTokens = &BusinessRoleListTokens;
3350 RoleListLanguage = &BusinessRoleListLanguage;
3351 RoleListPref = &BusinessRoleListPref;
3357 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3358 intiter != SplitPoints.end(); ++intiter){
3360 SLiter = SplitLength.find(intiter->first);
3362 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3364 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3365 PropertyName = PropertyElement.GetNextToken();
3366 PropertyValue = PropertyElement.GetNextToken();
3368 intPrevValue = intiter->second;
3370 // Process properties.
3372 size_t intPropertyValueLen = PropertyValue.Len();
3374 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3376 PropertyValue.Trim();
3377 PropertyValue.RemoveLast();
3381 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3383 PropertyValue.Remove(0, 1);
3387 CaptureString(&PropertyValue, FALSE);
3389 if (PropertyName == wxT("ALTID")){
3391 RoleListAltID->erase(*RoleCount);
3392 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3394 } else if (PropertyName == wxT("PID")){
3396 RoleListPID->erase(*RoleCount);
3397 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3399 } else if (PropertyName == wxT("PREF")){
3401 int PriorityNumber = 0;
3402 bool ValidNumber = TRUE;
3405 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3408 catch(std::invalid_argument &e){
3409 ValidNumber = FALSE;
3412 if (ValidNumber == TRUE){
3414 RoleListPref->erase(*RoleCount);
3415 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3419 } else if (PropertyName == wxT("LANGUAGE")){
3421 RoleListLanguage->erase(*RoleCount);
3422 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3426 // Something else we don't know about so append
3427 // to the tokens variable.
3429 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3431 if (FirstToken == TRUE){
3433 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3438 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3448 // Add the data to the General/Home/Work address variables.
3450 CaptureString(&PropertySeg2, FALSE);
3452 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3454 if (!PropertyTokens.IsEmpty()){
3456 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3462 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3464 std::map<int, int> SplitPoints;
3465 std::map<int, int> SplitLength;
3466 std::map<int, int>::iterator SLiter;
3467 wxString PropertyData;
3468 wxString PropertyName;
3469 wxString PropertyValue;
3470 wxString PropertyTokens;
3471 bool FirstToken = TRUE;
3472 int intPrevValue = 5;
3477 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3481 PropertyType PropType = PROPERTY_NONE;
3483 // Look for type before continuing.
3485 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3487 // Setup the pointers.
3489 std::map<int, wxString> *OrganisationsList = NULL;
3490 std::map<int, wxString> *OrganisationsListAltID = NULL;
3491 std::map<int, wxString> *OrganisationsListPID = NULL;
3492 std::map<int, wxString> *OrganisationsListType = NULL;
3493 std::map<int, wxString> *OrganisationsListTokens = NULL;
3494 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3495 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3496 std::map<int, int> *OrganisationsListPref = NULL;
3498 // Setup blank lines for later on.
3502 OrganisationsList = &GeneralOrganisationsList;
3503 OrganisationsListType = &GeneralOrganisationsListType;
3504 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3505 OrganisationsListPID = &GeneralOrganisationsListPID;
3506 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3507 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3508 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3509 OrganisationsListPref = &GeneralOrganisationsListPref;
3512 OrganisationsList = &HomeOrganisationsList;
3513 OrganisationsListType = &HomeOrganisationsListType;
3514 OrganisationsListAltID = &HomeOrganisationsListAltID;
3515 OrganisationsListPID = &HomeOrganisationsListPID;
3516 OrganisationsListTokens = &HomeOrganisationsListTokens;
3517 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3518 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3519 OrganisationsListPref = &HomeOrganisationsListPref;
3522 OrganisationsList = &BusinessOrganisationsList;
3523 OrganisationsListType = &BusinessOrganisationsListType;
3524 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3525 OrganisationsListPID = &BusinessOrganisationsListPID;
3526 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3527 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3528 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3529 OrganisationsListPref = &BusinessOrganisationsListPref;
3535 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3536 intiter != SplitPoints.end(); ++intiter){
3538 SLiter = SplitLength.find(intiter->first);
3540 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3542 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3543 PropertyName = PropertyElement.GetNextToken();
3544 PropertyValue = PropertyElement.GetNextToken();
3546 intPrevValue = intiter->second;
3548 // Process properties.
3550 size_t intPropertyValueLen = PropertyValue.Len();
3552 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3554 PropertyValue.Trim();
3555 PropertyValue.RemoveLast();
3559 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3561 PropertyValue.Remove(0, 1);
3565 CaptureString(&PropertyValue, FALSE);
3567 if (PropertyName == wxT("ALTID")){
3569 OrganisationsListAltID->erase(*OrganisationCount);
3570 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3572 } else if (PropertyName == wxT("PID")){
3574 OrganisationsListPID->erase(*OrganisationCount);
3575 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3577 } else if (PropertyName == wxT("SORT-AS")){
3579 OrganisationsListSortAs->erase(*OrganisationCount);
3580 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3582 } else if (PropertyName == wxT("PREF")){
3584 int PriorityNumber = 0;
3585 bool ValidNumber = TRUE;
3588 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3591 catch(std::invalid_argument &e){
3592 ValidNumber = FALSE;
3595 if (ValidNumber == TRUE){
3597 OrganisationsListPref->erase(*OrganisationCount);
3598 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3602 } else if (PropertyName == wxT("LANGUAGE")){
3604 OrganisationsListLanguage->erase(*OrganisationCount);
3605 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3609 // Something else we don't know about so append
3610 // to the tokens variable.
3612 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3614 if (FirstToken == TRUE){
3616 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3621 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3631 // Add the data to the General/Home/Work address variables.
3633 CaptureString(&PropertySeg2, FALSE);
3635 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3637 if (!PropertyTokens.IsEmpty()){
3639 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3645 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3647 std::map<int, int> SplitPoints;
3648 std::map<int, int> SplitLength;
3649 std::map<int, int>::iterator SLiter;
3650 wxString PropertyData;
3651 wxString PropertyName;
3652 wxString PropertyValue;
3653 wxString PropertyTokens;
3654 bool FirstToken = TRUE;
3655 int intPrevValue = 6;
3660 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3664 PropertyType PropType = PROPERTY_NONE;
3666 // Look for type before continuing.
3668 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3670 // Setup the pointers.
3672 std::map<int, wxString> *NoteList = NULL;
3673 std::map<int, wxString> *NoteListAltID = NULL;
3674 std::map<int, wxString> *NoteListPID = NULL;
3675 std::map<int, wxString> *NoteListType = NULL;
3676 std::map<int, wxString> *NoteListTokens = NULL;
3677 std::map<int, wxString> *NoteListLanguage = NULL;
3678 std::map<int, int> *NoteListPref = NULL;
3680 // Setup blank lines for later on.
3684 NoteList = &GeneralNoteList;
3685 NoteListType = &GeneralNoteListType;
3686 NoteListAltID = &GeneralNoteListAltID;
3687 NoteListPID = &GeneralNoteListPID;
3688 NoteListTokens = &GeneralNoteListTokens;
3689 NoteListLanguage = &GeneralNoteListLanguage;
3690 NoteListPref = &GeneralNoteListPref;
3693 NoteList = &HomeNoteList;
3694 NoteListType = &HomeNoteListType;
3695 NoteListAltID = &HomeNoteListAltID;
3696 NoteListPID = &HomeNoteListPID;
3697 NoteListTokens = &HomeNoteListTokens;
3698 NoteListLanguage = &HomeNoteListLanguage;
3699 NoteListPref = &HomeNoteListPref;
3702 NoteList = &BusinessNoteList;
3703 NoteListType = &BusinessNoteListType;
3704 NoteListAltID = &BusinessNoteListAltID;
3705 NoteListPID = &BusinessNoteListPID;
3706 NoteListTokens = &BusinessNoteListTokens;
3707 NoteListLanguage = &BusinessNoteListLanguage;
3708 NoteListPref = &BusinessNoteListPref;
3714 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3715 intiter != SplitPoints.end(); ++intiter){
3717 SLiter = SplitLength.find(intiter->first);
3719 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3721 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3722 PropertyName = PropertyElement.GetNextToken();
3723 PropertyValue = PropertyElement.GetNextToken();
3725 intPrevValue = intiter->second;
3727 // Process properties.
3729 size_t intPropertyValueLen = PropertyValue.Len();
3731 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3733 PropertyValue.Trim();
3734 PropertyValue.RemoveLast();
3738 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3740 PropertyValue.Remove(0, 1);
3744 CaptureString(&PropertyValue, FALSE);
3746 if (PropertyName == wxT("ALTID")){
3748 NoteListAltID->erase(*NoteCount);
3749 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3751 } else if (PropertyName == wxT("PID")){
3753 NoteListPID->erase(*NoteCount);
3754 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3756 } else if (PropertyName == wxT("PREF")){
3758 int PriorityNumber = 0;
3759 bool ValidNumber = TRUE;
3762 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3765 catch(std::invalid_argument &e){
3766 ValidNumber = FALSE;
3769 if (ValidNumber == TRUE){
3771 NoteListPref->erase(*NoteCount);
3772 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3776 } else if (PropertyName == wxT("LANGUAGE")){
3778 NoteListLanguage->erase(*NoteCount);
3779 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3783 // Something else we don't know about so append
3784 // to the tokens variable.
3786 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3788 if (FirstToken == TRUE){
3790 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3795 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3805 // Add the data to the General/Home/Work address variables.
3807 CaptureString(&PropertySeg2, FALSE);
3809 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3811 if (!PropertyTokens.IsEmpty()){
3813 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3819 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3821 std::map<int, int> SplitPoints;
3822 std::map<int, int> SplitLength;
3823 std::map<int, int>::iterator SLiter;
3824 wxString PropertyData;
3825 wxString PropertyName;
3826 wxString PropertyValue;
3827 wxString PropertyTokens;
3828 bool FirstToken = TRUE;
3829 int intPrevValue = 12;
3834 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3838 PropertyType PropType = PROPERTY_NONE;
3840 // Look for type before continuing.
3842 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3844 // Setup blank lines for later on.
3850 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3853 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3859 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3860 intiter != SplitPoints.end(); ++intiter){
3862 SLiter = SplitLength.find(intiter->first);
3864 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3866 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3867 PropertyName = PropertyElement.GetNextToken();
3868 PropertyValue = PropertyElement.GetNextToken();
3870 intPrevValue = intiter->second;
3872 // Process properties.
3874 size_t intPropertyValueLen = PropertyValue.Len();
3876 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3878 PropertyValue.Trim();
3879 PropertyValue.RemoveLast();
3883 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3885 PropertyValue.Remove(0, 1);
3889 CaptureString(&PropertyValue, FALSE);
3891 if (PropertyName == wxT("ALTID")){
3893 CategoriesListAltID.erase(*CategoryCount);
3894 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3896 } else if (PropertyName == wxT("PID")){
3898 CategoriesListPID.erase(*CategoryCount);
3899 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3901 } else if (PropertyName == wxT("PREF")){
3903 int PriorityNumber = 0;
3904 bool ValidNumber = TRUE;
3907 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3910 catch(std::invalid_argument &e){
3911 ValidNumber = FALSE;
3914 if (ValidNumber == TRUE){
3916 CategoriesListPref.erase(*CategoryCount);
3917 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3921 } else if (PropertyName == wxT("LANGUAGE")){
3923 CategoriesListLanguage.erase(*CategoryCount);
3924 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3928 // Something else we don't know about so append
3929 // to the tokens variable.
3931 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3933 if (FirstToken == TRUE){
3935 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3940 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3950 // Deal with multiple categories.
3952 int intOrigCatCount = *CategoryCount;
3953 bool FirstCategoryProcessed = TRUE;
3954 bool AfterFirstToken = FALSE;
3955 int intSplitSize = 0;
3956 int intSplitsFound = 0;
3957 int intSplitSeek = 0;
3958 int intPropertyLen = PropertySeg2.Len();
3960 SplitPoints.clear();
3961 SplitLength.clear();
3964 for (int i = 0; i <= intPropertyLen; i++){
3966 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3974 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3976 if (AfterFirstToken == TRUE){
3978 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3979 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3983 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3984 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3985 AfterFirstToken = TRUE;
3997 if (SplitPoints.size() > 0){
3999 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4000 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4004 if (SplitPoints.size() == 0){
4006 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4008 if (!PropertyTokens.IsEmpty()){
4010 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4016 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4017 intiter != SplitPoints.end(); ++intiter){
4019 SLiter = SplitLength.find(intiter->first);
4021 intPrevValue = intiter->second;
4023 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4025 // Add the data to the General/Home/Work address variables.
4027 // Trim any whitespace from the start and end.
4029 PropertyData = PropertyData.Trim(FALSE);
4030 PropertyData = PropertyData.Trim(TRUE);
4032 CaptureString(&PropertyData, FALSE);
4034 if (FirstCategoryProcessed == TRUE){
4036 FirstCategoryProcessed = FALSE;
4038 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4040 if (!PropertyTokens.IsEmpty()){
4042 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4052 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4054 if (!PropertyTokens.IsEmpty()){
4056 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4062 // Copy the properties to each of the categories (if it exists).
4064 if (!PropertyTokens.IsEmpty()){
4066 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4070 // Check if ALTID was used.
4072 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4074 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4078 // Check if PID was used.
4080 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4082 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4086 // Check if PREF was used.
4088 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4090 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4094 // Check if LANGUAGE was used.
4096 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4098 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4102 // Check if TYPE was used.
4108 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4111 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4119 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4121 size_t intPropertyLen = PropertySeg1.Len();
4122 std::map<int, int> SplitPoints;
4123 std::map<int, int> SplitLength;
4124 std::map<int, int>::iterator SLiter;
4125 wxString PropertyData;
4126 wxString PropertyName;
4127 wxString PropertyValue;
4128 wxString PropertyTokens;
4129 bool FirstToken = TRUE;
4130 int intSplitsFound = 0;
4131 int intSplitSize = 0;
4132 int intPrevValue = 7;
4136 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4140 PropertyType PropType = PROPERTY_NONE;
4142 // Look for type before continuing.
4144 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4148 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4149 intiter != SplitPoints.end(); ++intiter){
4151 SLiter = SplitLength.find(intiter->first);
4153 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4155 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4156 PropertyName = PropertyElement.GetNextToken();
4157 PropertyValue = PropertyElement.GetNextToken();
4159 intPrevValue = intiter->second;
4161 // Process properties.
4163 size_t intPropertyValueLen = PropertyValue.Len();
4165 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4167 PropertyValue.Trim();
4168 PropertyValue.RemoveLast();
4172 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4174 PropertyValue.Remove(0, 1);
4178 CaptureString(&PropertyValue, FALSE);
4180 if (PropertyName == wxT("ALTID")){
4182 PicturesListAltID.erase(*PhotoCount);
4183 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4185 } else if (PropertyName == wxT("PID")){
4187 PicturesListPID.erase(*PhotoCount);
4188 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4190 } else if (PropertyName == wxT("PREF")){
4192 int PriorityNumber = 0;
4193 bool ValidNumber = TRUE;
4196 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4199 catch(std::invalid_argument &e){
4200 ValidNumber = FALSE;
4203 if (ValidNumber == TRUE){
4205 PicturesListPref.erase(*PhotoCount);
4206 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4210 } else if (PropertyName == wxT("MEDIATYPE")){
4212 PicturesListMediatype.erase(*PhotoCount);
4213 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4217 // Something else we don't know about so append
4218 // to the tokens variable.
4220 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4222 if (FirstToken == TRUE){
4224 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4229 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4239 intPropertyLen = PropertySeg2.Len();
4240 SplitPoints.clear();
4241 SplitLength.clear();
4246 CaptureString(&PropertySeg2, FALSE);
4248 for (int i = 0; i <= intPropertyLen; i++){
4252 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4255 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4257 if (intSplitsFound == 6){
4259 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4264 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4274 wxString wxSPhotoURI;
4275 wxString wxSPhotoMIME;
4276 wxString wxSPhotoEncoding;
4277 wxString wxSPhotoData;
4278 std::string base64enc;
4280 if (intSplitsFound == 0){
4284 std::map<int, int>::iterator striter;
4286 striter = SplitLength.find(1);
4288 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4290 while (wSTDataType.HasMoreTokens() == TRUE){
4292 wxSPhotoURI = wSTDataType.GetNextToken();
4293 wxSPhotoMIME = wSTDataType.GetNextToken();
4298 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4300 while (wSTDataInfo.HasMoreTokens() == TRUE){
4302 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4303 wxSPhotoData = wSTDataInfo.GetNextToken();
4304 base64enc = wxSPhotoData.mb_str();
4311 // Add the data to the General/Home/Work address variables.
4313 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4314 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4315 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4321 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4324 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4328 if (!PropertyTokens.IsEmpty()){
4330 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4336 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4338 size_t intPropertyLen = PropertySeg1.Len();
4339 std::map<int, int> SplitPoints;
4340 std::map<int, int> SplitLength;
4341 std::map<int, int>::iterator SLiter;
4342 wxString PropertyData;
4343 wxString PropertyName;
4344 wxString PropertyValue;
4345 wxString PropertyTokens;
4346 bool FirstToken = TRUE;
4347 int intSplitsFound = 0;
4348 int intSplitSize = 0;
4349 int intPrevValue = 6;
4353 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4357 PropertyType PropType = PROPERTY_NONE;
4359 // Look for type before continuing.
4361 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4365 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4366 intiter != SplitPoints.end(); ++intiter){
4368 SLiter = SplitLength.find(intiter->first);
4370 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4372 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4373 PropertyName = PropertyElement.GetNextToken();
4374 PropertyValue = PropertyElement.GetNextToken();
4376 intPrevValue = intiter->second;
4378 // Process properties.
4380 size_t intPropertyValueLen = PropertyValue.Len();
4382 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4384 PropertyValue.Trim();
4385 PropertyValue.RemoveLast();
4389 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4391 PropertyValue.Remove(0, 1);
4395 CaptureString(&PropertyValue, FALSE);
4397 if (PropertyName == wxT("ALTID")){
4399 LogosListAltID.erase(*LogoCount);
4400 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4402 } else if (PropertyName == wxT("PID")){
4404 LogosListPID.erase(*LogoCount);
4405 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4407 } else if (PropertyName == wxT("PREF")){
4409 int PriorityNumber = 0;
4410 bool ValidNumber = TRUE;
4413 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4416 catch(std::invalid_argument &e){
4417 ValidNumber = FALSE;
4420 if (ValidNumber == TRUE){
4422 LogosListPref.erase(*LogoCount);
4423 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4427 } else if (PropertyName == wxT("MEDIATYPE")){
4429 LogosListMediatype.erase(*LogoCount);
4430 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4434 // Something else we don't know about so append
4435 // to the tokens variable.
4437 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4439 if (FirstToken == TRUE){
4441 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4446 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4456 intPropertyLen = PropertySeg2.Len();
4457 SplitPoints.clear();
4458 SplitLength.clear();
4463 CaptureString(&PropertySeg2, FALSE);
4465 for (int i = 0; i <= intPropertyLen; i++){
4469 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4472 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4474 if (intSplitsFound == 6){
4476 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4481 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4491 wxString wxSPhotoURI;
4492 wxString wxSPhotoMIME;
4493 wxString wxSPhotoEncoding;
4494 wxString wxSPhotoData;
4495 std::string base64enc;
4497 if (intSplitsFound == 0){
4501 std::map<int, int>::iterator striter;
4503 striter = SplitLength.find(1);
4505 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4507 while (wSTDataType.HasMoreTokens() == TRUE){
4509 wxSPhotoURI = wSTDataType.GetNextToken();
4510 wxSPhotoMIME = wSTDataType.GetNextToken();
4515 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4517 while (wSTDataInfo.HasMoreTokens() == TRUE){
4519 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4520 wxSPhotoData = wSTDataInfo.GetNextToken();
4521 base64enc = wxSPhotoData.mb_str();
4528 // Add the data to the General/Home/Work address variables.
4530 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4531 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4532 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4538 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4541 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4545 if (!PropertyTokens.IsEmpty()){
4547 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4553 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4555 size_t intPropertyLen = PropertySeg1.Len();
4556 std::map<int, int> SplitPoints;
4557 std::map<int, int> SplitLength;
4558 std::map<int, int>::iterator SLiter;
4559 wxString PropertyData;
4560 wxString PropertyName;
4561 wxString PropertyValue;
4562 wxString PropertyTokens;
4563 bool FirstToken = TRUE;
4564 int intSplitsFound = 0;
4565 int intSplitSize = 0;
4566 int intPrevValue = 7;
4570 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4574 PropertyType PropType = PROPERTY_NONE;
4576 // Look for type before continuing.
4578 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4582 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4583 intiter != SplitPoints.end(); ++intiter){
4585 SLiter = SplitLength.find(intiter->first);
4587 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4589 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4590 PropertyName = PropertyElement.GetNextToken();
4591 PropertyValue = PropertyElement.GetNextToken();
4593 intPrevValue = intiter->second;
4595 // Process properties.
4597 size_t intPropertyValueLen = PropertyValue.Len();
4599 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4601 PropertyValue.Trim();
4602 PropertyValue.RemoveLast();
4606 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4608 PropertyValue.Remove(0, 1);
4612 CaptureString(&PropertyValue, FALSE);
4614 if (PropertyName == wxT("ALTID")){
4616 SoundsListAltID.erase(*SoundCount);
4617 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4619 } else if (PropertyName == wxT("PID")){
4621 SoundsListPID.erase(*SoundCount);
4622 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4624 } else if (PropertyName == wxT("PREF")){
4626 int PriorityNumber = 0;
4627 bool ValidNumber = TRUE;
4630 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4633 catch(std::invalid_argument &e){
4634 ValidNumber = FALSE;
4637 if (ValidNumber == TRUE){
4639 SoundsListPref.erase(*SoundCount);
4640 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4644 } else if (PropertyName == wxT("MEDIATYPE")){
4646 SoundsListMediatype.erase(*SoundCount);
4647 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4649 } else if (PropertyName == wxT("LANGUAGE")){
4651 SoundsListLanguage.erase(*SoundCount);
4652 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4656 // Something else we don't know about so append
4657 // to the tokens variable.
4659 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4661 if (FirstToken == TRUE){
4663 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4668 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4678 intPropertyLen = PropertySeg2.Len();
4679 SplitPoints.clear();
4680 SplitLength.clear();
4685 CaptureString(&PropertySeg2, FALSE);
4687 for (int i = 0; i <= intPropertyLen; i++){
4691 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4694 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4696 if (intSplitsFound == 6){
4698 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4703 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4713 wxString wxSSoundURI;
4714 wxString wxSSoundMIME;
4715 wxString wxSSoundEncoding;
4716 wxString wxSSoundData;
4717 std::string base64enc;
4719 if (intSplitsFound == 0){
4723 std::map<int, int>::iterator striter;
4725 striter = SplitLength.find(1);
4727 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4729 while (wSTDataType.HasMoreTokens() == TRUE){
4731 wxSSoundURI = wSTDataType.GetNextToken();
4732 wxSSoundMIME = wSTDataType.GetNextToken();
4737 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4739 while (wSTDataInfo.HasMoreTokens() == TRUE){
4741 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4742 wxSSoundData = wSTDataInfo.GetNextToken();
4743 base64enc = wxSSoundData.mb_str();
4750 // Add the data to the General/Home/Work address variables.
4756 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4759 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4763 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4764 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4765 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4767 if (!PropertyTokens.IsEmpty()){
4769 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4775 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4777 size_t intPropertyLen = PropertySeg1.Len();
4778 std::map<int, int> SplitPoints;
4779 std::map<int, int> SplitLength;
4780 std::map<int, int>::iterator SLiter;
4781 wxString PropertyData;
4782 wxString PropertyName;
4783 wxString PropertyValue;
4784 wxString PropertyTokens;
4785 bool FirstToken = TRUE;
4786 int intSplitsFound = 0;
4787 int intSplitSize = 0;
4788 int intPrevValue = 8;
4792 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4796 PropertyType PropType = PROPERTY_NONE;
4798 // Look for type before continuing.
4800 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4804 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4805 intiter != SplitPoints.end(); ++intiter){
4807 SLiter = SplitLength.find(intiter->first);
4809 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4811 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4812 PropertyName = PropertyElement.GetNextToken();
4813 PropertyValue = PropertyElement.GetNextToken();
4815 intPrevValue = intiter->second;
4817 // Process properties.
4819 size_t intPropertyValueLen = PropertyValue.Len();
4821 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4823 PropertyValue.Trim();
4824 PropertyValue.RemoveLast();
4828 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4830 PropertyValue.Remove(0, 1);
4834 CaptureString(&PropertyValue, FALSE);
4836 if (PropertyName == wxT("ALTID")){
4838 CalendarListAltID.erase(*CalURICount);
4839 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4841 } else if (PropertyName == wxT("PID")){
4843 CalendarListPID.erase(*CalURICount);
4844 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4846 } else if (PropertyName == wxT("PREF")){
4848 int PriorityNumber = 0;
4849 bool ValidNumber = TRUE;
4852 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4855 catch(std::invalid_argument &e){
4856 ValidNumber = FALSE;
4859 if (ValidNumber == TRUE){
4861 CalendarListPref.erase(*CalURICount);
4862 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
4866 } else if (PropertyName == wxT("MEDIATYPE")){
4868 CalendarListMediatype.erase(*CalURICount);
4869 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4873 // Something else we don't know about so append
4874 // to the tokens variable.
4876 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4878 if (FirstToken == TRUE){
4880 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4885 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4895 intPropertyLen = PropertySeg2.Len();
4896 SplitPoints.clear();
4897 SplitLength.clear();
4902 CaptureString(&PropertySeg2, FALSE);
4904 // Add the data to the General/Home/Work address variables.
4910 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4913 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4917 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4919 if (!PropertyTokens.IsEmpty()){
4921 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4927 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4929 size_t intPropertyLen = PropertySeg1.Len();
4930 std::map<int, int> SplitPoints;
4931 std::map<int, int> SplitLength;
4932 std::map<int, int>::iterator SLiter;
4933 wxString PropertyData;
4934 wxString PropertyName;
4935 wxString PropertyValue;
4936 wxString PropertyTokens;
4937 bool FirstToken = TRUE;
4938 int intSplitsFound = 0;
4939 int intSplitSize = 0;
4940 int intPrevValue = 8;
4944 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4948 PropertyType PropType = PROPERTY_NONE;
4950 // Look for type before continuing.
4952 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4956 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4957 intiter != SplitPoints.end(); ++intiter){
4959 SLiter = SplitLength.find(intiter->first);
4961 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4963 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4964 PropertyName = PropertyElement.GetNextToken();
4965 PropertyValue = PropertyElement.GetNextToken();
4967 intPrevValue = intiter->second;
4969 // Process properties.
4971 size_t intPropertyValueLen = PropertyValue.Len();
4973 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4975 PropertyValue.Trim();
4976 PropertyValue.RemoveLast();
4980 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4982 PropertyValue.Remove(0, 1);
4986 CaptureString(&PropertyValue, FALSE);
4988 if (PropertyName == wxT("ALTID")){
4990 CalendarRequestListAltID.erase(*CalAdrURICount);
4991 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4993 } else if (PropertyName == wxT("PID")){
4995 CalendarRequestListPID.erase(*CalAdrURICount);
4996 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4998 } else if (PropertyName == wxT("PREF")){
5000 int PriorityNumber = 0;
5001 bool ValidNumber = TRUE;
5004 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5007 catch(std::invalid_argument &e){
5008 ValidNumber = FALSE;
5011 if (ValidNumber == TRUE){
5013 CalendarRequestListPref.erase(*CalAdrURICount);
5014 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5018 } else if (PropertyName == wxT("MEDIATYPE")){
5020 CalendarRequestListMediatype.erase(*CalAdrURICount);
5021 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5025 // Something else we don't know about so append
5026 // to the tokens variable.
5028 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5030 if (FirstToken == TRUE){
5032 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5037 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5047 intPropertyLen = PropertySeg2.Len();
5048 SplitPoints.clear();
5049 SplitLength.clear();
5054 CaptureString(&PropertySeg2, FALSE);
5056 // Add the data to the General/Home/Work address variables.
5062 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5065 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5069 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5071 if (!PropertyTokens.IsEmpty()){
5073 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5079 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5081 size_t intPropertyLen = PropertySeg1.Len();
5082 std::map<int, int> SplitPoints;
5083 std::map<int, int> SplitLength;
5084 std::map<int, int>::iterator SLiter;
5085 wxString PropertyData;
5086 wxString PropertyName;
5087 wxString PropertyValue;
5088 wxString PropertyTokens;
5089 bool FirstToken = TRUE;
5090 int intSplitsFound = 0;
5091 int intSplitSize = 0;
5092 int intPrevValue = 7;
5096 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5100 PropertyType PropType = PROPERTY_NONE;
5102 // Look for type before continuing.
5104 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5108 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5109 intiter != SplitPoints.end(); ++intiter){
5111 SLiter = SplitLength.find(intiter->first);
5113 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5115 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5116 PropertyName = PropertyElement.GetNextToken();
5117 PropertyValue = PropertyElement.GetNextToken();
5119 intPrevValue = intiter->second;
5121 // Process properties.
5123 size_t intPropertyValueLen = PropertyValue.Len();
5125 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5127 PropertyValue.Trim();
5128 PropertyValue.RemoveLast();
5132 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5134 PropertyValue.Remove(0, 1);
5138 CaptureString(&PropertyValue, FALSE);
5140 if (PropertyName == wxT("ALTID")){
5142 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5143 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5145 } else if (PropertyName == wxT("PID")){
5147 FreeBusyListPID.erase(*FreeBusyAddressCount);
5148 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5150 } else if (PropertyName == wxT("PREF")){
5152 int PriorityNumber = 0;
5153 bool ValidNumber = TRUE;
5156 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5159 catch(std::invalid_argument &e){
5160 ValidNumber = FALSE;
5163 if (ValidNumber == TRUE){
5165 FreeBusyListPref.erase(*FreeBusyAddressCount);
5166 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5170 } else if (PropertyName == wxT("MEDIATYPE")){
5172 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5173 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5177 // Something else we don't know about so append
5178 // to the tokens variable.
5180 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5182 if (FirstToken == TRUE){
5184 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5189 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5199 intPropertyLen = PropertySeg2.Len();
5200 SplitPoints.clear();
5201 SplitLength.clear();
5206 CaptureString(&PropertySeg2, FALSE);
5208 // Add the data to the General/Home/Work address variables.
5214 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5217 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5221 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5223 if (!PropertyTokens.IsEmpty()){
5225 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5231 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5233 size_t intPropertyLen = PropertySeg1.Len();
5234 std::map<int, int> SplitPoints;
5235 std::map<int, int> SplitLength;
5236 std::map<int, int>::iterator SLiter;
5237 wxString PropertyData;
5238 wxString PropertyName;
5239 wxString PropertyValue;
5240 wxString PropertyTokens;
5241 bool FirstToken = TRUE;
5242 int intSplitsFound = 0;
5243 int intSplitSize = 0;
5244 int intPrevValue = 5;
5249 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5253 PropertyType PropType = PROPERTY_NONE;
5255 // Look for type before continuing.
5257 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5261 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5262 intiter != SplitPoints.end(); ++intiter){
5264 SLiter = SplitLength.find(intiter->first);
5266 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5268 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5269 PropertyName = PropertyElement.GetNextToken();
5270 PropertyValue = PropertyElement.GetNextToken();
5272 intPrevValue = intiter->second;
5274 // Process properties.
5276 size_t intPropertyValueLen = PropertyValue.Len();
5278 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5280 PropertyValue.Trim();
5281 PropertyValue.RemoveLast();
5285 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5287 PropertyValue.Remove(0, 1);
5291 if (PropertyName == wxT("ALTID")){
5293 KeyListAltID.erase(*KeyCount);
5294 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5296 } else if (PropertyName == wxT("PID")){
5298 KeyListPID.erase(*KeyCount);
5299 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5301 } else if (PropertyName == wxT("PREF")){
5303 int PriorityNumber = 0;
5304 bool ValidNumber = TRUE;
5307 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5310 catch(std::invalid_argument &e){
5311 ValidNumber = FALSE;
5314 if (ValidNumber == TRUE){
5316 KeyListPref.erase(*KeyCount);
5317 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5323 // Something else we don't know about so append
5324 // to the tokens variable.
5326 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5328 if (FirstToken == TRUE){
5330 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5335 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5345 intPropertyLen = PropertySeg2.Len();
5346 SplitPoints.clear();
5347 SplitLength.clear();
5352 for (int i = 0; i <= intPropertyLen; i++){
5356 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5359 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5361 if (intSplitsFound == 6){
5363 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5368 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5379 wxString wxSKeyMIME;
5380 wxString wxSKeyEncoding;
5381 wxString wxSKeyData;
5382 std::string base64enc;
5384 if (intSplitsFound == 0){
5388 std::map<int, int>::iterator striter;
5390 striter = SplitLength.find(1);
5392 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5394 while (wSTDataType.HasMoreTokens() == TRUE){
5396 wxSKeyURI = wSTDataType.GetNextToken();
5397 wxSKeyMIME = wSTDataType.GetNextToken();
5402 if (wxSKeyURI == wxT("data")){
5404 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5406 while (wSTDataInfo.HasMoreTokens() == TRUE){
5408 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5409 wxSKeyData = wSTDataInfo.GetNextToken();
5418 // Add the data to the General/Home/Work address variables.
5420 if (wxSKeyURI == wxT("data")){
5422 KeyListDataEncType.erase(*KeyCount);
5423 KeyListKeyType.erase(*KeyCount);
5424 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5425 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5427 KeyList.erase(*KeyCount);
5428 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5432 KeyList.erase(*KeyCount);
5433 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5437 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5443 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5446 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5450 if (!PropertyTokens.IsEmpty()){
5452 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5458 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5460 // Split the Vendor three ways.
5462 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5465 wxString wxSVNDPropName;
5468 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5470 wSTVendorDetails.GetNextToken();
5471 wxSVNDID = wSTVendorDetails.GetNextToken();
5472 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5477 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5479 // Add the data to the vendor variables.
5481 VendorList.erase(*VendorCount);
5482 VendorListPEN.erase(*VendorCount);
5483 VendorListElement.erase(*VendorCount);
5485 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5486 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5487 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5493 void SplitValues(wxString *PropertyLine,
5494 std::map<int,int> *SplitPoints,
5495 std::map<int,int> *SplitLength,
5498 size_t intPropertyLen = PropertyLine->Len();
5499 int intSplitsFound = 0;
5500 int intSplitSize = 0;
5501 int intSplitSeek = 0;
5503 for (int i = intSize; i <= intPropertyLen; i++){
5507 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5508 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5510 if (intSplitsFound == 0){
5512 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5516 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5520 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5530 if (intSplitsFound == 0){
5532 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5533 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5537 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5538 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5544 void CheckType(wxString *PropertySeg1,
5545 std::map<int,int> *SplitPoints,
5546 std::map<int,int> *SplitLength,
5548 PropertyType *PropType){
5550 wxString PropertyData;
5551 wxString PropertyName;
5552 wxString PropertyValue;
5553 std::map<int,int>::iterator SLiter;
5555 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5556 intiter != SplitPoints->end(); ++intiter){
5558 SLiter = SplitLength->find(intiter->first);
5560 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5562 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5563 PropertyName = PropertyElement.GetNextToken();
5564 PropertyValue = PropertyElement.GetNextToken();
5566 *intPrevValue = intiter->second;
5568 if (PropertyName == wxT("TYPE")){
5570 if (PropertyValue == wxT("work")){
5572 *PropType = PROPERTY_WORK;
5574 } else if (PropertyValue == wxT("home")){
5576 *PropType = PROPERTY_HOME;
5580 *PropType = PROPERTY_NONE;