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 int ContactLineLen = 0;
82 int QuoteBreakPoint = 0;
85 int NicknameCount = 0;
86 int TimeZoneCount = 0;
90 int TelephoneCount = 0;
91 int LanguageCount = 0;
92 int GeographicCount = 0;
97 int OrganisationCount = 0;
99 int CategoryCount = 0;
103 int CalendarCount = 0;
104 int CalendarAddressCount = 0;
105 int FreeBusyAddressCount = 0;
107 wxString ContactLine;
108 wxString PropertyLine;
109 wxString PropertySeg1;
110 wxString PropertySeg2;
111 wxString PropertyNextLine;
114 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
115 iter != ContactFileLines.end(); ++iter){
117 ExtraLineSeek = TRUE;
123 PropertyLine.Clear();
124 PropertySeg1.Clear();
125 PropertySeg2.Clear();
128 ContactLine = iter->second;
130 while (ExtraLineSeek == TRUE){
132 // Check if there is extra data on the next line
133 // (indicated by space or tab at the start) and add data.
137 if (iter == ContactFileLines.end()){
144 PropertyNextLine = iter->second;
146 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
148 PropertyNextLine.Remove(0, 1);
149 ContactLine.Append(PropertyNextLine);
154 ExtraLineSeek = FALSE;
160 ContactLineLen = ContactLine.Len();
162 // Make sure we are not in quotation mode.
163 // Make sure colon does not have \ or \\ before it.
165 for (int i = 0; i <= ContactLineLen; i++){
167 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
169 PropertyFind = FALSE;
171 } else if (PropertyFind == TRUE){
173 Property.Append(ContactLine.Mid(i, 1));
177 if (ContactLine.Mid(i, 1) == wxT("\"")){
179 if (QuoteMode == TRUE){
191 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
200 // Split that line at the point into two variables (ignore the colon).
202 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
203 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
205 if (Property == wxT("KIND") && KindProcessed == FALSE){
207 ProcessKind(PropertySeg2);
209 } else if (Property == wxT("MEMBER")){
211 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
214 } else if (Property == wxT("FN")){
216 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
219 } else if (Property == wxT("N") && NameProcessed == FALSE){
221 ProcessN(PropertySeg1, PropertySeg2);
222 NameProcessed = TRUE;
224 } else if (Property == wxT("NICKNAME")){
226 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
229 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
231 ProcessGender(PropertySeg1, PropertySeg2);
232 GenderProcessed = TRUE;
234 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
236 ProcessBirthday(PropertySeg1, PropertySeg2);
237 BirthdayProcessed = TRUE;
239 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
241 ProcessAnniversary(PropertySeg1, PropertySeg2);
242 AnniversaryProcessed = TRUE;
244 } else if (Property == wxT("TZ")){
246 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
249 } else if (Property == wxT("ADR")){
251 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
254 } else if (Property == wxT("EMAIL")){
256 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
259 } else if (Property == wxT("IMPP")){
261 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
264 } else if (Property == wxT("TEL")){
266 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
269 } else if (Property == wxT("LANG")){
271 // See frmContactEditor-LoadLanguage.cpp
273 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
276 } else if (Property == wxT("GEO")){
278 // See frmContactEditor-LoadGeo.cpp
280 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
283 } else if (Property == wxT("RELATED")){
285 // See fromContactEditor-LoadRelated.cpp
287 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
290 } else if (Property == wxT("URL")){
292 // See frmContactEditor-LoadURL.cpp
294 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
297 } else if (Property == wxT("TITLE")) {
299 // See frmContactEditor-LoadTitle.cpp
301 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
304 } else if (Property == wxT("ROLE")) {
306 // See frmContactEditor-LoadTitle.cpp
308 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
311 } else if (Property == wxT("ORG")) {
313 // See frmContactEditor-LoadOrg.cpp
315 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
318 } else if (Property == wxT("NOTE")) {
320 // See frmContactEditor-LoadNote.cpp
322 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
325 } else if (Property == wxT("CATEGORIES")) {
327 // See frmContactEditor-LoadCategory.cpp
329 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
332 } else if (Property == wxT("PHOTO")) {
334 // See frmContactEditor-LoadPhoto.cpp
336 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
339 } else if (Property == wxT("LOGO")) {
341 // See frmContactEditor-LoadPhoto.cpp
343 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
346 } else if (Property == wxT("LOGO")) {
348 // See frmContactEditor-LoadPhoto.cpp
350 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
353 } else if (Property == wxT("SOUND")) {
355 // See frmContactEditor-LoadSound.cpp
357 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
360 } else if (Property == wxT("CALURI")){
362 // See frmContactEditor-LoadCalendar.cpp
364 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
367 } else if (Property == wxT("CALADRURI")){
369 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
370 CalendarAddressCount++;
372 } else if (Property == wxT("FBURL")){
374 // See frmContactEditor-LoadCalendar.cpp
376 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
377 FreeBusyAddressCount++;
379 } else if (Property == wxT("KEY")){
381 // See frmContactEditor-LoadKey.cpp
383 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
390 return CONTACTLOAD_OK;
394 void ContactDataObject::ProcessKind(wxString KindType){
396 if (KindType == wxT("individual")){
398 ContactKind = CONTACTKIND_INDIVIDUAL;
400 } else if (KindType == wxT("group")){
402 ContactKind = CONTACTKIND_GROUP;
404 } else if (KindType == wxT("org")){
406 ContactKind = CONTACTKIND_ORGANISATION;
408 } else if (KindType == wxT("location")){
410 ContactKind = CONTACTKIND_LOCATION;
414 ContactKind = CONTACTKIND_NONE;
419 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
421 std::map<int, int> SplitPoints;
422 std::map<int, int> SplitLength;
424 int intPrevValue = 8;
428 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
432 wxString PropertyName;
433 wxString PropertyValue;
434 wxString PropertyData;
435 wxString PropertyTokens;
436 std::map<int,int>::iterator SLiter;
437 bool FirstToken = TRUE;
439 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
440 intiter != SplitPoints.end(); ++intiter){
442 SLiter = SplitLength.find(intiter->first);
444 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
446 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
447 PropertyName = PropertyElement.GetNextToken();
448 PropertyValue = PropertyElement.GetNextToken();
450 intPrevValue = intiter->second;
452 CaptureString(&PropertyValue, FALSE);
454 if (PropertyName == wxT("ALTID")){
456 GroupsListAltID.erase(*GroupCount);
457 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
459 } else if (PropertyName == wxT("PID")){
461 GroupsListPID.erase(*GroupCount);
462 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
464 } else if (PropertyName == wxT("PREF")){
466 int PriorityNumber = 0;
467 bool ValidNumber = TRUE;
470 PriorityNumber = std::stoi(PropertyValue.ToStdString());
473 catch(std::invalid_argument &e){
477 if (ValidNumber == TRUE){
479 GroupsListPref.erase(*GroupCount);
480 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
484 } else if (PropertyName == wxT("MEDIATYPE")){
486 GroupsListMediaType.erase(*GroupCount);
487 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
489 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
491 if (FirstToken == TRUE){
493 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
498 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
506 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
508 if (!PropertyTokens.IsEmpty()){
510 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
517 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
519 std::map<int, int> SplitPoints;
520 std::map<int, int> SplitLength;
522 int intPrevValue = 4;
526 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
530 wxString PropertyName;
531 wxString PropertyValue;
532 wxString PropertyData;
533 wxString PropertyTokens;
534 std::map<int,int>::iterator SLiter;
535 bool FirstToken = TRUE;
537 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
538 intiter != SplitPoints.end(); ++intiter){
540 SLiter = SplitLength.find(intiter->first);
542 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
544 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
545 PropertyName = PropertyElement.GetNextToken();
546 PropertyValue = PropertyElement.GetNextToken();
548 intPrevValue = intiter->second;
550 CaptureString(&PropertyValue, FALSE);
552 if (PropertyName == wxT("TYPE")){
554 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
555 PropertyValue == wxT("work") ){
557 FullNamesListType.erase(*FNCount);
558 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
562 } else if (PropertyName == wxT("LANGUAGE")){
564 FullNamesListLanguage.erase(*FNCount);
565 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
567 } else if (PropertyName == wxT("ALTID")){
569 FullNamesListAltID.erase(*FNCount);
570 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
572 } else if (PropertyName == wxT("PID")){
574 FullNamesListPID.erase(*FNCount);
575 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
577 } else if (PropertyName == wxT("PREF")){
579 int PriorityNumber = 0;
580 bool ValidNumber = TRUE;
583 PriorityNumber = std::stoi(PropertyValue.ToStdString());
586 catch(std::invalid_argument &e){
590 if (ValidNumber == TRUE){
592 FullNamesListPref.erase(*FNCount);
593 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
597 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
599 if (FirstToken == TRUE){
601 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
606 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
614 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
616 if (!PropertyTokens.IsEmpty()){
618 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
624 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
626 std::map<int, int> SplitPoints;
627 std::map<int, int> SplitLength;
629 int intPrevValue = 3;
633 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
637 wxString PropertyName;
638 wxString PropertyValue;
639 wxString PropertyData;
640 wxString PropertyTokens;
641 std::map<int,int>::iterator SLiter;
642 bool FirstToken = TRUE;
644 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
645 intiter != SplitPoints.end(); ++intiter){
647 SLiter = SplitLength.find(intiter->first);
649 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
651 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
652 PropertyName = PropertyElement.GetNextToken();
653 PropertyValue = PropertyElement.GetNextToken();
655 intPrevValue = intiter->second;
657 CaptureString(&PropertyValue, FALSE);
659 if (PropertyName == wxT("ALTID")){
661 NameAltID = PropertyValue;
663 } else if (PropertyName == wxT("LANGUAGE")){
665 NameLanguage = PropertyValue;
667 } else if (PropertyName == wxT("SORT-AS")){
669 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
670 PropertyValue.Len() >= 3){
671 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
674 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
676 if (FirstToken == TRUE){
678 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
683 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
691 // Split the name data.
693 int intSplitSeek = 0;
694 int intSplitsFound = 0;
695 int intSplitSize = 0;
696 int intPropertyLen = PropertySeg2.Len();
698 std::map<int,wxString> NameValues;
701 for (int i = 0; i <= intPropertyLen; i++){
703 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
705 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
710 if (intSplitsFound == 4){
712 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
726 // Split the data into several parts.
728 for (std::map<int, wxString>::iterator iter = NameValues.begin();
729 iter != NameValues.end(); ++iter){
731 if (iter->first == 1){
733 // Deal with family name.
735 NameSurname = iter->second;
737 } else if (iter->first == 2){
739 // Deal with given names.
741 NameForename = iter->second;
743 } else if (iter->first == 3){
745 // Deal with additional names.
747 NameOtherNames = iter->second;
749 } else if (iter->first == 4){
751 // Deal with honorifix prefixes and suffixes.
753 NameTitle = iter->second;
757 if (iter == NameValues.end()){
763 NameSuffix = iter->second;
769 // Add the name token data.
771 if (!PropertyTokens.IsEmpty()){
773 NameTokens = PropertyTokens;
779 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
781 std::map<int, int> SplitPoints;
782 std::map<int, int> SplitLength;
784 int intPrevValue = 10;
787 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
791 PropertyType PropType = PROPERTY_NONE;
793 // Look for type before continuing.
795 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
799 std::map<int, wxString> *NicknamesList = NULL;
800 std::map<int, wxString> *NicknamesListType = NULL;
801 std::map<int, wxString> *NicknamesListLanguage = NULL;
802 std::map<int, wxString> *NicknamesListAltID = NULL;
803 std::map<int, wxString> *NicknamesListPID = NULL;
804 std::map<int, wxString> *NicknamesListTokens = NULL;
805 std::map<int, int> *NicknamesListPref = NULL;
809 NicknamesList = &GeneralNicknamesList;
810 NicknamesListType = &GeneralNicknamesListType;
811 NicknamesListLanguage = &GeneralNicknamesListLanguage;
812 NicknamesListAltID = &GeneralNicknamesListAltID;
813 NicknamesListPID = &GeneralNicknamesListPID;
814 NicknamesListTokens = &GeneralNicknamesListTokens;
815 NicknamesListPref = &GeneralNicknamesListPref;
818 NicknamesList = &HomeNicknamesList;
819 NicknamesListType = &HomeNicknamesListType;
820 NicknamesListLanguage = &HomeNicknamesListLanguage;
821 NicknamesListAltID = &HomeNicknamesListAltID;
822 NicknamesListPID = &HomeNicknamesListPID;
823 NicknamesListTokens = &HomeNicknamesListTokens;
824 NicknamesListPref = &HomeNicknamesListPref;
827 NicknamesList = &BusinessNicknamesList;
828 NicknamesListType = &BusinessNicknamesListType;
829 NicknamesListLanguage = &BusinessNicknamesListLanguage;
830 NicknamesListAltID = &BusinessNicknamesListAltID;
831 NicknamesListPID = &BusinessNicknamesListPID;
832 NicknamesListTokens = &BusinessNicknamesListTokens;
833 NicknamesListPref = &BusinessNicknamesListPref;
837 std::map<int, int>::iterator SLiter;
838 wxString PropertyData;
839 wxString PropertyName;
840 wxString PropertyValue;
841 wxString PropertyTokens;
842 bool FirstToken = TRUE;
844 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
845 intiter != SplitPoints.end(); ++intiter){
847 SLiter = SplitLength.find(intiter->first);
849 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
851 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
852 PropertyName = PropertyElement.GetNextToken();
853 PropertyValue = PropertyElement.GetNextToken();
855 intPrevValue = intiter->second;
857 CaptureString(&PropertyValue, FALSE);
859 if (PropertyName == wxT("ALTID")){
861 NicknamesListAltID->erase(*NicknameCount);
862 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
864 } else if (PropertyName == wxT("PID")){
866 NicknamesListPID->erase(*NicknameCount);
867 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
869 } else if (PropertyName == wxT("PREF")){
871 int PriorityNumber = 0;
872 bool ValidNumber = TRUE;
875 PriorityNumber = std::stoi(PropertyValue.ToStdString());
878 catch(std::invalid_argument &e){
882 if (ValidNumber == TRUE){
884 NicknamesListPref->erase(*NicknameCount);
885 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
889 } else if (PropertyName == wxT("LANGUAGE")){
891 NicknamesListLanguage->erase(*NicknameCount);
892 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
896 // Something else we don't know about so append
897 // to the tokens variable.
899 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
901 if (FirstToken == TRUE){
903 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
908 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
918 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
920 // Add the name token data.
922 if (!PropertyTokens.IsEmpty()){
924 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
930 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
932 std::map<int, int> SplitPoints;
933 std::map<int, int> SplitLength;
934 std::map<int, int>::iterator SLiter;
935 wxString PropertyData;
936 wxString PropertyName;
937 wxString PropertyValue;
938 wxString PropertyTokens;
939 bool FirstToken = TRUE;
940 int intPrevValue = 8;
942 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
946 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
947 intiter != SplitPoints.end(); ++intiter){
949 SLiter = SplitLength.find(intiter->first);
951 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
953 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
954 PropertyName = PropertyElement.GetNextToken();
955 PropertyValue = PropertyElement.GetNextToken();
957 intPrevValue = intiter->second;
959 // Process properties.
961 size_t intPropertyValueLen = PropertyValue.Len();
963 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
965 PropertyValue.Trim();
966 PropertyValue.RemoveLast();
970 if (PropertyValue.Mid(0, 1) == wxT("\"")){
972 PropertyValue.Remove(0, 1);
976 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
978 if (FirstToken == TRUE){
980 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
985 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
993 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
995 wxString GenderComponent;
997 if (GenderData.CountTokens() >= 2){
999 Gender = GenderData.GetNextToken();
1000 GenderDetails = GenderData.GetString();
1002 CaptureString(&GenderDetails, FALSE);
1006 Gender = GenderData.GetNextToken();
1010 if (!PropertyTokens.IsEmpty()){
1012 GenderTokens = PropertyTokens;
1018 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1020 // Process date. Preserve the remainder in the string.
1022 std::map<int, int> SplitPoints;
1023 std::map<int, int> SplitLength;
1024 std::map<int, int>::iterator SLiter;
1025 wxString PropertyData;
1026 wxString PropertyName;
1027 wxString PropertyValue;
1028 wxString PropertyTokens;
1029 bool BirthdayText = FALSE;
1030 int intPrevValue = 6;
1032 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1036 // Look for type before continuing.
1038 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1039 intiter != SplitPoints.end(); ++intiter){
1041 SLiter = SplitLength.find(intiter->first);
1043 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1045 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1046 PropertyName = PropertyElement.GetNextToken();
1047 PropertyValue = PropertyElement.GetNextToken();
1049 intPrevValue = intiter->second;
1051 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1053 CaptureString(&PropertySeg2, FALSE);
1054 Birthday = PropertySeg2;
1055 BirthdayText = TRUE;
1061 // Setup blank lines for later on.
1064 bool FirstToken = TRUE;
1066 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1067 intiter != SplitPoints.end(); ++intiter){
1069 SLiter = SplitLength.find(intiter->first);
1071 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1073 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1074 PropertyName = PropertyElement.GetNextToken();
1075 PropertyValue = PropertyElement.GetNextToken();
1077 intPrevValue = intiter->second;
1079 // Process properties.
1081 CaptureString(&PropertyValue, FALSE);
1083 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1085 PropertyValue.Trim();
1086 PropertyValue.RemoveLast();
1090 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1092 PropertyValue.Remove(0, 1);
1096 if (PropertyName == wxT("ALTID")){
1098 BirthdayAltID = PropertyValue;
1100 } else if (PropertyName == wxT("CALSCALE")){
1102 BirthdayCalScale = PropertyValue;
1104 } else if (PropertyName != wxT("VALUE")) {
1106 // Something else we don't know about so append
1107 // to the tokens variable.
1109 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1111 if (FirstToken == TRUE){
1113 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1118 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1128 // Add the data to the variables and form.
1130 if (BirthdayText == FALSE){
1132 Birthday = PropertySeg2;
1136 if (!PropertyTokens.IsEmpty()){
1138 BirthdayTokens = PropertyTokens;
1144 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1146 // Process date. Preserve the remainder in the string.
1148 std::map<int, int> SplitPoints;
1149 std::map<int, int> SplitLength;
1150 std::map<int, int>::iterator SLiter;
1151 wxString PropertyData;
1152 wxString PropertyName;
1153 wxString PropertyValue;
1154 wxString PropertyTokens;
1155 bool AnniversaryText = FALSE;
1156 int intPrevValue = 13;
1158 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1162 // Look for type before continuing.
1164 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1165 intiter != SplitPoints.end(); ++intiter){
1167 SLiter = SplitLength.find(intiter->first);
1169 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1171 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1172 PropertyName = PropertyElement.GetNextToken();
1173 PropertyValue = PropertyElement.GetNextToken();
1175 intPrevValue = intiter->second;
1177 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1179 CaptureString(&PropertySeg2, FALSE);
1180 Anniversary = PropertySeg2;
1181 AnniversaryText = TRUE;
1187 // Setup blank lines for later on.
1190 bool FirstToken = TRUE;
1192 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1193 intiter != SplitPoints.end(); ++intiter){
1195 SLiter = SplitLength.find(intiter->first);
1197 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1199 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1200 PropertyName = PropertyElement.GetNextToken();
1201 PropertyValue = PropertyElement.GetNextToken();
1203 intPrevValue = intiter->second;
1205 // Process properties.
1207 CaptureString(&PropertyValue, FALSE);
1209 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1211 PropertyValue.Trim();
1212 PropertyValue.RemoveLast();
1216 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1218 PropertyValue.Remove(0, 1);
1222 if (PropertyName == wxT("ALTID")){
1224 AnniversaryAltID = PropertyValue;
1226 } else if (PropertyName == wxT("CALSCALE")){
1228 AnniversaryCalScale = PropertyValue;
1230 } else if (PropertyName != wxT("VALUE")) {
1232 // Something else we don't know about so append
1233 // to the tokens variable.
1235 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1237 if (FirstToken == TRUE){
1239 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1244 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1254 // Add the data to the variables and form.
1256 if (AnniversaryText == FALSE){
1258 Anniversary = PropertySeg2;
1262 if (!PropertyTokens.IsEmpty()){
1264 AnniversaryTokens = PropertyTokens;
1270 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1272 std::map<int, int> SplitPoints;
1273 std::map<int, int> SplitLength;
1275 int intPrevValue = 4;
1278 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1282 PropertyType PropType = PROPERTY_NONE;
1284 // Look for type before continuing.
1286 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1290 std::map<int, wxString> *TZList = NULL;
1291 std::map<int, wxString> *TZListType = NULL;
1292 std::map<int, wxString> *TZListMediatype = NULL;
1293 std::map<int, wxString> *TZListAltID = NULL;
1294 std::map<int, wxString> *TZListPID = NULL;
1295 std::map<int, wxString> *TZListTokens = NULL;
1296 std::map<int, int> *TZListPref = NULL;
1300 TZList = &GeneralTZList;
1301 TZListType = &GeneralTZListType;
1302 TZListMediatype = &GeneralTZListMediatype;
1303 TZListAltID = &GeneralTZListAltID;
1304 TZListPID = &GeneralTZListPID;
1305 TZListTokens = &GeneralTZListTokens;
1306 TZListPref = &GeneralTZListPref;
1309 TZList = &HomeTZList;
1310 TZListType = &HomeTZListType;
1311 TZListMediatype = &HomeTZListMediatype;
1312 TZListAltID = &HomeTZListAltID;
1313 TZListPID = &HomeTZListPID;
1314 TZListTokens = &HomeTZListTokens;
1315 TZListPref = &HomeTZListPref;
1318 TZList = &BusinessTZList;
1319 TZListType = &BusinessTZListType;
1320 TZListMediatype = &BusinessTZListMediatype;
1321 TZListAltID = &BusinessTZListAltID;
1322 TZListPID = &BusinessTZListPID;
1323 TZListTokens = &BusinessTZListTokens;
1324 TZListPref = &BusinessTZListPref;
1328 std::map<int, int>::iterator SLiter;
1329 wxString PropertyData;
1330 wxString PropertyName;
1331 wxString PropertyValue;
1332 wxString PropertyTokens;
1333 bool FirstToken = TRUE;
1335 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1336 intiter != SplitPoints.end(); ++intiter){
1338 SLiter = SplitLength.find(intiter->first);
1340 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1342 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1343 PropertyName = PropertyElement.GetNextToken();
1344 PropertyValue = PropertyElement.GetNextToken();
1346 intPrevValue = intiter->second;
1348 CaptureString(&PropertyValue, FALSE);
1350 if (PropertyName == wxT("ALTID")){
1352 TZListAltID->erase(*TimeZoneCount);
1353 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1355 } else if (PropertyName == wxT("PID")){
1357 TZListPID->erase(*TimeZoneCount);
1358 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1360 } else if (PropertyName == wxT("PREF")){
1362 int PriorityNumber = 0;
1363 bool ValidNumber = TRUE;
1366 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1369 catch(std::invalid_argument &e){
1370 ValidNumber = FALSE;
1373 if (ValidNumber == TRUE){
1375 TZListPref->erase(*TimeZoneCount);
1376 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1380 } else if (PropertyName == wxT("MEDIATYPE")){
1382 TZListMediatype->erase(*TimeZoneCount);
1383 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1387 // Something else we don't know about so append
1388 // to the tokens variable.
1390 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1392 if (FirstToken == TRUE){
1394 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1399 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1409 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1411 // Add the name token data.
1413 if (!PropertyTokens.IsEmpty()){
1415 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1422 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1424 size_t intPropertyLen = PropertySeg1.Len();
1425 std::map<int, int> SplitPoints;
1426 std::map<int, int> SplitLength;
1427 std::map<int, int>::iterator SLiter;
1428 wxString PropertyData;
1429 wxString PropertyName;
1430 wxString PropertyValue;
1431 wxString PropertyTokens;
1432 wxString AddressLabel;
1433 wxString AddressLang;
1434 wxString AddressAltID;
1435 wxString AddressPID;
1436 wxString AddressTokens;
1437 wxString AddressGeo;
1438 wxString AddressTimezone;
1439 wxString AddressType;
1440 wxString AddressMediatype;
1441 wxString AddressPOBox;
1442 wxString AddressExtended;
1443 wxString AddressStreet;
1444 wxString AddressLocality;
1445 wxString AddressCity;
1446 wxString AddressRegion;
1447 wxString AddressPostalCode;
1448 wxString AddressCountry;
1449 bool FirstToken = TRUE;
1450 int intSplitsFound = 0;
1451 int intSplitSize = 0;
1452 int intPrevValue = 5;
1457 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1461 PropertyType PropType = PROPERTY_NONE;
1463 // Look for type before continuing.
1465 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1469 std::map<int, wxString> *AddressList = NULL;
1470 std::map<int, wxString> *AddressListTown = NULL;
1471 std::map<int, wxString> *AddressListCounty = NULL;
1472 std::map<int, wxString> *AddressListPostCode = NULL;
1473 std::map<int, wxString> *AddressListCountry = NULL;
1474 std::map<int, wxString> *AddressListLabel = NULL;
1475 std::map<int, wxString> *AddressListLang = NULL;
1476 std::map<int, wxString> *AddressListAltID = NULL;
1477 std::map<int, wxString> *AddressListPID = NULL;
1478 std::map<int, wxString> *AddressListTokens = NULL;
1479 std::map<int, wxString> *AddressListGeo = NULL;
1480 std::map<int, wxString> *AddressListTimezone = NULL;
1481 std::map<int, wxString> *AddressListType = NULL;
1482 std::map<int, wxString> *AddressListMediatype = NULL;
1483 std::map<int, int> *AddressListPref = NULL;
1487 AddressList = &GeneralAddressList;
1488 AddressListTown = &GeneralAddressListTown;
1489 AddressListCounty = &GeneralAddressListCounty;
1490 AddressListPostCode = &GeneralAddressListPostCode;
1491 AddressListCountry = &GeneralAddressListCountry;
1492 AddressListLabel = &GeneralAddressListLabel;
1493 AddressListLang = &GeneralAddressListLang;
1494 AddressListAltID = &GeneralAddressListAltID;
1495 AddressListPID = &GeneralAddressListPID;
1496 AddressListTokens = &GeneralAddressListTokens;
1497 AddressListGeo = &GeneralAddressListGeo;
1498 AddressListTimezone = &GeneralAddressListTimezone;
1499 AddressListType = &GeneralAddressListType;
1500 AddressListMediatype = &GeneralAddressListMediatype;
1501 AddressListPref = &GeneralAddressListPref;
1504 AddressList = &HomeAddressList;
1505 AddressListTown = &HomeAddressListTown;
1506 AddressListCounty = &HomeAddressListCounty;
1507 AddressListPostCode = &HomeAddressListPostCode;
1508 AddressListCountry = &HomeAddressListCountry;
1509 AddressListLabel = &HomeAddressListLabel;
1510 AddressListLang = &HomeAddressListLang;
1511 AddressListAltID = &HomeAddressListAltID;
1512 AddressListPID = &HomeAddressListPID;
1513 AddressListTokens = &HomeAddressListTokens;
1514 AddressListGeo = &HomeAddressListGeo;
1515 AddressListTimezone = &HomeAddressListTimezone;
1516 AddressListType = &HomeAddressListType;
1517 AddressListMediatype = &HomeAddressListMediatype;
1518 AddressListPref = &HomeAddressListPref;
1521 AddressList = &BusinessAddressList;
1522 AddressListTown = &BusinessAddressListTown;
1523 AddressListCounty = &BusinessAddressListCounty;
1524 AddressListPostCode = &BusinessAddressListPostCode;
1525 AddressListCountry = &BusinessAddressListCountry;
1526 AddressListLabel = &BusinessAddressListLabel;
1527 AddressListLang = &BusinessAddressListLang;
1528 AddressListAltID = &BusinessAddressListAltID;
1529 AddressListPID = &BusinessAddressListPID;
1530 AddressListTokens = &BusinessAddressListTokens;
1531 AddressListGeo = &BusinessAddressListGeo;
1532 AddressListTimezone = &BusinessAddressListTimezone;
1533 AddressListType = &BusinessAddressListType;
1534 AddressListMediatype = &BusinessAddressListMediatype;
1535 AddressListPref = &BusinessAddressListPref;
1541 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1542 intiter != SplitPoints.end(); ++intiter){
1544 SLiter = SplitLength.find(intiter->first);
1546 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1548 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1549 PropertyName = PropertyElement.GetNextToken();
1550 PropertyValue = PropertyElement.GetNextToken();
1552 intPrevValue = intiter->second;
1554 CaptureString(&PropertyValue, FALSE);
1556 // Process properties.
1558 if (PropertyName == wxT("LABEL")){
1560 AddressListLabel->erase(*AddressCount);
1561 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1563 } else if (PropertyName == wxT("LANGUAGE")){
1565 AddressListLang->erase(*AddressCount);
1566 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1568 } else if (PropertyName == wxT("ALTID")){
1570 AddressListAltID->erase(*AddressCount);
1571 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1573 } else if (PropertyName == wxT("PID")){
1575 AddressListPID->erase(*AddressCount);
1576 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1578 } else if (PropertyName == wxT("GEO")){
1580 AddressListGeo->erase(*AddressCount);
1581 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1583 } else if (PropertyName == wxT("TZ")){
1585 AddressListTimezone->erase(*AddressCount);
1586 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1588 } else if (PropertyName == wxT("MEDIATYPE")){
1590 AddressListMediatype->erase(*AddressCount);
1591 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1593 } else if (PropertyName == wxT("PREF")){
1595 int PriorityNumber = 0;
1596 bool ValidNumber = TRUE;
1599 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1602 catch(std::invalid_argument &e){
1603 ValidNumber = FALSE;
1606 if (ValidNumber == TRUE){
1608 AddressListPref->erase(*AddressCount);
1609 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1615 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1617 if (FirstToken == TRUE){
1619 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1624 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1634 // Split the address.
1636 //std::map<int, int>::iterator SLiter;
1637 intPropertyLen = PropertySeg2.Len();
1638 SplitPoints.clear();
1639 SplitLength.clear();
1644 for (int i = 0; i <= intPropertyLen; i++){
1648 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1651 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1653 if (intSplitsFound == 6){
1655 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1660 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1670 // Split the data into several parts.
1672 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1673 intiter != SplitPoints.end(); ++intiter){
1675 if (intiter->first == 1){
1677 // Deal with PO Box.
1679 SLiter = SplitLength.find(1);
1681 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1682 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1683 intPrevValue = intiter->second;
1685 } else if (intiter->first == 2){
1687 // Deal with extended address.
1689 SLiter = SplitLength.find(2);
1691 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1692 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1693 intPrevValue = intiter->second;
1695 } else if (intiter->first == 3){
1697 // Deal with street address.
1699 SLiter = SplitLength.find(3);
1701 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1702 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1703 intPrevValue = intiter->second;
1705 } else if (intiter->first == 4){
1707 // Deal with locality
1709 SLiter = SplitLength.find(4);
1711 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1712 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1713 intPrevValue = intiter->second;
1715 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1717 } else if (intiter->first == 5){
1719 // Deal with region.
1721 SLiter = SplitLength.find(5);
1723 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1724 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1725 intPrevValue = intiter->second;
1727 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1729 } else if (intiter->first == 6){
1731 // Deal with post code.
1733 SLiter = SplitLength.find(6);
1735 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1736 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1737 intPrevValue = intiter->second;
1739 // Deal with country.
1741 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1742 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1750 // Add the data to the General/Home/Work address variables.
1752 CaptureString(&AddressStreet, FALSE);
1753 CaptureString(&AddressLocality, FALSE);
1754 CaptureString(&AddressRegion, FALSE);
1755 CaptureString(&AddressPostalCode, FALSE);
1756 CaptureString(&AddressCountry, FALSE);
1758 if (!PropertyTokens.IsEmpty()){
1760 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1764 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1765 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1766 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1767 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1768 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1772 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1775 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1778 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1782 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1786 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1788 std::map<int, int> SplitPoints;
1789 std::map<int, int> SplitLength;
1791 int intPrevValue = 7;
1794 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1798 PropertyType PropType = PROPERTY_NONE;
1800 // Look for type before continuing.
1802 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1804 std::map<int, wxString> *EmailList = NULL;
1805 std::map<int, wxString> *EmailListType = NULL;
1806 std::map<int, wxString> *EmailListAltID = NULL;
1807 std::map<int, wxString> *EmailListPID = NULL;
1808 std::map<int, wxString> *EmailListTokens = NULL;
1809 std::map<int, int> *EmailListPref = NULL;
1813 EmailList = &GeneralEmailList;
1814 EmailListType = &GeneralEmailListType;
1815 EmailListAltID = &GeneralEmailListAltID;
1816 EmailListPID = &GeneralEmailListPID;
1817 EmailListTokens = &GeneralEmailListTokens;
1818 EmailListPref = &GeneralEmailListPref;
1821 EmailList = &HomeEmailList;
1822 EmailListType = &HomeEmailListType;
1823 EmailListAltID = &HomeEmailListAltID;
1824 EmailListPID = &HomeEmailListPID;
1825 EmailListTokens = &HomeEmailListTokens;
1826 EmailListPref = &HomeEmailListPref;
1829 EmailList = &BusinessEmailList;
1830 EmailListType = &BusinessEmailListType;
1831 EmailListAltID = &BusinessEmailListAltID;
1832 EmailListPID = &BusinessEmailListPID;
1833 EmailListTokens = &BusinessEmailListTokens;
1834 EmailListPref = &BusinessEmailListPref;
1840 std::map<int,int>::iterator SLiter;
1841 wxString PropertyData;
1842 wxString PropertyName;
1843 wxString PropertyValue;
1844 wxString PropertyTokens;
1845 bool FirstToken = TRUE;
1847 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1848 intiter != SplitPoints.end(); ++intiter){
1850 SLiter = SplitLength.find(intiter->first);
1852 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1854 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1855 PropertyName = PropertyElement.GetNextToken();
1856 PropertyValue = PropertyElement.GetNextToken();
1858 intPrevValue = intiter->second;
1860 CaptureString(&PropertyValue, FALSE);
1862 // Process properties.
1864 if (PropertyName == wxT("ALTID")){
1866 EmailListAltID->erase(*EmailCount);
1867 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1869 } else if (PropertyName == wxT("PID")){
1871 EmailListPID->erase(*EmailCount);
1872 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1874 } else if (PropertyName == wxT("PREF")){
1876 int PriorityNumber = 0;
1877 bool ValidNumber = TRUE;
1880 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1883 catch(std::invalid_argument &e){
1884 ValidNumber = FALSE;
1887 if (ValidNumber == TRUE){
1889 EmailListPref->erase(*EmailCount);
1890 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1896 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1898 if (FirstToken == TRUE){
1900 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1905 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1915 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1917 // Add the name token data.
1919 if (!PropertyTokens.IsEmpty()){
1921 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1928 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1930 std::map<int, int> SplitPoints;
1931 std::map<int, int> SplitLength;
1933 int intPrevValue = 6;
1936 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1940 PropertyType PropType = PROPERTY_NONE;
1942 // Look for type before continuing.
1944 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1946 std::map<int, wxString> *IMList = NULL;
1947 std::map<int, wxString> *IMListType = NULL;
1948 std::map<int, wxString> *IMListAltID = NULL;
1949 std::map<int, wxString> *IMListPID = NULL;
1950 std::map<int, wxString> *IMListTokens = NULL;
1951 std::map<int, wxString> *IMListMediatype = NULL;
1952 std::map<int, int> *IMListPref = NULL;
1956 IMList = &GeneralIMList;
1957 IMListType = &GeneralIMListType;
1958 IMListAltID = &GeneralIMListAltID;
1959 IMListPID = &GeneralIMListPID;
1960 IMListTokens = &GeneralIMListTokens;
1961 IMListMediatype = &GeneralIMListMediatype;
1962 IMListPref = &GeneralIMListPref;
1965 IMList = &HomeIMList;
1966 IMListType = &HomeIMListType;
1967 IMListAltID = &HomeIMListAltID;
1968 IMListPID = &HomeIMListPID;
1969 IMListTokens = &HomeIMListTokens;
1970 IMListMediatype = &HomeIMListMediatype;
1971 IMListPref = &HomeIMListPref;
1974 IMList = &BusinessIMList;
1975 IMListType = &BusinessIMListType;
1976 IMListAltID = &BusinessIMListAltID;
1977 IMListPID = &BusinessIMListPID;
1978 IMListTokens = &BusinessIMListTokens;
1979 IMListMediatype = &BusinessIMListMediatype;
1980 IMListPref = &BusinessIMListPref;
1986 std::map<int,int>::iterator SLiter;
1987 wxString PropertyData;
1988 wxString PropertyName;
1989 wxString PropertyValue;
1990 wxString PropertyTokens;
1991 bool FirstToken = TRUE;
1993 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1994 intiter != SplitPoints.end(); ++intiter){
1996 SLiter = SplitLength.find(intiter->first);
1998 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2000 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2001 PropertyName = PropertyElement.GetNextToken();
2002 PropertyValue = PropertyElement.GetNextToken();
2004 intPrevValue = intiter->second;
2006 CaptureString(&PropertyValue, FALSE);
2008 // Process properties.
2010 if (PropertyName == wxT("ALTID")){
2012 IMListAltID->erase(*IMCount);
2013 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2015 } else if (PropertyName == wxT("PID")){
2017 IMListPID->erase(*IMCount);
2018 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2020 } else if (PropertyName == wxT("MEDIATYPE")){
2022 IMListMediatype->erase(*IMCount);
2023 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2025 } else if (PropertyName == wxT("PREF")){
2027 int PriorityNumber = 0;
2028 bool ValidNumber = TRUE;
2031 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2034 catch(std::invalid_argument &e){
2035 ValidNumber = FALSE;
2038 if (ValidNumber == TRUE){
2040 IMListPref->erase(*IMCount);
2041 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2047 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2049 if (FirstToken == TRUE){
2051 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2056 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2066 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2068 // Add the name token data.
2070 if (!PropertyTokens.IsEmpty()){
2072 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2078 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2080 std::map<int, int> SplitPoints;
2081 std::map<int, int> SplitLength;
2082 std::map<int, int>::iterator SLiter;
2086 PropertyType PropType = PROPERTY_NONE;
2088 // Look for type before continuing.
2091 wxString TelTypeDetail;
2092 wxString PropertyData;
2093 wxString PropertyName;
2094 wxString PropertyValue;
2095 wxString PropertyTokens;
2097 std::map<int,int> TypeSplitPoints;
2098 std::map<int,int> TypeSplitLength;
2099 std::map<int,int>::iterator TSLiter;
2101 int intSplitSize = 0;
2102 int intSplitsFound = 0;
2103 int intSplitPoint = 0;
2105 int intPrevValue = 5;
2107 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2111 // Look for type before continuing.
2113 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2114 intiter != SplitPoints.end(); ++intiter){
2116 SLiter = SplitLength.find(intiter->first);
2118 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2120 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2121 PropertyName = PropertyElement.GetNextToken();
2122 PropertyValue = PropertyElement.GetNextToken();
2124 intPrevValue = intiter->second;
2126 if (PropertyName == wxT("TYPE")){
2128 // Process each value in type and translate each
2131 // Strip out the quotes if they are there.
2133 size_t intPropertyValueLen = PropertyValue.Len();
2135 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2137 PropertyValue.Trim();
2138 PropertyValue.RemoveLast();
2142 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2144 PropertyValue.Remove(0, 1);
2148 TelTypeDetail = PropertyValue;
2154 for (int i = 0; i <= intPropertyValueLen; i++){
2158 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2160 if (intSplitsFound == 0){
2162 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2163 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2167 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2168 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2181 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2182 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2184 int intTypeSeek = 0;
2186 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2187 typeiter != TypeSplitPoints.end(); ++typeiter){
2189 wxString TypePropertyName;
2191 TSLiter = TypeSplitLength.find(typeiter->first);
2193 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2195 if (intTypeSeek == 0){
2200 TelTypeUI.Append(wxT(","));
2204 if (TypePropertyName == wxT("home")){
2206 PropType = PROPERTY_HOME;
2208 } else if (TypePropertyName == wxT("work")){
2210 PropType = PROPERTY_WORK;
2215 if (TypePropertyName == wxT("text")){
2217 TelTypeUI.Append(_("text"));
2220 } else if (TypePropertyName == wxT("voice")){
2222 TelTypeUI.Append(_("voice"));
2225 } else if (TypePropertyName == wxT("fax")){
2227 TelTypeUI.Append(_("fax"));
2230 } else if (TypePropertyName == wxT("cell")){
2232 TelTypeUI.Append(_("mobile"));
2235 } else if (TypePropertyName == wxT("video")){
2237 TelTypeUI.Append(_("video"));
2240 } else if (TypePropertyName == wxT("pager")){
2242 TelTypeUI.Append(_("pager"));
2245 } else if (TypePropertyName == wxT("textphone")){
2247 TelTypeUI.Append(_("textphone"));
2258 std::map<int, wxString> *TelephoneList = NULL;
2259 std::map<int, wxString> *TelephoneListType = NULL;
2260 std::map<int, wxString> *TelephoneListAltID = NULL;
2261 std::map<int, wxString> *TelephoneListPID = NULL;
2262 std::map<int, wxString> *TelephoneListTokens = NULL;
2263 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2264 std::map<int, int> *TelephoneListPref = NULL;
2268 TelephoneList = &GeneralTelephoneList;
2269 TelephoneListType = &GeneralTelephoneListType;
2270 TelephoneListAltID = &GeneralTelephoneListAltID;
2271 TelephoneListPID = &GeneralTelephoneListPID;
2272 TelephoneListTokens = &GeneralTelephoneListTokens;
2273 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2274 TelephoneListPref = &GeneralTelephoneListPref;
2277 TelephoneList = &HomeTelephoneList;
2278 TelephoneListType = &HomeTelephoneListType;
2279 TelephoneListAltID = &HomeTelephoneListAltID;
2280 TelephoneListPID = &HomeTelephoneListPID;
2281 TelephoneListTokens = &HomeTelephoneListTokens;
2282 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2283 TelephoneListPref = &HomeTelephoneListPref;
2286 TelephoneList = &BusinessTelephoneList;
2287 TelephoneListType = &BusinessTelephoneListType;
2288 TelephoneListAltID = &BusinessTelephoneListAltID;
2289 TelephoneListPID = &BusinessTelephoneListPID;
2290 TelephoneListTokens = &BusinessTelephoneListTokens;
2291 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2292 TelephoneListPref = &BusinessTelephoneListPref;
2296 // Process the properties.
2298 bool FirstToken = TRUE;
2301 SplitPoints.clear();
2302 SplitLength.clear();
2304 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2308 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2309 intiter != SplitPoints.end(); ++intiter){
2311 SLiter = SplitLength.find(intiter->first);
2313 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2315 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2316 PropertyName = PropertyElement.GetNextToken();
2317 PropertyValue = PropertyElement.GetNextToken();
2319 intPrevValue = intiter->second;
2321 CaptureString(&PropertyValue, FALSE);
2323 // Process properties.
2325 if (PropertyName == wxT("ALTID")){
2327 TelephoneListAltID->erase(*TelephoneCount);
2328 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2330 } else if (PropertyName == wxT("PID")){
2332 TelephoneListPID->erase(*TelephoneCount);
2333 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2335 } else if (PropertyName == wxT("PREF")){
2337 int PriorityNumber = 0;
2338 bool ValidNumber = TRUE;
2341 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2344 catch(std::invalid_argument &e){
2345 ValidNumber = FALSE;
2348 if (ValidNumber == TRUE){
2350 TelephoneListPref->erase(*TelephoneCount);
2351 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2357 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2359 if (FirstToken == TRUE){
2361 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2366 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2376 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2377 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2379 // Add the name token data.
2381 if (!PropertyTokens.IsEmpty()){
2383 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2389 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2391 std::map<int, int> SplitPoints;
2392 std::map<int, int> SplitLength;
2394 int intPrevValue = 6;
2397 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2401 PropertyType PropType = PROPERTY_NONE;
2403 // Look for type before continuing.
2405 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2407 std::map<int, wxString> *LanguageList = NULL;
2408 std::map<int, wxString> *LanguageListType = NULL;
2409 std::map<int, wxString> *LanguageListAltID = NULL;
2410 std::map<int, wxString> *LanguageListPID = NULL;
2411 std::map<int, wxString> *LanguageListTokens = NULL;
2412 std::map<int, int> *LanguageListPref = NULL;
2416 LanguageList = &GeneralLanguageList;
2417 LanguageListType = &GeneralLanguageListType;
2418 LanguageListAltID = &GeneralLanguageListAltID;
2419 LanguageListPID = &GeneralLanguageListPID;
2420 LanguageListTokens = &GeneralLanguageListTokens;
2421 LanguageListPref = &GeneralLanguageListPref;
2424 LanguageList = &HomeLanguageList;
2425 LanguageListType = &HomeLanguageListType;
2426 LanguageListAltID = &HomeLanguageListAltID;
2427 LanguageListPID = &HomeLanguageListPID;
2428 LanguageListTokens = &HomeLanguageListTokens;
2429 LanguageListPref = &HomeLanguageListPref;
2432 LanguageList = &BusinessLanguageList;
2433 LanguageListType = &BusinessLanguageListType;
2434 LanguageListAltID = &BusinessLanguageListAltID;
2435 LanguageListPID = &BusinessLanguageListPID;
2436 LanguageListTokens = &BusinessLanguageListTokens;
2437 LanguageListPref = &BusinessLanguageListPref;
2443 std::map<int,int>::iterator SLiter;
2444 wxString PropertyData;
2445 wxString PropertyName;
2446 wxString PropertyValue;
2447 wxString PropertyTokens;
2448 bool FirstToken = TRUE;
2450 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2451 intiter != SplitPoints.end(); ++intiter){
2453 SLiter = SplitLength.find(intiter->first);
2455 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2457 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2458 PropertyName = PropertyElement.GetNextToken();
2459 PropertyValue = PropertyElement.GetNextToken();
2461 intPrevValue = intiter->second;
2463 CaptureString(&PropertyValue, FALSE);
2465 // Process properties.
2467 if (PropertyName == wxT("ALTID")){
2469 LanguageListAltID->erase(*LanguageCount);
2470 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2472 } else if (PropertyName == wxT("PID")){
2474 LanguageListPID->erase(*LanguageCount);
2475 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2477 } else if (PropertyName == wxT("PREF")){
2479 int PriorityNumber = 0;
2480 bool ValidNumber = TRUE;
2483 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2486 catch(std::invalid_argument &e){
2487 ValidNumber = FALSE;
2490 if (ValidNumber == TRUE){
2492 LanguageListPref->erase(*LanguageCount);
2493 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2499 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2501 if (FirstToken == TRUE){
2503 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2508 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2518 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2520 // Add the name token data.
2522 if (!PropertyTokens.IsEmpty()){
2524 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2530 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2532 std::map<int, int> SplitPoints;
2533 std::map<int, int> SplitLength;
2535 int intPrevValue = 5;
2538 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2542 PropertyType PropType = PROPERTY_NONE;
2544 // Look for type before continuing.
2546 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2548 std::map<int, wxString> *GeopositionList = NULL;
2549 std::map<int, wxString> *GeopositionListType = NULL;
2550 std::map<int, wxString> *GeopositionListAltID = NULL;
2551 std::map<int, wxString> *GeopositionListPID = NULL;
2552 std::map<int, wxString> *GeopositionListTokens = NULL;
2553 std::map<int, wxString> *GeopositionListMediatype = NULL;
2554 std::map<int, int> *GeopositionListPref = NULL;
2558 GeopositionList = &GeneralGeographyList;
2559 GeopositionListType = &GeneralGeographyListType;
2560 GeopositionListAltID = &GeneralGeographyListAltID;
2561 GeopositionListPID = &GeneralGeographyListPID;
2562 GeopositionListTokens = &GeneralGeographyListTokens;
2563 GeopositionListMediatype = &GeneralGeographyListMediatype;
2564 GeopositionListPref = &GeneralGeographyListPref;
2567 GeopositionList = &HomeGeographyList;
2568 GeopositionListType = &HomeGeographyListType;
2569 GeopositionListAltID = &HomeGeographyListAltID;
2570 GeopositionListPID = &HomeGeographyListPID;
2571 GeopositionListTokens = &HomeGeographyListTokens;
2572 GeopositionListMediatype = &HomeGeographyListMediatype;
2573 GeopositionListPref = &HomeGeographyListPref;
2576 GeopositionList = &BusinessGeographyList;
2577 GeopositionListType = &BusinessGeographyListType;
2578 GeopositionListAltID = &BusinessGeographyListAltID;
2579 GeopositionListPID = &BusinessGeographyListPID;
2580 GeopositionListTokens = &BusinessGeographyListTokens;
2581 GeopositionListMediatype = &BusinessGeographyListMediatype;
2582 GeopositionListPref = &BusinessGeographyListPref;
2588 std::map<int,int>::iterator SLiter;
2589 wxString PropertyData;
2590 wxString PropertyName;
2591 wxString PropertyValue;
2592 wxString PropertyTokens;
2593 bool FirstToken = TRUE;
2595 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2596 intiter != SplitPoints.end(); ++intiter){
2598 SLiter = SplitLength.find(intiter->first);
2600 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2602 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2603 PropertyName = PropertyElement.GetNextToken();
2604 PropertyValue = PropertyElement.GetNextToken();
2606 intPrevValue = intiter->second;
2608 CaptureString(&PropertyValue, FALSE);
2610 // Process properties.
2612 if (PropertyName == wxT("ALTID")){
2614 GeopositionListAltID->erase(*GeographicCount);
2615 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2617 } else if (PropertyName == wxT("PID")){
2619 GeopositionListPID->erase(*GeographicCount);
2620 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2622 } else if (PropertyName == wxT("MEDIATYPE")){
2624 GeopositionListMediatype->erase(*GeographicCount);
2625 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2627 } else if (PropertyName == wxT("PREF")){
2629 int PriorityNumber = 0;
2630 bool ValidNumber = TRUE;
2633 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2636 catch(std::invalid_argument &e){
2637 ValidNumber = FALSE;
2640 if (ValidNumber == TRUE){
2642 GeopositionListPref->erase(*GeographicCount);
2643 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2649 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2651 if (FirstToken == TRUE){
2653 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2658 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2668 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2670 // Add the name token data.
2672 if (!PropertyTokens.IsEmpty()){
2674 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2680 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2682 size_t intPropertyLen = PropertySeg1.Len();
2683 std::map<int, int> SplitPoints;
2684 std::map<int, int> SplitLength;
2685 std::map<int, int>::iterator SLiter;
2686 wxString PropertyData;
2687 wxString PropertyName;
2688 wxString PropertyValue;
2689 wxString PropertyTokens;
2690 wxString RelatedType;
2691 wxString RelatedTypeOriginal;
2692 wxString RelatedName;
2693 bool FirstToken = TRUE;
2694 int intSplitsFound = 0;
2695 int intSplitSize = 0;
2696 int intPrevValue = 9;
2700 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2704 // Look for type before continuing.
2706 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2707 intiter != SplitPoints.end(); ++intiter){
2709 SLiter = SplitLength.find(intiter->first);
2711 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2713 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2714 PropertyName = PropertyElement.GetNextToken();
2715 PropertyValue = PropertyElement.GetNextToken();
2717 intPrevValue = intiter->second;
2721 RelatedTypeOriginal = PropertyValue;
2723 if (PropertyName == wxT("TYPE")){
2725 if (PropertyValue == wxT("contact")){
2727 RelatedType = _("Contact");
2729 } else if (PropertyValue == wxT("acquaintance")){
2731 RelatedType = _("Acquaintance");
2733 } else if (PropertyValue == wxT("friend")){
2735 RelatedType = _("Friend");
2737 } else if (PropertyValue == wxT("met")){
2739 RelatedType = _("Met");
2741 } else if (PropertyValue == wxT("co-worker")){
2743 RelatedType = _("Co-worker");
2745 } else if (PropertyValue == wxT("colleague")){
2747 RelatedType = _("Colleague");
2749 } else if (PropertyValue == wxT("co-resident")){
2751 RelatedType = _("Co-resident");
2753 } else if (PropertyValue == wxT("neighbor")){
2755 RelatedType = _("Neighbour");
2757 } else if (PropertyValue == wxT("child")){
2759 RelatedType = _("Child");
2761 } else if (PropertyValue == wxT("parent")){
2763 RelatedType = _("Parent");
2765 } else if (PropertyValue == wxT("sibling")){
2767 RelatedType = _("Sibling");
2769 } else if (PropertyValue == wxT("spouse")){
2771 RelatedType = _("Spouse");
2773 } else if (PropertyValue == wxT("kin")){
2775 RelatedType = _("Kin");
2777 } else if (PropertyValue == wxT("muse")){
2779 RelatedType = _("Muse");
2781 } else if (PropertyValue == wxT("crush")){
2783 RelatedType = _("Crush");
2785 } else if (PropertyValue == wxT("date")){
2787 RelatedType = _("Date");
2789 } else if (PropertyValue == wxT("sweetheart")){
2791 RelatedType = _("Sweetheart");
2793 } else if (PropertyValue == wxT("me")){
2795 RelatedType = _("Me");
2797 } else if (PropertyValue == wxT("agent")){
2799 RelatedType = _("Agent");
2801 } else if (PropertyValue == wxT("emergency")){
2803 RelatedType = _("Emergency");
2807 RelatedType = PropertyValue;
2817 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2818 intiter != SplitPoints.end(); ++intiter){
2820 SLiter = SplitLength.find(intiter->first);
2822 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2824 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2825 PropertyName = PropertyElement.GetNextToken();
2826 PropertyValue = PropertyElement.GetNextToken();
2828 intPrevValue = intiter->second;
2830 // Process properties.
2832 size_t intPropertyValueLen = PropertyValue.Len();
2834 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2836 PropertyValue.Trim();
2837 PropertyValue.RemoveLast();
2841 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2843 PropertyValue.Remove(0, 1);
2847 CaptureString(&PropertyValue, FALSE);
2849 if (PropertyName == wxT("ALTID")){
2851 GeneralRelatedListAltID.erase(*RelatedCount);
2852 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2854 } else if (PropertyName == wxT("PID")){
2856 GeneralRelatedListPID.erase(*RelatedCount);
2857 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2859 } else if (PropertyName == wxT("PREF")){
2861 int PriorityNumber = 0;
2862 bool ValidNumber = TRUE;
2865 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2868 catch(std::invalid_argument &e){
2869 ValidNumber = FALSE;
2872 if (ValidNumber == TRUE){
2874 GeneralRelatedListPref.erase(*RelatedCount);
2875 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2879 } else if (PropertyName == wxT("LANGUAGE")){
2881 GeneralRelatedListLanguage.erase(*RelatedCount);
2882 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2884 } else if (PropertyName != wxT("TYPE")) {
2886 // Something else we don't know about so append
2887 // to the tokens variable.
2889 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2891 if (FirstToken == TRUE){
2893 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2898 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2908 // Add the data to the General/Home/Work address variables.
2910 GeneralRelatedList.erase(*RelatedCount);
2911 GeneralRelatedListRelType.erase(*RelatedCount);
2912 GeneralRelatedListType.erase(*RelatedCount);
2913 GeneralRelatedListTokens.erase(*RelatedCount);
2914 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2915 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2916 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2917 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2921 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2923 std::map<int, int> SplitPoints;
2924 std::map<int, int> SplitLength;
2925 std::map<int, int>::iterator SLiter;
2926 wxString PropertyData;
2927 wxString PropertyName;
2928 wxString PropertyValue;
2929 wxString PropertyTokens;
2930 bool FirstToken = TRUE;
2931 int intPrevValue = 5;
2936 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2940 PropertyType PropType = PROPERTY_NONE;
2942 // Look for type before continuing.
2944 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2946 // Setup the pointers.
2948 std::map<int, wxString> *WebsiteList = NULL;
2949 std::map<int, wxString> *WebsiteListAltID = NULL;
2950 std::map<int, wxString> *WebsiteListPID = NULL;
2951 std::map<int, wxString> *WebsiteListType = NULL;
2952 std::map<int, wxString> *WebsiteListTokens = NULL;
2953 std::map<int, wxString> *WebsiteListMediatype = NULL;
2954 std::map<int, int> *WebsiteListPref = NULL;
2956 // Setup blank lines for later on.
2960 WebsiteList = &GeneralWebsiteList;
2961 WebsiteListType = &GeneralWebsiteListType;
2962 WebsiteListAltID = &GeneralWebsiteListAltID;
2963 WebsiteListPID = &GeneralWebsiteListPID;
2964 WebsiteListTokens = &GeneralWebsiteListTokens;
2965 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2966 WebsiteListPref = &GeneralWebsiteListPref;
2969 WebsiteList = &HomeWebsiteList;
2970 WebsiteListType = &HomeWebsiteListType;
2971 WebsiteListAltID = &HomeWebsiteListAltID;
2972 WebsiteListPID = &HomeWebsiteListPID;
2973 WebsiteListTokens = &HomeWebsiteListTokens;
2974 WebsiteListMediatype = &HomeWebsiteListMediatype;
2975 WebsiteListPref = &HomeWebsiteListPref;
2978 WebsiteList = &BusinessWebsiteList;
2979 WebsiteListType = &BusinessWebsiteListType;
2980 WebsiteListAltID = &BusinessWebsiteListAltID;
2981 WebsiteListPID = &BusinessWebsiteListPID;
2982 WebsiteListTokens = &BusinessWebsiteListTokens;
2983 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2984 WebsiteListPref = &BusinessWebsiteListPref;
2990 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2991 intiter != SplitPoints.end(); ++intiter){
2993 SLiter = SplitLength.find(intiter->first);
2995 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2997 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2998 PropertyName = PropertyElement.GetNextToken();
2999 PropertyValue = PropertyElement.GetNextToken();
3001 intPrevValue = intiter->second;
3003 // Process properties.
3005 size_t intPropertyValueLen = PropertyValue.Len();
3007 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3009 PropertyValue.Trim();
3010 PropertyValue.RemoveLast();
3014 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3016 PropertyValue.Remove(0, 1);
3020 CaptureString(&PropertyValue, FALSE);
3022 if (PropertyName == wxT("ALTID")){
3024 WebsiteListAltID->erase(*URLCount);
3025 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3027 } else if (PropertyName == wxT("PID")){
3029 WebsiteListPID->erase(*URLCount);
3030 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3032 } else if (PropertyName == wxT("PREF")){
3034 int PriorityNumber = 0;
3035 bool ValidNumber = TRUE;
3038 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3041 catch(std::invalid_argument &e){
3042 ValidNumber = FALSE;
3045 if (ValidNumber == TRUE){
3047 WebsiteListPref->erase(*URLCount);
3048 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3052 } else if (PropertyName == wxT("MEDIATYPE")){
3054 WebsiteListMediatype->erase(*URLCount);
3055 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3059 // Something else we don't know about so append
3060 // to the tokens variable.
3062 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3064 if (FirstToken == TRUE){
3066 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3071 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3081 // Add the data to the General/Home/Work address variables.
3083 CaptureString(&PropertySeg2, FALSE);
3085 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3087 if (!PropertyTokens.IsEmpty()){
3089 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3095 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3097 std::map<int, int> SplitPoints;
3098 std::map<int, int> SplitLength;
3099 std::map<int, int>::iterator SLiter;
3100 wxString PropertyData;
3101 wxString PropertyName;
3102 wxString PropertyValue;
3103 wxString PropertyTokens;
3104 bool FirstToken = TRUE;
3105 int intPrevValue = 7;
3110 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3114 PropertyType PropType = PROPERTY_NONE;
3116 // Look for type before continuing.
3118 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3120 // Setup the pointers.
3122 std::map<int, wxString> *TitleList = NULL;
3123 std::map<int, wxString> *TitleListAltID = NULL;
3124 std::map<int, wxString> *TitleListPID = NULL;
3125 std::map<int, wxString> *TitleListType = NULL;
3126 std::map<int, wxString> *TitleListTokens = NULL;
3127 std::map<int, wxString> *TitleListLanguage = NULL;
3128 std::map<int, int> *TitleListPref = NULL;
3130 // Setup blank lines for later on.
3134 TitleList = &GeneralTitleList;
3135 TitleListType = &GeneralTitleListType;
3136 TitleListAltID = &GeneralTitleListAltID;
3137 TitleListPID = &GeneralTitleListPID;
3138 TitleListTokens = &GeneralTitleListTokens;
3139 TitleListLanguage = &GeneralTitleListLanguage;
3140 TitleListPref = &GeneralTitleListPref;
3143 TitleList = &HomeTitleList;
3144 TitleListType = &HomeTitleListType;
3145 TitleListAltID = &HomeTitleListAltID;
3146 TitleListPID = &HomeTitleListPID;
3147 TitleListTokens = &HomeTitleListTokens;
3148 TitleListLanguage = &HomeTitleListLanguage;
3149 TitleListPref = &HomeTitleListPref;
3152 TitleList = &BusinessTitleList;
3153 TitleListType = &BusinessTitleListType;
3154 TitleListAltID = &BusinessTitleListAltID;
3155 TitleListPID = &BusinessTitleListPID;
3156 TitleListTokens = &BusinessTitleListTokens;
3157 TitleListLanguage = &BusinessTitleListLanguage;
3158 TitleListPref = &BusinessTitleListPref;
3164 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3165 intiter != SplitPoints.end(); ++intiter){
3167 SLiter = SplitLength.find(intiter->first);
3169 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3171 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3172 PropertyName = PropertyElement.GetNextToken();
3173 PropertyValue = PropertyElement.GetNextToken();
3175 intPrevValue = intiter->second;
3177 // Process properties.
3179 size_t intPropertyValueLen = PropertyValue.Len();
3181 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3183 PropertyValue.Trim();
3184 PropertyValue.RemoveLast();
3188 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3190 PropertyValue.Remove(0, 1);
3194 CaptureString(&PropertyValue, FALSE);
3196 if (PropertyName == wxT("ALTID")){
3198 TitleListAltID->erase(*TitleCount);
3199 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3201 } else if (PropertyName == wxT("PID")){
3203 TitleListPID->erase(*TitleCount);
3204 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3206 } else if (PropertyName == wxT("PREF")){
3208 int PriorityNumber = 0;
3209 bool ValidNumber = TRUE;
3212 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3215 catch(std::invalid_argument &e){
3216 ValidNumber = FALSE;
3219 if (ValidNumber == TRUE){
3221 TitleListPref->erase(*TitleCount);
3222 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3226 } else if (PropertyName == wxT("LANGUAGE")){
3228 TitleListLanguage->erase(*TitleCount);
3229 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3233 // Something else we don't know about so append
3234 // to the tokens variable.
3236 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3238 if (FirstToken == TRUE){
3240 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3245 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3255 // Add the data to the General/Home/Work address variables.
3257 CaptureString(&PropertySeg2, FALSE);
3259 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3261 if (!PropertyTokens.IsEmpty()){
3263 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3269 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3271 std::map<int, int> SplitPoints;
3272 std::map<int, int> SplitLength;
3273 std::map<int, int>::iterator SLiter;
3274 wxString PropertyData;
3275 wxString PropertyName;
3276 wxString PropertyValue;
3277 wxString PropertyTokens;
3278 bool FirstToken = TRUE;
3279 int intPrevValue = 6;
3284 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3288 PropertyType PropType = PROPERTY_NONE;
3290 // Look for type before continuing.
3292 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3294 // Setup the pointers.
3296 std::map<int, wxString> *RoleList = NULL;
3297 std::map<int, wxString> *RoleListAltID = NULL;
3298 std::map<int, wxString> *RoleListPID = NULL;
3299 std::map<int, wxString> *RoleListType = NULL;
3300 std::map<int, wxString> *RoleListTokens = NULL;
3301 std::map<int, wxString> *RoleListLanguage = NULL;
3302 std::map<int, int> *RoleListPref = NULL;
3304 // Setup blank lines for later on.
3308 RoleList = &GeneralRoleList;
3309 RoleListType = &GeneralRoleListType;
3310 RoleListAltID = &GeneralRoleListAltID;
3311 RoleListPID = &GeneralRoleListPID;
3312 RoleListTokens = &GeneralRoleListTokens;
3313 RoleListLanguage = &GeneralRoleListLanguage;
3314 RoleListPref = &GeneralRoleListPref;
3317 RoleList = &HomeRoleList;
3318 RoleListType = &HomeRoleListType;
3319 RoleListAltID = &HomeRoleListAltID;
3320 RoleListPID = &HomeRoleListPID;
3321 RoleListTokens = &HomeRoleListTokens;
3322 RoleListLanguage = &HomeRoleListLanguage;
3323 RoleListPref = &HomeRoleListPref;
3326 RoleList = &BusinessRoleList;
3327 RoleListType = &BusinessRoleListType;
3328 RoleListAltID = &BusinessRoleListAltID;
3329 RoleListPID = &BusinessRoleListPID;
3330 RoleListTokens = &BusinessRoleListTokens;
3331 RoleListLanguage = &BusinessRoleListLanguage;
3332 RoleListPref = &BusinessRoleListPref;
3338 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3339 intiter != SplitPoints.end(); ++intiter){
3341 SLiter = SplitLength.find(intiter->first);
3343 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3345 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3346 PropertyName = PropertyElement.GetNextToken();
3347 PropertyValue = PropertyElement.GetNextToken();
3349 intPrevValue = intiter->second;
3351 // Process properties.
3353 size_t intPropertyValueLen = PropertyValue.Len();
3355 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3357 PropertyValue.Trim();
3358 PropertyValue.RemoveLast();
3362 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3364 PropertyValue.Remove(0, 1);
3368 CaptureString(&PropertyValue, FALSE);
3370 if (PropertyName == wxT("ALTID")){
3372 RoleListAltID->erase(*RoleCount);
3373 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3375 } else if (PropertyName == wxT("PID")){
3377 RoleListPID->erase(*RoleCount);
3378 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3380 } else if (PropertyName == wxT("PREF")){
3382 int PriorityNumber = 0;
3383 bool ValidNumber = TRUE;
3386 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3389 catch(std::invalid_argument &e){
3390 ValidNumber = FALSE;
3393 if (ValidNumber == TRUE){
3395 RoleListPref->erase(*RoleCount);
3396 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3400 } else if (PropertyName == wxT("LANGUAGE")){
3402 RoleListLanguage->erase(*RoleCount);
3403 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3407 // Something else we don't know about so append
3408 // to the tokens variable.
3410 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3412 if (FirstToken == TRUE){
3414 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3419 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3429 // Add the data to the General/Home/Work address variables.
3431 CaptureString(&PropertySeg2, FALSE);
3433 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3435 if (!PropertyTokens.IsEmpty()){
3437 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3443 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3445 std::map<int, int> SplitPoints;
3446 std::map<int, int> SplitLength;
3447 std::map<int, int>::iterator SLiter;
3448 wxString PropertyData;
3449 wxString PropertyName;
3450 wxString PropertyValue;
3451 wxString PropertyTokens;
3452 bool FirstToken = TRUE;
3453 int intPrevValue = 5;
3458 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3462 PropertyType PropType = PROPERTY_NONE;
3464 // Look for type before continuing.
3466 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3468 // Setup the pointers.
3470 std::map<int, wxString> *OrganisationsList = NULL;
3471 std::map<int, wxString> *OrganisationsListAltID = NULL;
3472 std::map<int, wxString> *OrganisationsListPID = NULL;
3473 std::map<int, wxString> *OrganisationsListType = NULL;
3474 std::map<int, wxString> *OrganisationsListTokens = NULL;
3475 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3476 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3477 std::map<int, int> *OrganisationsListPref = NULL;
3479 // Setup blank lines for later on.
3483 OrganisationsList = &GeneralOrganisationsList;
3484 OrganisationsListType = &GeneralOrganisationsListType;
3485 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3486 OrganisationsListPID = &GeneralOrganisationsListPID;
3487 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3488 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3489 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3490 OrganisationsListPref = &GeneralOrganisationsListPref;
3493 OrganisationsList = &HomeOrganisationsList;
3494 OrganisationsListType = &HomeOrganisationsListType;
3495 OrganisationsListAltID = &HomeOrganisationsListAltID;
3496 OrganisationsListPID = &HomeOrganisationsListPID;
3497 OrganisationsListTokens = &HomeOrganisationsListTokens;
3498 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3499 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3500 OrganisationsListPref = &HomeOrganisationsListPref;
3503 OrganisationsList = &BusinessOrganisationsList;
3504 OrganisationsListType = &BusinessOrganisationsListType;
3505 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3506 OrganisationsListPID = &BusinessOrganisationsListPID;
3507 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3508 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3509 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3510 OrganisationsListPref = &BusinessOrganisationsListPref;
3516 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3517 intiter != SplitPoints.end(); ++intiter){
3519 SLiter = SplitLength.find(intiter->first);
3521 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3523 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3524 PropertyName = PropertyElement.GetNextToken();
3525 PropertyValue = PropertyElement.GetNextToken();
3527 intPrevValue = intiter->second;
3529 // Process properties.
3531 size_t intPropertyValueLen = PropertyValue.Len();
3533 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3535 PropertyValue.Trim();
3536 PropertyValue.RemoveLast();
3540 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3542 PropertyValue.Remove(0, 1);
3546 CaptureString(&PropertyValue, FALSE);
3548 if (PropertyName == wxT("ALTID")){
3550 OrganisationsListAltID->erase(*OrganisationCount);
3551 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3553 } else if (PropertyName == wxT("PID")){
3555 OrganisationsListPID->erase(*OrganisationCount);
3556 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3558 } else if (PropertyName == wxT("SORT-AS")){
3560 OrganisationsListSortAs->erase(*OrganisationCount);
3561 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3563 } else if (PropertyName == wxT("PREF")){
3565 int PriorityNumber = 0;
3566 bool ValidNumber = TRUE;
3569 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3572 catch(std::invalid_argument &e){
3573 ValidNumber = FALSE;
3576 if (ValidNumber == TRUE){
3578 OrganisationsListPref->erase(*OrganisationCount);
3579 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3583 } else if (PropertyName == wxT("LANGUAGE")){
3585 OrganisationsListLanguage->erase(*OrganisationCount);
3586 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3590 // Something else we don't know about so append
3591 // to the tokens variable.
3593 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3595 if (FirstToken == TRUE){
3597 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3602 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3612 // Add the data to the General/Home/Work address variables.
3614 CaptureString(&PropertySeg2, FALSE);
3616 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3618 if (!PropertyTokens.IsEmpty()){
3620 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3626 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3628 std::map<int, int> SplitPoints;
3629 std::map<int, int> SplitLength;
3630 std::map<int, int>::iterator SLiter;
3631 wxString PropertyData;
3632 wxString PropertyName;
3633 wxString PropertyValue;
3634 wxString PropertyTokens;
3635 bool FirstToken = TRUE;
3636 int intPrevValue = 6;
3641 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3645 PropertyType PropType = PROPERTY_NONE;
3647 // Look for type before continuing.
3649 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3651 // Setup the pointers.
3653 std::map<int, wxString> *NoteList = NULL;
3654 std::map<int, wxString> *NoteListAltID = NULL;
3655 std::map<int, wxString> *NoteListPID = NULL;
3656 std::map<int, wxString> *NoteListType = NULL;
3657 std::map<int, wxString> *NoteListTokens = NULL;
3658 std::map<int, wxString> *NoteListLanguage = NULL;
3659 std::map<int, int> *NoteListPref = NULL;
3661 // Setup blank lines for later on.
3665 NoteList = &GeneralNoteList;
3666 NoteListType = &GeneralNoteListType;
3667 NoteListAltID = &GeneralNoteListAltID;
3668 NoteListPID = &GeneralNoteListPID;
3669 NoteListTokens = &GeneralNoteListTokens;
3670 NoteListLanguage = &GeneralNoteListLanguage;
3671 NoteListPref = &GeneralNoteListPref;
3674 NoteList = &HomeNoteList;
3675 NoteListType = &HomeNoteListType;
3676 NoteListAltID = &HomeNoteListAltID;
3677 NoteListPID = &HomeNoteListPID;
3678 NoteListTokens = &HomeNoteListTokens;
3679 NoteListLanguage = &HomeNoteListLanguage;
3680 NoteListPref = &HomeNoteListPref;
3683 NoteList = &BusinessNoteList;
3684 NoteListType = &BusinessNoteListType;
3685 NoteListAltID = &BusinessNoteListAltID;
3686 NoteListPID = &BusinessNoteListPID;
3687 NoteListTokens = &BusinessNoteListTokens;
3688 NoteListLanguage = &BusinessNoteListLanguage;
3689 NoteListPref = &BusinessNoteListPref;
3695 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3696 intiter != SplitPoints.end(); ++intiter){
3698 SLiter = SplitLength.find(intiter->first);
3700 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3702 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3703 PropertyName = PropertyElement.GetNextToken();
3704 PropertyValue = PropertyElement.GetNextToken();
3706 intPrevValue = intiter->second;
3708 // Process properties.
3710 size_t intPropertyValueLen = PropertyValue.Len();
3712 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3714 PropertyValue.Trim();
3715 PropertyValue.RemoveLast();
3719 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3721 PropertyValue.Remove(0, 1);
3725 CaptureString(&PropertyValue, FALSE);
3727 if (PropertyName == wxT("ALTID")){
3729 NoteListAltID->erase(*NoteCount);
3730 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3732 } else if (PropertyName == wxT("PID")){
3734 NoteListPID->erase(*NoteCount);
3735 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3737 } else if (PropertyName == wxT("PREF")){
3739 int PriorityNumber = 0;
3740 bool ValidNumber = TRUE;
3743 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3746 catch(std::invalid_argument &e){
3747 ValidNumber = FALSE;
3750 if (ValidNumber == TRUE){
3752 NoteListPref->erase(*NoteCount);
3753 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3757 } else if (PropertyName == wxT("LANGUAGE")){
3759 NoteListLanguage->erase(*NoteCount);
3760 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3764 // Something else we don't know about so append
3765 // to the tokens variable.
3767 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3769 if (FirstToken == TRUE){
3771 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3776 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3786 // Add the data to the General/Home/Work address variables.
3788 CaptureString(&PropertySeg2, FALSE);
3790 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3792 if (!PropertyTokens.IsEmpty()){
3794 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3800 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3802 std::map<int, int> SplitPoints;
3803 std::map<int, int> SplitLength;
3804 std::map<int, int>::iterator SLiter;
3805 wxString PropertyData;
3806 wxString PropertyName;
3807 wxString PropertyValue;
3808 wxString PropertyTokens;
3809 bool FirstToken = TRUE;
3810 int intPrevValue = 12;
3815 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3819 PropertyType PropType = PROPERTY_NONE;
3821 // Look for type before continuing.
3823 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3825 // Setup blank lines for later on.
3831 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3834 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3840 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3841 intiter != SplitPoints.end(); ++intiter){
3843 SLiter = SplitLength.find(intiter->first);
3845 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3847 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3848 PropertyName = PropertyElement.GetNextToken();
3849 PropertyValue = PropertyElement.GetNextToken();
3851 intPrevValue = intiter->second;
3853 // Process properties.
3855 size_t intPropertyValueLen = PropertyValue.Len();
3857 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3859 PropertyValue.Trim();
3860 PropertyValue.RemoveLast();
3864 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3866 PropertyValue.Remove(0, 1);
3870 CaptureString(&PropertyValue, FALSE);
3872 if (PropertyName == wxT("ALTID")){
3874 CategoriesListAltID.erase(*CategoryCount);
3875 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3877 } else if (PropertyName == wxT("PID")){
3879 CategoriesListPID.erase(*CategoryCount);
3880 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3882 } else if (PropertyName == wxT("PREF")){
3884 int PriorityNumber = 0;
3885 bool ValidNumber = TRUE;
3888 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3891 catch(std::invalid_argument &e){
3892 ValidNumber = FALSE;
3895 if (ValidNumber == TRUE){
3897 CategoriesListPref.erase(*CategoryCount);
3898 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3902 } else if (PropertyName == wxT("LANGUAGE")){
3904 CategoriesListLanguage.erase(*CategoryCount);
3905 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3909 // Something else we don't know about so append
3910 // to the tokens variable.
3912 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3914 if (FirstToken == TRUE){
3916 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3921 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3931 // Deal with multiple categories.
3933 int intOrigCatCount = *CategoryCount;
3934 bool FirstCategoryProcessed = TRUE;
3935 bool AfterFirstToken = FALSE;
3936 int intSplitSize = 0;
3937 int intSplitsFound = 0;
3938 int intSplitSeek = 0;
3939 int intPropertyLen = PropertySeg2.Len();
3941 SplitPoints.clear();
3942 SplitLength.clear();
3945 for (int i = 0; i <= intPropertyLen; i++){
3947 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3955 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3957 if (AfterFirstToken == TRUE){
3959 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3960 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3964 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3965 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3966 AfterFirstToken = TRUE;
3978 if (SplitPoints.size() > 0){
3980 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3981 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3985 if (SplitPoints.size() == 0){
3987 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3989 if (!PropertyTokens.IsEmpty()){
3991 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3997 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3998 intiter != SplitPoints.end(); ++intiter){
4000 SLiter = SplitLength.find(intiter->first);
4002 intPrevValue = intiter->second;
4004 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4006 // Add the data to the General/Home/Work address variables.
4008 // Trim any whitespace from the start and end.
4010 PropertyData = PropertyData.Trim(FALSE);
4011 PropertyData = PropertyData.Trim(TRUE);
4013 CaptureString(&PropertyData, FALSE);
4015 if (FirstCategoryProcessed == TRUE){
4017 FirstCategoryProcessed = FALSE;
4019 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4021 if (!PropertyTokens.IsEmpty()){
4023 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4033 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4035 if (!PropertyTokens.IsEmpty()){
4037 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4043 // Copy the properties to each of the categories (if it exists).
4045 if (!PropertyTokens.IsEmpty()){
4047 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4051 // Check if ALTID was used.
4053 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4055 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4059 // Check if PID was used.
4061 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4063 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4067 // Check if PREF was used.
4069 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4071 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4075 // Check if LANGUAGE was used.
4077 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4079 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4083 // Check if TYPE was used.
4089 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4092 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4100 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4102 size_t intPropertyLen = PropertySeg1.Len();
4103 std::map<int, int> SplitPoints;
4104 std::map<int, int> SplitLength;
4105 std::map<int, int>::iterator SLiter;
4106 wxString PropertyData;
4107 wxString PropertyName;
4108 wxString PropertyValue;
4109 wxString PropertyTokens;
4110 bool FirstToken = TRUE;
4111 int intSplitsFound = 0;
4112 int intSplitSize = 0;
4113 int intPrevValue = 7;
4117 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4121 PropertyType PropType = PROPERTY_NONE;
4123 // Look for type before continuing.
4125 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4129 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4130 intiter != SplitPoints.end(); ++intiter){
4132 SLiter = SplitLength.find(intiter->first);
4134 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4136 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4137 PropertyName = PropertyElement.GetNextToken();
4138 PropertyValue = PropertyElement.GetNextToken();
4140 intPrevValue = intiter->second;
4142 // Process properties.
4144 size_t intPropertyValueLen = PropertyValue.Len();
4146 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4148 PropertyValue.Trim();
4149 PropertyValue.RemoveLast();
4153 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4155 PropertyValue.Remove(0, 1);
4159 CaptureString(&PropertyValue, FALSE);
4161 if (PropertyName == wxT("ALTID")){
4163 PicturesListAltID.erase(*PhotoCount);
4164 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4166 } else if (PropertyName == wxT("PID")){
4168 PicturesListPID.erase(*PhotoCount);
4169 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4171 } else if (PropertyName == wxT("PREF")){
4173 int PriorityNumber = 0;
4174 bool ValidNumber = TRUE;
4177 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4180 catch(std::invalid_argument &e){
4181 ValidNumber = FALSE;
4184 if (ValidNumber == TRUE){
4186 PicturesListPref.erase(*PhotoCount);
4187 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4191 } else if (PropertyName == wxT("MEDIATYPE")){
4193 PicturesListMediatype.erase(*PhotoCount);
4194 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4198 // Something else we don't know about so append
4199 // to the tokens variable.
4201 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4203 if (FirstToken == TRUE){
4205 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4210 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4220 intPropertyLen = PropertySeg2.Len();
4221 SplitPoints.clear();
4222 SplitLength.clear();
4227 CaptureString(&PropertySeg2, FALSE);
4229 for (int i = 0; i <= intPropertyLen; i++){
4233 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4236 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4238 if (intSplitsFound == 6){
4240 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4245 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4255 wxString wxSPhotoURI;
4256 wxString wxSPhotoMIME;
4257 wxString wxSPhotoEncoding;
4258 wxString wxSPhotoData;
4259 std::string base64enc;
4261 if (intSplitsFound == 0){
4265 std::map<int, int>::iterator striter;
4267 striter = SplitLength.find(1);
4269 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4271 while (wSTDataType.HasMoreTokens() == TRUE){
4273 wxSPhotoURI = wSTDataType.GetNextToken();
4274 wxSPhotoMIME = wSTDataType.GetNextToken();
4279 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4281 while (wSTDataInfo.HasMoreTokens() == TRUE){
4283 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4284 wxSPhotoData = wSTDataInfo.GetNextToken();
4285 base64enc = wxSPhotoData.mb_str();
4292 // Add the data to the General/Home/Work address variables.
4294 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4295 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4296 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4302 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4305 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4309 if (!PropertyTokens.IsEmpty()){
4311 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4317 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4319 size_t intPropertyLen = PropertySeg1.Len();
4320 std::map<int, int> SplitPoints;
4321 std::map<int, int> SplitLength;
4322 std::map<int, int>::iterator SLiter;
4323 wxString PropertyData;
4324 wxString PropertyName;
4325 wxString PropertyValue;
4326 wxString PropertyTokens;
4327 bool FirstToken = TRUE;
4328 int intSplitsFound = 0;
4329 int intSplitSize = 0;
4330 int intPrevValue = 6;
4334 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4338 PropertyType PropType = PROPERTY_NONE;
4340 // Look for type before continuing.
4342 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4346 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4347 intiter != SplitPoints.end(); ++intiter){
4349 SLiter = SplitLength.find(intiter->first);
4351 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4353 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4354 PropertyName = PropertyElement.GetNextToken();
4355 PropertyValue = PropertyElement.GetNextToken();
4357 intPrevValue = intiter->second;
4359 // Process properties.
4361 size_t intPropertyValueLen = PropertyValue.Len();
4363 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4365 PropertyValue.Trim();
4366 PropertyValue.RemoveLast();
4370 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4372 PropertyValue.Remove(0, 1);
4376 CaptureString(&PropertyValue, FALSE);
4378 if (PropertyName == wxT("ALTID")){
4380 LogosListAltID.erase(*LogoCount);
4381 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4383 } else if (PropertyName == wxT("PID")){
4385 LogosListPID.erase(*LogoCount);
4386 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4388 } else if (PropertyName == wxT("PREF")){
4390 int PriorityNumber = 0;
4391 bool ValidNumber = TRUE;
4394 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4397 catch(std::invalid_argument &e){
4398 ValidNumber = FALSE;
4401 if (ValidNumber == TRUE){
4403 LogosListPref.erase(*LogoCount);
4404 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4408 } else if (PropertyName == wxT("MEDIATYPE")){
4410 LogosListMediatype.erase(*LogoCount);
4411 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4415 // Something else we don't know about so append
4416 // to the tokens variable.
4418 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4420 if (FirstToken == TRUE){
4422 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4427 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4437 intPropertyLen = PropertySeg2.Len();
4438 SplitPoints.clear();
4439 SplitLength.clear();
4444 CaptureString(&PropertySeg2, FALSE);
4446 for (int i = 0; i <= intPropertyLen; i++){
4450 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4453 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4455 if (intSplitsFound == 6){
4457 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4462 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4472 wxString wxSPhotoURI;
4473 wxString wxSPhotoMIME;
4474 wxString wxSPhotoEncoding;
4475 wxString wxSPhotoData;
4476 std::string base64enc;
4478 if (intSplitsFound == 0){
4482 std::map<int, int>::iterator striter;
4484 striter = SplitLength.find(1);
4486 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4488 while (wSTDataType.HasMoreTokens() == TRUE){
4490 wxSPhotoURI = wSTDataType.GetNextToken();
4491 wxSPhotoMIME = wSTDataType.GetNextToken();
4496 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4498 while (wSTDataInfo.HasMoreTokens() == TRUE){
4500 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4501 wxSPhotoData = wSTDataInfo.GetNextToken();
4502 base64enc = wxSPhotoData.mb_str();
4509 // Add the data to the General/Home/Work address variables.
4511 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4512 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4513 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4519 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4522 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4526 if (!PropertyTokens.IsEmpty()){
4528 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4534 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4536 size_t intPropertyLen = PropertySeg1.Len();
4537 std::map<int, int> SplitPoints;
4538 std::map<int, int> SplitLength;
4539 std::map<int, int>::iterator SLiter;
4540 wxString PropertyData;
4541 wxString PropertyName;
4542 wxString PropertyValue;
4543 wxString PropertyTokens;
4544 bool FirstToken = TRUE;
4545 int intSplitsFound = 0;
4546 int intSplitSize = 0;
4547 int intPrevValue = 7;
4551 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4555 PropertyType PropType = PROPERTY_NONE;
4557 // Look for type before continuing.
4559 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4563 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4564 intiter != SplitPoints.end(); ++intiter){
4566 SLiter = SplitLength.find(intiter->first);
4568 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4570 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4571 PropertyName = PropertyElement.GetNextToken();
4572 PropertyValue = PropertyElement.GetNextToken();
4574 intPrevValue = intiter->second;
4576 // Process properties.
4578 size_t intPropertyValueLen = PropertyValue.Len();
4580 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4582 PropertyValue.Trim();
4583 PropertyValue.RemoveLast();
4587 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4589 PropertyValue.Remove(0, 1);
4593 CaptureString(&PropertyValue, FALSE);
4595 if (PropertyName == wxT("ALTID")){
4597 SoundsListAltID.erase(*SoundCount);
4598 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4600 } else if (PropertyName == wxT("PID")){
4602 SoundsListPID.erase(*SoundCount);
4603 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4605 } else if (PropertyName == wxT("PREF")){
4607 int PriorityNumber = 0;
4608 bool ValidNumber = TRUE;
4611 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4614 catch(std::invalid_argument &e){
4615 ValidNumber = FALSE;
4618 if (ValidNumber == TRUE){
4620 SoundsListPref.erase(*SoundCount);
4621 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4625 } else if (PropertyName == wxT("MEDIATYPE")){
4627 SoundsListMediatype.erase(*SoundCount);
4628 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4630 } else if (PropertyName == wxT("LANGUAGE")){
4632 SoundsListLanguage.erase(*SoundCount);
4633 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4637 // Something else we don't know about so append
4638 // to the tokens variable.
4640 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4642 if (FirstToken == TRUE){
4644 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4649 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4659 intPropertyLen = PropertySeg2.Len();
4660 SplitPoints.clear();
4661 SplitLength.clear();
4666 CaptureString(&PropertySeg2, FALSE);
4668 for (int i = 0; i <= intPropertyLen; i++){
4672 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4675 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4677 if (intSplitsFound == 6){
4679 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4684 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4694 wxString wxSSoundURI;
4695 wxString wxSSoundMIME;
4696 wxString wxSSoundEncoding;
4697 wxString wxSSoundData;
4698 std::string base64enc;
4700 if (intSplitsFound == 0){
4704 std::map<int, int>::iterator striter;
4706 striter = SplitLength.find(1);
4708 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4710 while (wSTDataType.HasMoreTokens() == TRUE){
4712 wxSSoundURI = wSTDataType.GetNextToken();
4713 wxSSoundMIME = wSTDataType.GetNextToken();
4718 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4720 while (wSTDataInfo.HasMoreTokens() == TRUE){
4722 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4723 wxSSoundData = wSTDataInfo.GetNextToken();
4724 base64enc = wxSSoundData.mb_str();
4731 // Add the data to the General/Home/Work address variables.
4737 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4740 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4744 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4745 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4746 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4748 if (!PropertyTokens.IsEmpty()){
4750 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4756 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4758 size_t intPropertyLen = PropertySeg1.Len();
4759 std::map<int, int> SplitPoints;
4760 std::map<int, int> SplitLength;
4761 std::map<int, int>::iterator SLiter;
4762 wxString PropertyData;
4763 wxString PropertyName;
4764 wxString PropertyValue;
4765 wxString PropertyTokens;
4766 bool FirstToken = TRUE;
4767 int intSplitsFound = 0;
4768 int intSplitSize = 0;
4769 int intPrevValue = 8;
4773 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4777 PropertyType PropType = PROPERTY_NONE;
4779 // Look for type before continuing.
4781 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4785 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4786 intiter != SplitPoints.end(); ++intiter){
4788 SLiter = SplitLength.find(intiter->first);
4790 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4792 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4793 PropertyName = PropertyElement.GetNextToken();
4794 PropertyValue = PropertyElement.GetNextToken();
4796 intPrevValue = intiter->second;
4798 // Process properties.
4800 size_t intPropertyValueLen = PropertyValue.Len();
4802 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4804 PropertyValue.Trim();
4805 PropertyValue.RemoveLast();
4809 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4811 PropertyValue.Remove(0, 1);
4815 CaptureString(&PropertyValue, FALSE);
4817 if (PropertyName == wxT("ALTID")){
4819 CalendarListAltID.erase(*CalURICount);
4820 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4822 } else if (PropertyName == wxT("PID")){
4824 CalendarListPID.erase(*CalURICount);
4825 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4827 } else if (PropertyName == wxT("PREF")){
4829 int PriorityNumber = 0;
4830 bool ValidNumber = TRUE;
4833 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4836 catch(std::invalid_argument &e){
4837 ValidNumber = FALSE;
4840 if (ValidNumber == TRUE){
4842 CalendarListPref.erase(*CalURICount);
4843 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
4847 } else if (PropertyName == wxT("MEDIATYPE")){
4849 CalendarListMediatype.erase(*CalURICount);
4850 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4854 // Something else we don't know about so append
4855 // to the tokens variable.
4857 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4859 if (FirstToken == TRUE){
4861 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4866 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4876 intPropertyLen = PropertySeg2.Len();
4877 SplitPoints.clear();
4878 SplitLength.clear();
4883 CaptureString(&PropertySeg2, FALSE);
4885 // Add the data to the General/Home/Work address variables.
4891 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4894 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4898 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4900 if (!PropertyTokens.IsEmpty()){
4902 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4908 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4910 size_t intPropertyLen = PropertySeg1.Len();
4911 std::map<int, int> SplitPoints;
4912 std::map<int, int> SplitLength;
4913 std::map<int, int>::iterator SLiter;
4914 wxString PropertyData;
4915 wxString PropertyName;
4916 wxString PropertyValue;
4917 wxString PropertyTokens;
4918 bool FirstToken = TRUE;
4919 int intSplitsFound = 0;
4920 int intSplitSize = 0;
4921 int intPrevValue = 8;
4925 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4929 PropertyType PropType = PROPERTY_NONE;
4931 // Look for type before continuing.
4933 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4937 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4938 intiter != SplitPoints.end(); ++intiter){
4940 SLiter = SplitLength.find(intiter->first);
4942 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4944 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4945 PropertyName = PropertyElement.GetNextToken();
4946 PropertyValue = PropertyElement.GetNextToken();
4948 intPrevValue = intiter->second;
4950 // Process properties.
4952 size_t intPropertyValueLen = PropertyValue.Len();
4954 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4956 PropertyValue.Trim();
4957 PropertyValue.RemoveLast();
4961 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4963 PropertyValue.Remove(0, 1);
4967 CaptureString(&PropertyValue, FALSE);
4969 if (PropertyName == wxT("ALTID")){
4971 CalendarRequestListAltID.erase(*CalAdrURICount);
4972 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4974 } else if (PropertyName == wxT("PID")){
4976 CalendarRequestListPID.erase(*CalAdrURICount);
4977 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4979 } else if (PropertyName == wxT("PREF")){
4981 int PriorityNumber = 0;
4982 bool ValidNumber = TRUE;
4985 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4988 catch(std::invalid_argument &e){
4989 ValidNumber = FALSE;
4992 if (ValidNumber == TRUE){
4994 CalendarRequestListPref.erase(*CalAdrURICount);
4995 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
4999 } else if (PropertyName == wxT("MEDIATYPE")){
5001 CalendarRequestListMediatype.erase(*CalAdrURICount);
5002 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5006 // Something else we don't know about so append
5007 // to the tokens variable.
5009 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5011 if (FirstToken == TRUE){
5013 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5018 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5028 intPropertyLen = PropertySeg2.Len();
5029 SplitPoints.clear();
5030 SplitLength.clear();
5035 CaptureString(&PropertySeg2, FALSE);
5037 // Add the data to the General/Home/Work address variables.
5043 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5046 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5050 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5052 if (!PropertyTokens.IsEmpty()){
5054 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5060 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5062 size_t intPropertyLen = PropertySeg1.Len();
5063 std::map<int, int> SplitPoints;
5064 std::map<int, int> SplitLength;
5065 std::map<int, int>::iterator SLiter;
5066 wxString PropertyData;
5067 wxString PropertyName;
5068 wxString PropertyValue;
5069 wxString PropertyTokens;
5070 bool FirstToken = TRUE;
5071 int intSplitsFound = 0;
5072 int intSplitSize = 0;
5073 int intPrevValue = 7;
5077 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5081 PropertyType PropType = PROPERTY_NONE;
5083 // Look for type before continuing.
5085 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5089 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5090 intiter != SplitPoints.end(); ++intiter){
5092 SLiter = SplitLength.find(intiter->first);
5094 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5096 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5097 PropertyName = PropertyElement.GetNextToken();
5098 PropertyValue = PropertyElement.GetNextToken();
5100 intPrevValue = intiter->second;
5102 // Process properties.
5104 size_t intPropertyValueLen = PropertyValue.Len();
5106 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5108 PropertyValue.Trim();
5109 PropertyValue.RemoveLast();
5113 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5115 PropertyValue.Remove(0, 1);
5119 CaptureString(&PropertyValue, FALSE);
5121 if (PropertyName == wxT("ALTID")){
5123 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5124 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5126 } else if (PropertyName == wxT("PID")){
5128 FreeBusyListPID.erase(*FreeBusyAddressCount);
5129 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5131 } else if (PropertyName == wxT("PREF")){
5133 int PriorityNumber = 0;
5134 bool ValidNumber = TRUE;
5137 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5140 catch(std::invalid_argument &e){
5141 ValidNumber = FALSE;
5144 if (ValidNumber == TRUE){
5146 FreeBusyListPref.erase(*FreeBusyAddressCount);
5147 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5151 } else if (PropertyName == wxT("MEDIATYPE")){
5153 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5154 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5158 // Something else we don't know about so append
5159 // to the tokens variable.
5161 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5163 if (FirstToken == TRUE){
5165 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5170 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5180 intPropertyLen = PropertySeg2.Len();
5181 SplitPoints.clear();
5182 SplitLength.clear();
5187 CaptureString(&PropertySeg2, FALSE);
5189 // Add the data to the General/Home/Work address variables.
5195 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5198 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5202 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5204 if (!PropertyTokens.IsEmpty()){
5206 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5212 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5214 size_t intPropertyLen = PropertySeg1.Len();
5215 std::map<int, int> SplitPoints;
5216 std::map<int, int> SplitLength;
5217 std::map<int, int>::iterator SLiter;
5218 wxString PropertyData;
5219 wxString PropertyName;
5220 wxString PropertyValue;
5221 wxString PropertyTokens;
5222 bool FirstToken = TRUE;
5223 int intSplitsFound = 0;
5224 int intSplitSize = 0;
5225 int intPrevValue = 5;
5230 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5234 PropertyType PropType = PROPERTY_NONE;
5236 // Look for type before continuing.
5238 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5242 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5243 intiter != SplitPoints.end(); ++intiter){
5245 SLiter = SplitLength.find(intiter->first);
5247 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5249 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5250 PropertyName = PropertyElement.GetNextToken();
5251 PropertyValue = PropertyElement.GetNextToken();
5253 intPrevValue = intiter->second;
5255 // Process properties.
5257 size_t intPropertyValueLen = PropertyValue.Len();
5259 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5261 PropertyValue.Trim();
5262 PropertyValue.RemoveLast();
5266 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5268 PropertyValue.Remove(0, 1);
5272 if (PropertyName == wxT("ALTID")){
5274 KeyListAltID.erase(*KeyCount);
5275 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5277 } else if (PropertyName == wxT("PID")){
5279 KeyListPID.erase(*KeyCount);
5280 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5282 } else if (PropertyName == wxT("PREF")){
5284 int PriorityNumber = 0;
5285 bool ValidNumber = TRUE;
5288 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5291 catch(std::invalid_argument &e){
5292 ValidNumber = FALSE;
5295 if (ValidNumber == TRUE){
5297 KeyListPref.erase(*KeyCount);
5298 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5304 // Something else we don't know about so append
5305 // to the tokens variable.
5307 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5309 if (FirstToken == TRUE){
5311 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5316 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5326 intPropertyLen = PropertySeg2.Len();
5327 SplitPoints.clear();
5328 SplitLength.clear();
5333 for (int i = 0; i <= intPropertyLen; i++){
5337 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5340 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5342 if (intSplitsFound == 6){
5344 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5349 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5360 wxString wxSKeyMIME;
5361 wxString wxSKeyEncoding;
5362 wxString wxSKeyData;
5363 std::string base64enc;
5365 if (intSplitsFound == 0){
5369 std::map<int, int>::iterator striter;
5371 striter = SplitLength.find(1);
5373 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5375 while (wSTDataType.HasMoreTokens() == TRUE){
5377 wxSKeyURI = wSTDataType.GetNextToken();
5378 wxSKeyMIME = wSTDataType.GetNextToken();
5383 if (wxSKeyURI == wxT("data")){
5385 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5387 while (wSTDataInfo.HasMoreTokens() == TRUE){
5389 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5390 wxSKeyData = wSTDataInfo.GetNextToken();
5399 // Add the data to the General/Home/Work address variables.
5401 if (wxSKeyURI == wxT("data")){
5403 KeyListDataEncType.erase(*KeyCount);
5404 KeyListKeyType.erase(*KeyCount);
5405 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5406 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5408 KeyList.erase(*KeyCount);
5409 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5413 KeyList.erase(*KeyCount);
5414 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5418 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5424 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5427 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5431 if (!PropertyTokens.IsEmpty()){
5433 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5439 void SplitValues(wxString *PropertyLine,
5440 std::map<int,int> *SplitPoints,
5441 std::map<int,int> *SplitLength,
5444 size_t intPropertyLen = PropertyLine->Len();
5445 int intSplitsFound = 0;
5446 int intSplitSize = 0;
5447 int intSplitSeek = 0;
5449 for (int i = intSize; i <= intPropertyLen; i++){
5453 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5454 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5456 if (intSplitsFound == 0){
5458 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5462 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5466 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5476 if (intSplitsFound == 0){
5478 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5479 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5483 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5484 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5490 void CheckType(wxString *PropertySeg1,
5491 std::map<int,int> *SplitPoints,
5492 std::map<int,int> *SplitLength,
5494 PropertyType *PropType){
5496 wxString PropertyData;
5497 wxString PropertyName;
5498 wxString PropertyValue;
5499 std::map<int,int>::iterator SLiter;
5501 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5502 intiter != SplitPoints->end(); ++intiter){
5504 SLiter = SplitLength->find(intiter->first);
5506 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5508 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5509 PropertyName = PropertyElement.GetNextToken();
5510 PropertyValue = PropertyElement.GetNextToken();
5512 *intPrevValue = intiter->second;
5514 if (PropertyName == wxT("TYPE")){
5516 if (PropertyValue == wxT("work")){
5518 *PropType = PROPERTY_WORK;
5520 } else if (PropertyValue == wxT("home")){
5522 *PropType = PROPERTY_HOME;
5526 *PropType = PROPERTY_NONE;