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;
96 wxString PropertyLine;
97 wxString PropertySeg1;
98 wxString PropertySeg2;
99 wxString PropertyNextLine;
102 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
103 iter != ContactFileLines.end(); ++iter){
105 ExtraLineSeek = TRUE;
111 PropertyLine.Clear();
112 PropertySeg1.Clear();
113 PropertySeg2.Clear();
116 ContactLine = iter->second;
118 while (ExtraLineSeek == TRUE){
120 // Check if there is extra data on the next line
121 // (indicated by space or tab at the start) and add data.
125 if (iter == ContactFileLines.end()){
132 PropertyNextLine = iter->second;
134 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
136 PropertyNextLine.Remove(0, 1);
137 ContactLine.Append(PropertyNextLine);
142 ExtraLineSeek = FALSE;
148 ContactLineLen = ContactLine.Len();
150 // Make sure we are not in quotation mode.
151 // Make sure colon does not have \ or \\ before it.
153 for (int i = 0; i <= ContactLineLen; i++){
155 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
157 PropertyFind = FALSE;
159 } else if (PropertyFind == TRUE){
161 Property.Append(ContactLine.Mid(i, 1));
165 if (ContactLine.Mid(i, 1) == wxT("\"")){
167 if (QuoteMode == TRUE){
179 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
188 // Split that line at the point into two variables (ignore the colon).
190 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
191 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
193 if (Property == wxT("KIND") && KindProcessed == FALSE){
195 ProcessKind(PropertySeg2);
197 } else if (Property == wxT("MEMBER")){
199 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
202 } else if (Property == wxT("FN")){
204 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
207 } else if (Property == wxT("N") && NameProcessed == FALSE){
209 ProcessN(PropertySeg1, PropertySeg2);
210 NameProcessed = TRUE;
212 } else if (Property == wxT("NICKNAME")){
214 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
217 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
219 ProcessGender(PropertySeg1, PropertySeg2);
220 GenderProcessed = TRUE;
222 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
224 ProcessBirthday(PropertySeg1, PropertySeg2);
225 BirthdayProcessed = TRUE;
227 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
229 ProcessAnniversary(PropertySeg1, PropertySeg2);
230 AnniversaryProcessed = TRUE;
232 } else if (Property == wxT("TZ")){
234 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
237 } else if (Property == wxT("ADR")){
239 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
242 } else if (Property == wxT("EMAIL")){
244 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
247 } else if (Property == wxT("IMPP")){
249 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
252 } else if (Property == wxT("TEL")){
254 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
257 } else if (Property == wxT("LANG")){
259 // See frmContactEditor-LoadLanguage.cpp
261 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
264 } else if (Property == wxT("GEO")){
266 // See frmContactEditor-LoadGeo.cpp
268 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
271 } else if (Property == wxT("RELATED")){
273 // See fromContactEditor-LoadRelated.cpp
275 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
278 } else if (Property == wxT("URL")){
280 // See frmContactEditor-LoadURL.cpp
282 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
289 return CONTACTLOAD_OK;
293 void ContactDataObject::ProcessKind(wxString KindType){
295 if (KindType == wxT("individual")){
297 ContactKind = CONTACTKIND_INDIVIDUAL;
299 } else if (KindType == wxT("group")){
301 ContactKind = CONTACTKIND_GROUP;
303 } else if (KindType == wxT("org")){
305 ContactKind = CONTACTKIND_ORGANISATION;
307 } else if (KindType == wxT("location")){
309 ContactKind = CONTACTKIND_LOCATION;
313 ContactKind = CONTACTKIND_NONE;
318 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
320 std::map<int, int> SplitPoints;
321 std::map<int, int> SplitLength;
323 int intPrevValue = 8;
327 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
331 wxString PropertyName;
332 wxString PropertyValue;
333 wxString PropertyData;
334 wxString PropertyTokens;
335 std::map<int,int>::iterator SLiter;
336 bool FirstToken = TRUE;
338 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
339 intiter != SplitPoints.end(); ++intiter){
341 SLiter = SplitLength.find(intiter->first);
343 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
345 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
346 PropertyName = PropertyElement.GetNextToken();
347 PropertyValue = PropertyElement.GetNextToken();
349 intPrevValue = intiter->second;
351 CaptureString(&PropertyValue, FALSE);
353 if (PropertyName == wxT("ALTID")){
355 GroupsListAltID.erase(*GroupCount);
356 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
358 } else if (PropertyName == wxT("PID")){
360 GroupsListPID.erase(*GroupCount);
361 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
363 } else if (PropertyName == wxT("PREF")){
365 int PriorityNumber = 0;
366 bool ValidNumber = TRUE;
369 PriorityNumber = std::stoi(PropertyValue.ToStdString());
372 catch(std::invalid_argument &e){
376 if (ValidNumber == TRUE){
378 GroupsListPref.erase(*GroupCount);
379 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
383 } else if (PropertyName == wxT("MEDIATYPE")){
385 GroupsListMediaType.erase(*GroupCount);
386 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
388 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
390 if (FirstToken == TRUE){
392 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
397 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
405 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
407 if (!PropertyTokens.IsEmpty()){
409 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
416 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
418 std::map<int, int> SplitPoints;
419 std::map<int, int> SplitLength;
421 int intPrevValue = 4;
425 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
429 wxString PropertyName;
430 wxString PropertyValue;
431 wxString PropertyData;
432 wxString PropertyTokens;
433 std::map<int,int>::iterator SLiter;
434 bool FirstToken = TRUE;
436 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
437 intiter != SplitPoints.end(); ++intiter){
439 SLiter = SplitLength.find(intiter->first);
441 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
443 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
444 PropertyName = PropertyElement.GetNextToken();
445 PropertyValue = PropertyElement.GetNextToken();
447 intPrevValue = intiter->second;
449 CaptureString(&PropertyValue, FALSE);
451 if (PropertyName == wxT("TYPE")){
453 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
454 PropertyValue == wxT("work") ){
456 FullNamesListType.erase(*FNCount);
457 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
461 } else if (PropertyName == wxT("LANGUAGE")){
463 FullNamesListLanguage.erase(*FNCount);
464 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
466 } else if (PropertyName == wxT("ALTID")){
468 FullNamesListAltID.erase(*FNCount);
469 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
471 } else if (PropertyName == wxT("PID")){
473 FullNamesListPID.erase(*FNCount);
474 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
476 } else if (PropertyName == wxT("PREF")){
478 int PriorityNumber = 0;
479 bool ValidNumber = TRUE;
482 PriorityNumber = std::stoi(PropertyValue.ToStdString());
485 catch(std::invalid_argument &e){
489 if (ValidNumber == TRUE){
491 FullNamesListPref.erase(*FNCount);
492 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
496 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
498 if (FirstToken == TRUE){
500 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
505 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
513 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
515 if (!PropertyTokens.IsEmpty()){
517 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
523 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
525 std::map<int, int> SplitPoints;
526 std::map<int, int> SplitLength;
528 int intPrevValue = 3;
532 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
536 wxString PropertyName;
537 wxString PropertyValue;
538 wxString PropertyData;
539 wxString PropertyTokens;
540 std::map<int,int>::iterator SLiter;
541 bool FirstToken = TRUE;
543 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
544 intiter != SplitPoints.end(); ++intiter){
546 SLiter = SplitLength.find(intiter->first);
548 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
550 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
551 PropertyName = PropertyElement.GetNextToken();
552 PropertyValue = PropertyElement.GetNextToken();
554 intPrevValue = intiter->second;
556 CaptureString(&PropertyValue, FALSE);
558 if (PropertyName == wxT("ALTID")){
560 NameAltID = PropertyValue;
562 } else if (PropertyName == wxT("LANGUAGE")){
564 NameLanguage = PropertyValue;
566 } else if (PropertyName == wxT("SORT-AS")){
568 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
569 PropertyValue.Len() >= 3){
570 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
573 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
575 if (FirstToken == TRUE){
577 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
582 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
590 // Split the name data.
592 int intSplitSeek = 0;
593 int intSplitsFound = 0;
594 int intSplitSize = 0;
595 int intPropertyLen = PropertySeg2.Len();
597 std::map<int,wxString> NameValues;
600 for (int i = 0; i <= intPropertyLen; i++){
602 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
604 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
609 if (intSplitsFound == 4){
611 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
625 // Split the data into several parts.
627 for (std::map<int, wxString>::iterator iter = NameValues.begin();
628 iter != NameValues.end(); ++iter){
630 if (iter->first == 1){
632 // Deal with family name.
634 NameSurname = iter->second;
636 } else if (iter->first == 2){
638 // Deal with given names.
640 NameForename = iter->second;
642 } else if (iter->first == 3){
644 // Deal with additional names.
646 NameOtherNames = iter->second;
648 } else if (iter->first == 4){
650 // Deal with honorifix prefixes and suffixes.
652 NameTitle = iter->second;
656 if (iter == NameValues.end()){
662 NameSuffix = iter->second;
668 // Add the name token data.
670 if (!PropertyTokens.IsEmpty()){
672 NameTokens = PropertyTokens;
678 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
680 std::map<int, int> SplitPoints;
681 std::map<int, int> SplitLength;
683 int intPrevValue = 10;
686 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
690 PropertyType PropType = PROPERTY_NONE;
692 // Look for type before continuing.
694 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
698 std::map<int, wxString> *NicknamesList = NULL;
699 std::map<int, wxString> *NicknamesListType = NULL;
700 std::map<int, wxString> *NicknamesListLanguage = NULL;
701 std::map<int, wxString> *NicknamesListAltID = NULL;
702 std::map<int, wxString> *NicknamesListPID = NULL;
703 std::map<int, wxString> *NicknamesListTokens = NULL;
704 std::map<int, int> *NicknamesListPref = NULL;
708 NicknamesList = &GeneralNicknamesList;
709 NicknamesListType = &GeneralNicknamesListType;
710 NicknamesListLanguage = &GeneralNicknamesListLanguage;
711 NicknamesListAltID = &GeneralNicknamesListAltID;
712 NicknamesListPID = &GeneralNicknamesListPID;
713 NicknamesListTokens = &GeneralNicknamesListTokens;
714 NicknamesListPref = &GeneralNicknamesListPref;
717 NicknamesList = &HomeNicknamesList;
718 NicknamesListType = &HomeNicknamesListType;
719 NicknamesListLanguage = &HomeNicknamesListLanguage;
720 NicknamesListAltID = &HomeNicknamesListAltID;
721 NicknamesListPID = &HomeNicknamesListPID;
722 NicknamesListTokens = &HomeNicknamesListTokens;
723 NicknamesListPref = &HomeNicknamesListPref;
726 NicknamesList = &BusinessNicknamesList;
727 NicknamesListType = &BusinessNicknamesListType;
728 NicknamesListLanguage = &BusinessNicknamesListLanguage;
729 NicknamesListAltID = &BusinessNicknamesListAltID;
730 NicknamesListPID = &BusinessNicknamesListPID;
731 NicknamesListTokens = &BusinessNicknamesListTokens;
732 NicknamesListPref = &BusinessNicknamesListPref;
736 std::map<int, int>::iterator SLiter;
737 wxString PropertyData;
738 wxString PropertyName;
739 wxString PropertyValue;
740 wxString PropertyTokens;
741 bool FirstToken = TRUE;
743 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
744 intiter != SplitPoints.end(); ++intiter){
746 SLiter = SplitLength.find(intiter->first);
748 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
750 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
751 PropertyName = PropertyElement.GetNextToken();
752 PropertyValue = PropertyElement.GetNextToken();
754 intPrevValue = intiter->second;
756 CaptureString(&PropertyValue, FALSE);
758 if (PropertyName == wxT("ALTID")){
760 NicknamesListAltID->erase(*NicknameCount);
761 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
763 } else if (PropertyName == wxT("PID")){
765 NicknamesListPID->erase(*NicknameCount);
766 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
768 } else if (PropertyName == wxT("PREF")){
770 int PriorityNumber = 0;
771 bool ValidNumber = TRUE;
774 PriorityNumber = std::stoi(PropertyValue.ToStdString());
777 catch(std::invalid_argument &e){
781 if (ValidNumber == TRUE){
783 NicknamesListPref->erase(*NicknameCount);
784 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
788 } else if (PropertyName == wxT("LANGUAGE")){
790 NicknamesListLanguage->erase(*NicknameCount);
791 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
795 // Something else we don't know about so append
796 // to the tokens variable.
798 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
800 if (FirstToken == TRUE){
802 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
807 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
817 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
819 // Add the name token data.
821 if (!PropertyTokens.IsEmpty()){
823 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
829 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
831 std::map<int, int> SplitPoints;
832 std::map<int, int> SplitLength;
833 std::map<int, int>::iterator SLiter;
834 wxString PropertyData;
835 wxString PropertyName;
836 wxString PropertyValue;
837 wxString PropertyTokens;
838 bool FirstToken = TRUE;
839 int intPrevValue = 8;
841 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
845 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
846 intiter != SplitPoints.end(); ++intiter){
848 SLiter = SplitLength.find(intiter->first);
850 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
852 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
853 PropertyName = PropertyElement.GetNextToken();
854 PropertyValue = PropertyElement.GetNextToken();
856 intPrevValue = intiter->second;
858 // Process properties.
860 size_t intPropertyValueLen = PropertyValue.Len();
862 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
864 PropertyValue.Trim();
865 PropertyValue.RemoveLast();
869 if (PropertyValue.Mid(0, 1) == wxT("\"")){
871 PropertyValue.Remove(0, 1);
875 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
877 if (FirstToken == TRUE){
879 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
884 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
892 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
894 wxString GenderComponent;
896 if (GenderData.CountTokens() >= 2){
898 Gender = GenderData.GetNextToken();
899 GenderDetails = GenderData.GetString();
901 CaptureString(&GenderDetails, FALSE);
905 Gender = GenderData.GetNextToken();
909 if (!PropertyTokens.IsEmpty()){
911 GenderTokens = PropertyTokens;
917 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
919 // Process date. Preserve the remainder in the string.
921 std::map<int, int> SplitPoints;
922 std::map<int, int> SplitLength;
923 std::map<int, int>::iterator SLiter;
924 wxString PropertyData;
925 wxString PropertyName;
926 wxString PropertyValue;
927 wxString PropertyTokens;
928 bool BirthdayText = FALSE;
929 int intPrevValue = 6;
931 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
935 // Look for type before continuing.
937 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
938 intiter != SplitPoints.end(); ++intiter){
940 SLiter = SplitLength.find(intiter->first);
942 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
944 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
945 PropertyName = PropertyElement.GetNextToken();
946 PropertyValue = PropertyElement.GetNextToken();
948 intPrevValue = intiter->second;
950 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
952 CaptureString(&PropertySeg2, FALSE);
953 Birthday = PropertySeg2;
960 // Setup blank lines for later on.
963 bool FirstToken = TRUE;
965 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
966 intiter != SplitPoints.end(); ++intiter){
968 SLiter = SplitLength.find(intiter->first);
970 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
972 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
973 PropertyName = PropertyElement.GetNextToken();
974 PropertyValue = PropertyElement.GetNextToken();
976 intPrevValue = intiter->second;
978 // Process properties.
980 CaptureString(&PropertyValue, FALSE);
982 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
984 PropertyValue.Trim();
985 PropertyValue.RemoveLast();
989 if (PropertyValue.Mid(0, 1) == wxT("\"")){
991 PropertyValue.Remove(0, 1);
995 if (PropertyName == wxT("ALTID")){
997 BirthdayAltID = PropertyValue;
999 } else if (PropertyName == wxT("CALSCALE")){
1001 BirthdayCalScale = PropertyValue;
1003 } else if (PropertyName != wxT("VALUE")) {
1005 // Something else we don't know about so append
1006 // to the tokens variable.
1008 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1010 if (FirstToken == TRUE){
1012 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1017 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1027 // Add the data to the variables and form.
1029 if (BirthdayText == FALSE){
1031 Birthday = PropertySeg2;
1035 if (!PropertyTokens.IsEmpty()){
1037 BirthdayTokens = PropertyTokens;
1043 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1045 // Process date. Preserve the remainder in the string.
1047 std::map<int, int> SplitPoints;
1048 std::map<int, int> SplitLength;
1049 std::map<int, int>::iterator SLiter;
1050 wxString PropertyData;
1051 wxString PropertyName;
1052 wxString PropertyValue;
1053 wxString PropertyTokens;
1054 bool AnniversaryText = FALSE;
1055 int intPrevValue = 13;
1057 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1061 // Look for type before continuing.
1063 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1064 intiter != SplitPoints.end(); ++intiter){
1066 SLiter = SplitLength.find(intiter->first);
1068 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1070 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1071 PropertyName = PropertyElement.GetNextToken();
1072 PropertyValue = PropertyElement.GetNextToken();
1074 intPrevValue = intiter->second;
1076 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1078 CaptureString(&PropertySeg2, FALSE);
1079 Anniversary = PropertySeg2;
1080 AnniversaryText = TRUE;
1086 // Setup blank lines for later on.
1089 bool FirstToken = TRUE;
1091 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1092 intiter != SplitPoints.end(); ++intiter){
1094 SLiter = SplitLength.find(intiter->first);
1096 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1098 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1099 PropertyName = PropertyElement.GetNextToken();
1100 PropertyValue = PropertyElement.GetNextToken();
1102 intPrevValue = intiter->second;
1104 // Process properties.
1106 CaptureString(&PropertyValue, FALSE);
1108 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1110 PropertyValue.Trim();
1111 PropertyValue.RemoveLast();
1115 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1117 PropertyValue.Remove(0, 1);
1121 if (PropertyName == wxT("ALTID")){
1123 AnniversaryAltID = PropertyValue;
1125 } else if (PropertyName == wxT("CALSCALE")){
1127 AnniversaryCalScale = PropertyValue;
1129 } else if (PropertyName != wxT("VALUE")) {
1131 // Something else we don't know about so append
1132 // to the tokens variable.
1134 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1136 if (FirstToken == TRUE){
1138 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1143 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1153 // Add the data to the variables and form.
1155 if (AnniversaryText == FALSE){
1157 Anniversary = PropertySeg2;
1161 if (!PropertyTokens.IsEmpty()){
1163 AnniversaryTokens = PropertyTokens;
1169 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1171 std::map<int, int> SplitPoints;
1172 std::map<int, int> SplitLength;
1174 int intPrevValue = 4;
1177 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1181 PropertyType PropType = PROPERTY_NONE;
1183 // Look for type before continuing.
1185 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1189 std::map<int, wxString> *TZList = NULL;
1190 std::map<int, wxString> *TZListType = NULL;
1191 std::map<int, wxString> *TZListMediatype = NULL;
1192 std::map<int, wxString> *TZListAltID = NULL;
1193 std::map<int, wxString> *TZListPID = NULL;
1194 std::map<int, wxString> *TZListTokens = NULL;
1195 std::map<int, int> *TZListPref = NULL;
1199 TZList = &GeneralTZList;
1200 TZListType = &GeneralTZListType;
1201 TZListMediatype = &GeneralTZListMediatype;
1202 TZListAltID = &GeneralTZListAltID;
1203 TZListPID = &GeneralTZListPID;
1204 TZListTokens = &GeneralTZListTokens;
1205 TZListPref = &GeneralTZListPref;
1208 TZList = &HomeTZList;
1209 TZListType = &HomeTZListType;
1210 TZListMediatype = &HomeTZListMediatype;
1211 TZListAltID = &HomeTZListAltID;
1212 TZListPID = &HomeTZListPID;
1213 TZListTokens = &HomeTZListTokens;
1214 TZListPref = &HomeTZListPref;
1217 TZList = &BusinessTZList;
1218 TZListType = &BusinessTZListType;
1219 TZListMediatype = &BusinessTZListMediatype;
1220 TZListAltID = &BusinessTZListAltID;
1221 TZListPID = &BusinessTZListPID;
1222 TZListTokens = &BusinessTZListTokens;
1223 TZListPref = &BusinessTZListPref;
1227 std::map<int, int>::iterator SLiter;
1228 wxString PropertyData;
1229 wxString PropertyName;
1230 wxString PropertyValue;
1231 wxString PropertyTokens;
1232 bool FirstToken = TRUE;
1234 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1235 intiter != SplitPoints.end(); ++intiter){
1237 SLiter = SplitLength.find(intiter->first);
1239 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1241 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1242 PropertyName = PropertyElement.GetNextToken();
1243 PropertyValue = PropertyElement.GetNextToken();
1245 intPrevValue = intiter->second;
1247 CaptureString(&PropertyValue, FALSE);
1249 if (PropertyName == wxT("ALTID")){
1251 TZListAltID->erase(*TimeZoneCount);
1252 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1254 } else if (PropertyName == wxT("PID")){
1256 TZListPID->erase(*TimeZoneCount);
1257 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1259 } else if (PropertyName == wxT("PREF")){
1261 int PriorityNumber = 0;
1262 bool ValidNumber = TRUE;
1265 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1268 catch(std::invalid_argument &e){
1269 ValidNumber = FALSE;
1272 if (ValidNumber == TRUE){
1274 TZListPref->erase(*TimeZoneCount);
1275 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1279 } else if (PropertyName == wxT("MEDIATYPE")){
1281 TZListMediatype->erase(*TimeZoneCount);
1282 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1286 // Something else we don't know about so append
1287 // to the tokens variable.
1289 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1291 if (FirstToken == TRUE){
1293 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1298 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1308 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1310 // Add the name token data.
1312 if (!PropertyTokens.IsEmpty()){
1314 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1321 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1323 size_t intPropertyLen = PropertySeg1.Len();
1324 std::map<int, int> SplitPoints;
1325 std::map<int, int> SplitLength;
1326 std::map<int, int>::iterator SLiter;
1327 wxString PropertyData;
1328 wxString PropertyName;
1329 wxString PropertyValue;
1330 wxString PropertyTokens;
1331 wxString AddressLabel;
1332 wxString AddressLang;
1333 wxString AddressAltID;
1334 wxString AddressPID;
1335 wxString AddressTokens;
1336 wxString AddressGeo;
1337 wxString AddressTimezone;
1338 wxString AddressType;
1339 wxString AddressMediatype;
1340 wxString AddressPOBox;
1341 wxString AddressExtended;
1342 wxString AddressStreet;
1343 wxString AddressLocality;
1344 wxString AddressCity;
1345 wxString AddressRegion;
1346 wxString AddressPostalCode;
1347 wxString AddressCountry;
1348 bool FirstToken = TRUE;
1349 int intSplitsFound = 0;
1350 int intSplitSize = 0;
1351 int intPrevValue = 5;
1356 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1360 PropertyType PropType = PROPERTY_NONE;
1362 // Look for type before continuing.
1364 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1368 std::map<int, wxString> *AddressList = NULL;
1369 std::map<int, wxString> *AddressListTown = NULL;
1370 std::map<int, wxString> *AddressListCounty = NULL;
1371 std::map<int, wxString> *AddressListPostCode = NULL;
1372 std::map<int, wxString> *AddressListCountry = NULL;
1373 std::map<int, wxString> *AddressListLabel = NULL;
1374 std::map<int, wxString> *AddressListLang = NULL;
1375 std::map<int, wxString> *AddressListAltID = NULL;
1376 std::map<int, wxString> *AddressListPID = NULL;
1377 std::map<int, wxString> *AddressListTokens = NULL;
1378 std::map<int, wxString> *AddressListGeo = NULL;
1379 std::map<int, wxString> *AddressListTimezone = NULL;
1380 std::map<int, wxString> *AddressListType = NULL;
1381 std::map<int, wxString> *AddressListMediatype = NULL;
1382 std::map<int, int> *AddressListPref = NULL;
1386 AddressList = &GeneralAddressList;
1387 AddressListTown = &GeneralAddressListTown;
1388 AddressListCounty = &GeneralAddressListCounty;
1389 AddressListPostCode = &GeneralAddressListPostCode;
1390 AddressListCountry = &GeneralAddressListCountry;
1391 AddressListLabel = &GeneralAddressListLabel;
1392 AddressListLang = &GeneralAddressListLang;
1393 AddressListAltID = &GeneralAddressListAltID;
1394 AddressListPID = &GeneralAddressListPID;
1395 AddressListTokens = &GeneralAddressListTokens;
1396 AddressListGeo = &GeneralAddressListGeo;
1397 AddressListTimezone = &GeneralAddressListTimezone;
1398 AddressListType = &GeneralAddressListType;
1399 AddressListMediatype = &GeneralAddressListMediatype;
1400 AddressListPref = &GeneralAddressListPref;
1403 AddressList = &HomeAddressList;
1404 AddressListTown = &HomeAddressListTown;
1405 AddressListCounty = &HomeAddressListCounty;
1406 AddressListPostCode = &HomeAddressListPostCode;
1407 AddressListCountry = &HomeAddressListCountry;
1408 AddressListLabel = &HomeAddressListLabel;
1409 AddressListLang = &HomeAddressListLang;
1410 AddressListAltID = &HomeAddressListAltID;
1411 AddressListPID = &HomeAddressListPID;
1412 AddressListTokens = &HomeAddressListTokens;
1413 AddressListGeo = &HomeAddressListGeo;
1414 AddressListTimezone = &HomeAddressListTimezone;
1415 AddressListType = &HomeAddressListType;
1416 AddressListMediatype = &HomeAddressListMediatype;
1417 AddressListPref = &HomeAddressListPref;
1420 AddressList = &BusinessAddressList;
1421 AddressListTown = &BusinessAddressListTown;
1422 AddressListCounty = &BusinessAddressListCounty;
1423 AddressListPostCode = &BusinessAddressListPostCode;
1424 AddressListCountry = &BusinessAddressListCountry;
1425 AddressListLabel = &BusinessAddressListLabel;
1426 AddressListLang = &BusinessAddressListLang;
1427 AddressListAltID = &BusinessAddressListAltID;
1428 AddressListPID = &BusinessAddressListPID;
1429 AddressListTokens = &BusinessAddressListTokens;
1430 AddressListGeo = &BusinessAddressListGeo;
1431 AddressListTimezone = &BusinessAddressListTimezone;
1432 AddressListType = &BusinessAddressListType;
1433 AddressListMediatype = &BusinessAddressListMediatype;
1434 AddressListPref = &BusinessAddressListPref;
1440 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1441 intiter != SplitPoints.end(); ++intiter){
1443 SLiter = SplitLength.find(intiter->first);
1445 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1447 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1448 PropertyName = PropertyElement.GetNextToken();
1449 PropertyValue = PropertyElement.GetNextToken();
1451 intPrevValue = intiter->second;
1453 CaptureString(&PropertyValue, FALSE);
1455 // Process properties.
1457 if (PropertyName == wxT("LABEL")){
1459 AddressListLabel->erase(*AddressCount);
1460 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1462 } else if (PropertyName == wxT("LANGUAGE")){
1464 AddressListLang->erase(*AddressCount);
1465 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1467 } else if (PropertyName == wxT("ALTID")){
1469 AddressListAltID->erase(*AddressCount);
1470 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1472 } else if (PropertyName == wxT("PID")){
1474 AddressListPID->erase(*AddressCount);
1475 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1477 } else if (PropertyName == wxT("GEO")){
1479 AddressListGeo->erase(*AddressCount);
1480 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1482 } else if (PropertyName == wxT("TZ")){
1484 AddressListTimezone->erase(*AddressCount);
1485 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1487 } else if (PropertyName == wxT("MEDIATYPE")){
1489 AddressListMediatype->erase(*AddressCount);
1490 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1492 } else if (PropertyName == wxT("PREF")){
1494 int PriorityNumber = 0;
1495 bool ValidNumber = TRUE;
1498 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1501 catch(std::invalid_argument &e){
1502 ValidNumber = FALSE;
1505 if (ValidNumber == TRUE){
1507 AddressListPref->erase(*AddressCount);
1508 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1514 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1516 if (FirstToken == TRUE){
1518 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1523 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1533 // Split the address.
1535 //std::map<int, int>::iterator SLiter;
1536 intPropertyLen = PropertySeg2.Len();
1537 SplitPoints.clear();
1538 SplitLength.clear();
1543 for (int i = 0; i <= intPropertyLen; i++){
1547 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1550 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1552 if (intSplitsFound == 6){
1554 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1559 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1569 // Split the data into several parts.
1571 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1572 intiter != SplitPoints.end(); ++intiter){
1574 if (intiter->first == 1){
1576 // Deal with PO Box.
1578 SLiter = SplitLength.find(1);
1580 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1581 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1582 intPrevValue = intiter->second;
1584 } else if (intiter->first == 2){
1586 // Deal with extended address.
1588 SLiter = SplitLength.find(2);
1590 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1591 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1592 intPrevValue = intiter->second;
1594 } else if (intiter->first == 3){
1596 // Deal with street address.
1598 SLiter = SplitLength.find(3);
1600 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1601 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1602 intPrevValue = intiter->second;
1604 } else if (intiter->first == 4){
1606 // Deal with locality
1608 SLiter = SplitLength.find(4);
1610 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1611 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1612 intPrevValue = intiter->second;
1614 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1616 } else if (intiter->first == 5){
1618 // Deal with region.
1620 SLiter = SplitLength.find(5);
1622 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1623 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1624 intPrevValue = intiter->second;
1626 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1628 } else if (intiter->first == 6){
1630 // Deal with post code.
1632 SLiter = SplitLength.find(6);
1634 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1635 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1636 intPrevValue = intiter->second;
1638 // Deal with country.
1640 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1641 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1649 // Add the data to the General/Home/Work address variables.
1651 CaptureString(&AddressStreet, FALSE);
1652 CaptureString(&AddressLocality, FALSE);
1653 CaptureString(&AddressRegion, FALSE);
1654 CaptureString(&AddressPostalCode, FALSE);
1655 CaptureString(&AddressCountry, FALSE);
1657 if (!PropertyTokens.IsEmpty()){
1659 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1663 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1664 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1665 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1666 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1667 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1671 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1674 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1677 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1681 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1685 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1687 std::map<int, int> SplitPoints;
1688 std::map<int, int> SplitLength;
1690 int intPrevValue = 7;
1693 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1697 PropertyType PropType = PROPERTY_NONE;
1699 // Look for type before continuing.
1701 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1703 std::map<int, wxString> *EmailList = NULL;
1704 std::map<int, wxString> *EmailListType = NULL;
1705 std::map<int, wxString> *EmailListAltID = NULL;
1706 std::map<int, wxString> *EmailListPID = NULL;
1707 std::map<int, wxString> *EmailListTokens = NULL;
1708 std::map<int, int> *EmailListPref = NULL;
1712 EmailList = &GeneralEmailList;
1713 EmailListType = &GeneralEmailListType;
1714 EmailListAltID = &GeneralEmailListAltID;
1715 EmailListPID = &GeneralEmailListPID;
1716 EmailListTokens = &GeneralEmailListTokens;
1717 EmailListPref = &GeneralEmailListPref;
1720 EmailList = &HomeEmailList;
1721 EmailListType = &HomeEmailListType;
1722 EmailListAltID = &HomeEmailListAltID;
1723 EmailListPID = &HomeEmailListPID;
1724 EmailListTokens = &HomeEmailListTokens;
1725 EmailListPref = &HomeEmailListPref;
1728 EmailList = &BusinessEmailList;
1729 EmailListType = &BusinessEmailListType;
1730 EmailListAltID = &BusinessEmailListAltID;
1731 EmailListPID = &BusinessEmailListPID;
1732 EmailListTokens = &BusinessEmailListTokens;
1733 EmailListPref = &BusinessEmailListPref;
1739 std::map<int,int>::iterator SLiter;
1740 wxString PropertyData;
1741 wxString PropertyName;
1742 wxString PropertyValue;
1743 wxString PropertyTokens;
1744 bool FirstToken = TRUE;
1746 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1747 intiter != SplitPoints.end(); ++intiter){
1749 SLiter = SplitLength.find(intiter->first);
1751 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1753 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1754 PropertyName = PropertyElement.GetNextToken();
1755 PropertyValue = PropertyElement.GetNextToken();
1757 intPrevValue = intiter->second;
1759 CaptureString(&PropertyValue, FALSE);
1761 // Process properties.
1763 if (PropertyName == wxT("ALTID")){
1765 EmailListAltID->erase(*EmailCount);
1766 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1768 } else if (PropertyName == wxT("PID")){
1770 EmailListPID->erase(*EmailCount);
1771 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1773 } else if (PropertyName == wxT("PREF")){
1775 int PriorityNumber = 0;
1776 bool ValidNumber = TRUE;
1779 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1782 catch(std::invalid_argument &e){
1783 ValidNumber = FALSE;
1786 if (ValidNumber == TRUE){
1788 EmailListPref->erase(*EmailCount);
1789 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1795 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1797 if (FirstToken == TRUE){
1799 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1804 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1814 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1816 // Add the name token data.
1818 if (!PropertyTokens.IsEmpty()){
1820 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1827 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1829 std::map<int, int> SplitPoints;
1830 std::map<int, int> SplitLength;
1832 int intPrevValue = 6;
1835 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1839 PropertyType PropType = PROPERTY_NONE;
1841 // Look for type before continuing.
1843 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1845 std::map<int, wxString> *IMList = NULL;
1846 std::map<int, wxString> *IMListType = NULL;
1847 std::map<int, wxString> *IMListAltID = NULL;
1848 std::map<int, wxString> *IMListPID = NULL;
1849 std::map<int, wxString> *IMListTokens = NULL;
1850 std::map<int, wxString> *IMListMediatype = NULL;
1851 std::map<int, int> *IMListPref = NULL;
1855 IMList = &GeneralIMList;
1856 IMListType = &GeneralIMListType;
1857 IMListAltID = &GeneralIMListAltID;
1858 IMListPID = &GeneralIMListPID;
1859 IMListTokens = &GeneralIMListTokens;
1860 IMListMediatype = &GeneralIMListMediatype;
1861 IMListPref = &GeneralIMListPref;
1864 IMList = &HomeIMList;
1865 IMListType = &HomeIMListType;
1866 IMListAltID = &HomeIMListAltID;
1867 IMListPID = &HomeIMListPID;
1868 IMListTokens = &HomeIMListTokens;
1869 IMListMediatype = &HomeIMListMediatype;
1870 IMListPref = &HomeIMListPref;
1873 IMList = &BusinessIMList;
1874 IMListType = &BusinessIMListType;
1875 IMListAltID = &BusinessIMListAltID;
1876 IMListPID = &BusinessIMListPID;
1877 IMListTokens = &BusinessIMListTokens;
1878 IMListMediatype = &BusinessIMListMediatype;
1879 IMListPref = &BusinessIMListPref;
1885 std::map<int,int>::iterator SLiter;
1886 wxString PropertyData;
1887 wxString PropertyName;
1888 wxString PropertyValue;
1889 wxString PropertyTokens;
1890 bool FirstToken = TRUE;
1892 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1893 intiter != SplitPoints.end(); ++intiter){
1895 SLiter = SplitLength.find(intiter->first);
1897 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1899 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1900 PropertyName = PropertyElement.GetNextToken();
1901 PropertyValue = PropertyElement.GetNextToken();
1903 intPrevValue = intiter->second;
1905 CaptureString(&PropertyValue, FALSE);
1907 // Process properties.
1909 if (PropertyName == wxT("ALTID")){
1911 IMListAltID->erase(*IMCount);
1912 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1914 } else if (PropertyName == wxT("PID")){
1916 IMListPID->erase(*IMCount);
1917 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1919 } else if (PropertyName == wxT("MEDIATYPE")){
1921 IMListMediatype->erase(*IMCount);
1922 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1924 } else if (PropertyName == wxT("PREF")){
1926 int PriorityNumber = 0;
1927 bool ValidNumber = TRUE;
1930 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1933 catch(std::invalid_argument &e){
1934 ValidNumber = FALSE;
1937 if (ValidNumber == TRUE){
1939 IMListPref->erase(*IMCount);
1940 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1946 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1948 if (FirstToken == TRUE){
1950 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1955 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1965 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1967 // Add the name token data.
1969 if (!PropertyTokens.IsEmpty()){
1971 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1977 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1979 std::map<int, int> SplitPoints;
1980 std::map<int, int> SplitLength;
1981 std::map<int, int>::iterator SLiter;
1985 PropertyType PropType = PROPERTY_NONE;
1987 // Look for type before continuing.
1990 wxString TelTypeDetail;
1991 wxString PropertyData;
1992 wxString PropertyName;
1993 wxString PropertyValue;
1994 wxString PropertyTokens;
1996 std::map<int,int> TypeSplitPoints;
1997 std::map<int,int> TypeSplitLength;
1998 std::map<int,int>::iterator TSLiter;
2000 int intSplitSize = 0;
2001 int intSplitsFound = 0;
2002 int intSplitPoint = 0;
2004 int intPrevValue = 5;
2006 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2010 // Look for type before continuing.
2012 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2013 intiter != SplitPoints.end(); ++intiter){
2015 SLiter = SplitLength.find(intiter->first);
2017 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2019 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2020 PropertyName = PropertyElement.GetNextToken();
2021 PropertyValue = PropertyElement.GetNextToken();
2023 intPrevValue = intiter->second;
2025 if (PropertyName == wxT("TYPE")){
2027 // Process each value in type and translate each
2030 // Strip out the quotes if they are there.
2032 size_t intPropertyValueLen = PropertyValue.Len();
2034 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2036 PropertyValue.Trim();
2037 PropertyValue.RemoveLast();
2041 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2043 PropertyValue.Remove(0, 1);
2047 TelTypeDetail = PropertyValue;
2053 for (int i = 0; i <= intPropertyValueLen; i++){
2057 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2059 if (intSplitsFound == 0){
2061 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2062 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2066 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2067 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2080 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2081 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2083 int intTypeSeek = 0;
2085 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2086 typeiter != TypeSplitPoints.end(); ++typeiter){
2088 wxString TypePropertyName;
2090 TSLiter = TypeSplitLength.find(typeiter->first);
2092 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2094 if (intTypeSeek == 0){
2099 TelTypeUI.Append(wxT(","));
2103 if (TypePropertyName == wxT("home")){
2105 PropType = PROPERTY_HOME;
2107 } else if (TypePropertyName == wxT("work")){
2109 PropType = PROPERTY_WORK;
2114 if (TypePropertyName == wxT("text")){
2116 TelTypeUI.Append(_("text"));
2119 } else if (TypePropertyName == wxT("voice")){
2121 TelTypeUI.Append(_("voice"));
2124 } else if (TypePropertyName == wxT("fax")){
2126 TelTypeUI.Append(_("fax"));
2129 } else if (TypePropertyName == wxT("cell")){
2131 TelTypeUI.Append(_("mobile"));
2134 } else if (TypePropertyName == wxT("video")){
2136 TelTypeUI.Append(_("video"));
2139 } else if (TypePropertyName == wxT("pager")){
2141 TelTypeUI.Append(_("pager"));
2144 } else if (TypePropertyName == wxT("textphone")){
2146 TelTypeUI.Append(_("textphone"));
2157 std::map<int, wxString> *TelephoneList = NULL;
2158 std::map<int, wxString> *TelephoneListType = NULL;
2159 std::map<int, wxString> *TelephoneListAltID = NULL;
2160 std::map<int, wxString> *TelephoneListPID = NULL;
2161 std::map<int, wxString> *TelephoneListTokens = NULL;
2162 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2163 std::map<int, int> *TelephoneListPref = NULL;
2167 TelephoneList = &GeneralTelephoneList;
2168 TelephoneListType = &GeneralTelephoneListType;
2169 TelephoneListAltID = &GeneralTelephoneListAltID;
2170 TelephoneListPID = &GeneralTelephoneListPID;
2171 TelephoneListTokens = &GeneralTelephoneListTokens;
2172 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2173 TelephoneListPref = &GeneralTelephoneListPref;
2176 TelephoneList = &HomeTelephoneList;
2177 TelephoneListType = &HomeTelephoneListType;
2178 TelephoneListAltID = &HomeTelephoneListAltID;
2179 TelephoneListPID = &HomeTelephoneListPID;
2180 TelephoneListTokens = &HomeTelephoneListTokens;
2181 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2182 TelephoneListPref = &HomeTelephoneListPref;
2185 TelephoneList = &BusinessTelephoneList;
2186 TelephoneListType = &BusinessTelephoneListType;
2187 TelephoneListAltID = &BusinessTelephoneListAltID;
2188 TelephoneListPID = &BusinessTelephoneListPID;
2189 TelephoneListTokens = &BusinessTelephoneListTokens;
2190 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2191 TelephoneListPref = &BusinessTelephoneListPref;
2195 // Process the properties.
2197 bool FirstToken = TRUE;
2200 SplitPoints.clear();
2201 SplitLength.clear();
2203 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2207 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2208 intiter != SplitPoints.end(); ++intiter){
2210 SLiter = SplitLength.find(intiter->first);
2212 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2214 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2215 PropertyName = PropertyElement.GetNextToken();
2216 PropertyValue = PropertyElement.GetNextToken();
2218 intPrevValue = intiter->second;
2220 CaptureString(&PropertyValue, FALSE);
2222 // Process properties.
2224 if (PropertyName == wxT("ALTID")){
2226 TelephoneListAltID->erase(*TelephoneCount);
2227 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2229 } else if (PropertyName == wxT("PID")){
2231 TelephoneListPID->erase(*TelephoneCount);
2232 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2234 } else if (PropertyName == wxT("PREF")){
2236 int PriorityNumber = 0;
2237 bool ValidNumber = TRUE;
2240 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2243 catch(std::invalid_argument &e){
2244 ValidNumber = FALSE;
2247 if (ValidNumber == TRUE){
2249 TelephoneListPref->erase(*TelephoneCount);
2250 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2256 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2258 if (FirstToken == TRUE){
2260 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2265 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2275 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2276 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2278 // Add the name token data.
2280 if (!PropertyTokens.IsEmpty()){
2282 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2288 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2290 std::map<int, int> SplitPoints;
2291 std::map<int, int> SplitLength;
2293 int intPrevValue = 6;
2296 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2300 PropertyType PropType = PROPERTY_NONE;
2302 // Look for type before continuing.
2304 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2306 std::map<int, wxString> *LanguageList = NULL;
2307 std::map<int, wxString> *LanguageListType = NULL;
2308 std::map<int, wxString> *LanguageListAltID = NULL;
2309 std::map<int, wxString> *LanguageListPID = NULL;
2310 std::map<int, wxString> *LanguageListTokens = NULL;
2311 std::map<int, int> *LanguageListPref = NULL;
2315 LanguageList = &GeneralLanguageList;
2316 LanguageListType = &GeneralLanguageListType;
2317 LanguageListAltID = &GeneralLanguageListAltID;
2318 LanguageListPID = &GeneralLanguageListPID;
2319 LanguageListTokens = &GeneralLanguageListTokens;
2320 LanguageListPref = &GeneralLanguageListPref;
2323 LanguageList = &HomeLanguageList;
2324 LanguageListType = &HomeLanguageListType;
2325 LanguageListAltID = &HomeLanguageListAltID;
2326 LanguageListPID = &HomeLanguageListPID;
2327 LanguageListTokens = &HomeLanguageListTokens;
2328 LanguageListPref = &HomeLanguageListPref;
2331 LanguageList = &BusinessLanguageList;
2332 LanguageListType = &BusinessLanguageListType;
2333 LanguageListAltID = &BusinessLanguageListAltID;
2334 LanguageListPID = &BusinessLanguageListPID;
2335 LanguageListTokens = &BusinessLanguageListTokens;
2336 LanguageListPref = &BusinessLanguageListPref;
2342 std::map<int,int>::iterator SLiter;
2343 wxString PropertyData;
2344 wxString PropertyName;
2345 wxString PropertyValue;
2346 wxString PropertyTokens;
2347 bool FirstToken = TRUE;
2349 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2350 intiter != SplitPoints.end(); ++intiter){
2352 SLiter = SplitLength.find(intiter->first);
2354 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2356 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2357 PropertyName = PropertyElement.GetNextToken();
2358 PropertyValue = PropertyElement.GetNextToken();
2360 intPrevValue = intiter->second;
2362 CaptureString(&PropertyValue, FALSE);
2364 // Process properties.
2366 if (PropertyName == wxT("ALTID")){
2368 LanguageListAltID->erase(*LanguageCount);
2369 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2371 } else if (PropertyName == wxT("PID")){
2373 LanguageListPID->erase(*LanguageCount);
2374 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2376 } else if (PropertyName == wxT("PREF")){
2378 int PriorityNumber = 0;
2379 bool ValidNumber = TRUE;
2382 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2385 catch(std::invalid_argument &e){
2386 ValidNumber = FALSE;
2389 if (ValidNumber == TRUE){
2391 LanguageListPref->erase(*LanguageCount);
2392 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2398 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2400 if (FirstToken == TRUE){
2402 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2407 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2417 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2419 // Add the name token data.
2421 if (!PropertyTokens.IsEmpty()){
2423 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2429 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2431 std::map<int, int> SplitPoints;
2432 std::map<int, int> SplitLength;
2434 int intPrevValue = 5;
2437 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2441 PropertyType PropType = PROPERTY_NONE;
2443 // Look for type before continuing.
2445 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2447 std::map<int, wxString> *GeopositionList = NULL;
2448 std::map<int, wxString> *GeopositionListType = NULL;
2449 std::map<int, wxString> *GeopositionListAltID = NULL;
2450 std::map<int, wxString> *GeopositionListPID = NULL;
2451 std::map<int, wxString> *GeopositionListTokens = NULL;
2452 std::map<int, wxString> *GeopositionListMediatype = NULL;
2453 std::map<int, int> *GeopositionListPref = NULL;
2457 GeopositionList = &GeneralGeographyList;
2458 GeopositionListType = &GeneralGeographyListType;
2459 GeopositionListAltID = &GeneralGeographyListAltID;
2460 GeopositionListPID = &GeneralGeographyListPID;
2461 GeopositionListTokens = &GeneralGeographyListTokens;
2462 GeopositionListMediatype = &GeneralGeographyListMediatype;
2463 GeopositionListPref = &GeneralGeographyListPref;
2466 GeopositionList = &HomeGeographyList;
2467 GeopositionListType = &HomeGeographyListType;
2468 GeopositionListAltID = &HomeGeographyListAltID;
2469 GeopositionListPID = &HomeGeographyListPID;
2470 GeopositionListTokens = &HomeGeographyListTokens;
2471 GeopositionListMediatype = &HomeGeographyListMediatype;
2472 GeopositionListPref = &HomeGeographyListPref;
2475 GeopositionList = &BusinessGeographyList;
2476 GeopositionListType = &BusinessGeographyListType;
2477 GeopositionListAltID = &BusinessGeographyListAltID;
2478 GeopositionListPID = &BusinessGeographyListPID;
2479 GeopositionListTokens = &BusinessGeographyListTokens;
2480 GeopositionListMediatype = &BusinessGeographyListMediatype;
2481 GeopositionListPref = &BusinessGeographyListPref;
2487 std::map<int,int>::iterator SLiter;
2488 wxString PropertyData;
2489 wxString PropertyName;
2490 wxString PropertyValue;
2491 wxString PropertyTokens;
2492 bool FirstToken = TRUE;
2494 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2495 intiter != SplitPoints.end(); ++intiter){
2497 SLiter = SplitLength.find(intiter->first);
2499 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2501 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2502 PropertyName = PropertyElement.GetNextToken();
2503 PropertyValue = PropertyElement.GetNextToken();
2505 intPrevValue = intiter->second;
2507 CaptureString(&PropertyValue, FALSE);
2509 // Process properties.
2511 if (PropertyName == wxT("ALTID")){
2513 GeopositionListAltID->erase(*GeographicCount);
2514 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2516 } else if (PropertyName == wxT("PID")){
2518 GeopositionListPID->erase(*GeographicCount);
2519 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2521 } else if (PropertyName == wxT("MEDIATYPE")){
2523 GeopositionListMediatype->erase(*GeographicCount);
2524 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2526 } else if (PropertyName == wxT("PREF")){
2528 int PriorityNumber = 0;
2529 bool ValidNumber = TRUE;
2532 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2535 catch(std::invalid_argument &e){
2536 ValidNumber = FALSE;
2539 if (ValidNumber == TRUE){
2541 GeopositionListPref->erase(*GeographicCount);
2542 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2548 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2550 if (FirstToken == TRUE){
2552 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2557 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2567 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2569 // Add the name token data.
2571 if (!PropertyTokens.IsEmpty()){
2573 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2579 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2581 size_t intPropertyLen = PropertySeg1.Len();
2582 std::map<int, int> SplitPoints;
2583 std::map<int, int> SplitLength;
2584 std::map<int, int>::iterator SLiter;
2585 wxString PropertyData;
2586 wxString PropertyName;
2587 wxString PropertyValue;
2588 wxString PropertyTokens;
2589 wxString RelatedType;
2590 wxString RelatedTypeOriginal;
2591 wxString RelatedName;
2592 bool FirstToken = TRUE;
2593 int intSplitsFound = 0;
2594 int intSplitSize = 0;
2595 int intPrevValue = 9;
2599 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2603 // Look for type before continuing.
2605 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2606 intiter != SplitPoints.end(); ++intiter){
2608 SLiter = SplitLength.find(intiter->first);
2610 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2612 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2613 PropertyName = PropertyElement.GetNextToken();
2614 PropertyValue = PropertyElement.GetNextToken();
2616 intPrevValue = intiter->second;
2620 RelatedTypeOriginal = PropertyValue;
2622 if (PropertyName == wxT("TYPE")){
2624 if (PropertyValue == wxT("contact")){
2626 RelatedType = _("Contact");
2628 } else if (PropertyValue == wxT("acquaintance")){
2630 RelatedType = _("Acquaintance");
2632 } else if (PropertyValue == wxT("friend")){
2634 RelatedType = _("Friend");
2636 } else if (PropertyValue == wxT("met")){
2638 RelatedType = _("Met");
2640 } else if (PropertyValue == wxT("co-worker")){
2642 RelatedType = _("Co-worker");
2644 } else if (PropertyValue == wxT("colleague")){
2646 RelatedType = _("Colleague");
2648 } else if (PropertyValue == wxT("co-resident")){
2650 RelatedType = _("Co-resident");
2652 } else if (PropertyValue == wxT("neighbor")){
2654 RelatedType = _("Neighbour");
2656 } else if (PropertyValue == wxT("child")){
2658 RelatedType = _("Child");
2660 } else if (PropertyValue == wxT("parent")){
2662 RelatedType = _("Parent");
2664 } else if (PropertyValue == wxT("sibling")){
2666 RelatedType = _("Sibling");
2668 } else if (PropertyValue == wxT("spouse")){
2670 RelatedType = _("Spouse");
2672 } else if (PropertyValue == wxT("kin")){
2674 RelatedType = _("Kin");
2676 } else if (PropertyValue == wxT("muse")){
2678 RelatedType = _("Muse");
2680 } else if (PropertyValue == wxT("crush")){
2682 RelatedType = _("Crush");
2684 } else if (PropertyValue == wxT("date")){
2686 RelatedType = _("Date");
2688 } else if (PropertyValue == wxT("sweetheart")){
2690 RelatedType = _("Sweetheart");
2692 } else if (PropertyValue == wxT("me")){
2694 RelatedType = _("Me");
2696 } else if (PropertyValue == wxT("agent")){
2698 RelatedType = _("Agent");
2700 } else if (PropertyValue == wxT("emergency")){
2702 RelatedType = _("Emergency");
2706 RelatedType = PropertyValue;
2716 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2717 intiter != SplitPoints.end(); ++intiter){
2719 SLiter = SplitLength.find(intiter->first);
2721 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2723 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2724 PropertyName = PropertyElement.GetNextToken();
2725 PropertyValue = PropertyElement.GetNextToken();
2727 intPrevValue = intiter->second;
2729 // Process properties.
2731 size_t intPropertyValueLen = PropertyValue.Len();
2733 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2735 PropertyValue.Trim();
2736 PropertyValue.RemoveLast();
2740 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2742 PropertyValue.Remove(0, 1);
2746 CaptureString(&PropertyValue, FALSE);
2748 if (PropertyName == wxT("ALTID")){
2750 GeneralRelatedListAltID.erase(*RelatedCount);
2751 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2753 } else if (PropertyName == wxT("PID")){
2755 GeneralRelatedListPID.erase(*RelatedCount);
2756 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2758 } else if (PropertyName == wxT("PREF")){
2760 intPref = wxAtoi(PropertyValue);
2762 if (intPref > 0 && intPref < 101){
2764 GeneralRelatedListPref.erase(*RelatedCount);
2765 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, intPref));
2770 } else if (PropertyName == wxT("LANGUAGE")){
2772 GeneralRelatedListLanguage.erase(*RelatedCount);
2773 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2775 } else if (PropertyName != wxT("TYPE")) {
2777 // Something else we don't know about so append
2778 // to the tokens variable.
2780 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2782 if (FirstToken == TRUE){
2784 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2789 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2799 // Add the data to the General/Home/Work address variables.
2801 GeneralRelatedList.erase(*RelatedCount);
2802 GeneralRelatedListRelType.erase(*RelatedCount);
2803 GeneralRelatedListType.erase(*RelatedCount);
2804 GeneralRelatedListTokens.erase(*RelatedCount);
2805 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2806 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2807 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2808 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2812 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2814 std::map<int, int> SplitPoints;
2815 std::map<int, int> SplitLength;
2816 std::map<int, int>::iterator SLiter;
2817 wxString PropertyData;
2818 wxString PropertyName;
2819 wxString PropertyValue;
2820 wxString PropertyTokens;
2821 bool FirstToken = TRUE;
2822 int intPrevValue = 5;
2827 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2831 PropertyType PropType = PROPERTY_NONE;
2833 // Look for type before continuing.
2835 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2837 // Setup the pointers.
2839 std::map<int, wxString> *WebsiteList = NULL;
2840 std::map<int, wxString> *WebsiteListAltID = NULL;
2841 std::map<int, wxString> *WebsiteListPID = NULL;
2842 std::map<int, wxString> *WebsiteListType = NULL;
2843 std::map<int, wxString> *WebsiteListTokens = NULL;
2844 std::map<int, wxString> *WebsiteListMediatype = NULL;
2845 std::map<int, int> *WebsiteListPref = NULL;
2847 // Setup blank lines for later on.
2851 WebsiteList = &GeneralWebsiteList;
2852 WebsiteListType = &GeneralWebsiteListType;
2853 WebsiteListAltID = &GeneralWebsiteListAltID;
2854 WebsiteListPID = &GeneralWebsiteListPID;
2855 WebsiteListTokens = &GeneralWebsiteListTokens;
2856 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2857 WebsiteListPref = &GeneralWebsiteListPref;
2860 WebsiteList = &HomeWebsiteList;
2861 WebsiteListType = &HomeWebsiteListType;
2862 WebsiteListAltID = &HomeWebsiteListAltID;
2863 WebsiteListPID = &HomeWebsiteListPID;
2864 WebsiteListTokens = &HomeWebsiteListTokens;
2865 WebsiteListMediatype = &HomeWebsiteListMediatype;
2866 WebsiteListPref = &HomeWebsiteListPref;
2869 WebsiteList = &BusinessWebsiteList;
2870 WebsiteListType = &BusinessWebsiteListType;
2871 WebsiteListAltID = &BusinessWebsiteListAltID;
2872 WebsiteListPID = &BusinessWebsiteListPID;
2873 WebsiteListTokens = &BusinessWebsiteListTokens;
2874 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2875 WebsiteListPref = &BusinessWebsiteListPref;
2881 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2882 intiter != SplitPoints.end(); ++intiter){
2884 SLiter = SplitLength.find(intiter->first);
2886 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2888 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2889 PropertyName = PropertyElement.GetNextToken();
2890 PropertyValue = PropertyElement.GetNextToken();
2892 intPrevValue = intiter->second;
2894 // Process properties.
2896 size_t intPropertyValueLen = PropertyValue.Len();
2898 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2900 PropertyValue.Trim();
2901 PropertyValue.RemoveLast();
2905 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2907 PropertyValue.Remove(0, 1);
2911 CaptureString(&PropertyValue, FALSE);
2913 if (PropertyName == wxT("ALTID")){
2915 WebsiteListAltID->erase(*URLCount);
2916 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2918 } else if (PropertyName == wxT("PID")){
2920 WebsiteListPID->erase(*URLCount);
2921 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2923 } else if (PropertyName == wxT("PREF")){
2925 int PriorityNumber = 0;
2926 bool ValidNumber = TRUE;
2929 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2932 catch(std::invalid_argument &e){
2933 ValidNumber = FALSE;
2936 if (ValidNumber == TRUE){
2938 WebsiteListPref->erase(*URLCount);
2939 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2943 } else if (PropertyName == wxT("MEDIATYPE")){
2945 WebsiteListMediatype->erase(*URLCount);
2946 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2950 // Something else we don't know about so append
2951 // to the tokens variable.
2953 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2955 if (FirstToken == TRUE){
2957 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2962 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2972 // Add the data to the General/Home/Work address variables.
2974 CaptureString(&PropertySeg2, FALSE);
2976 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2978 if (!PropertyTokens.IsEmpty()){
2980 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2986 void SplitValues(wxString *PropertyLine,
2987 std::map<int,int> *SplitPoints,
2988 std::map<int,int> *SplitLength,
2991 size_t intPropertyLen = PropertyLine->Len();
2992 int intSplitsFound = 0;
2993 int intSplitSize = 0;
2994 int intSplitSeek = 0;
2996 for (int i = intSize; i <= intPropertyLen; i++){
3000 if (PropertyLine->Mid(i, 1) == wxT(";") &&
3001 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
3003 if (intSplitsFound == 0){
3005 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
3009 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3013 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
3023 if (intSplitsFound == 0){
3025 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
3026 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3030 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3031 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3037 void CheckType(wxString *PropertySeg1,
3038 std::map<int,int> *SplitPoints,
3039 std::map<int,int> *SplitLength,
3041 PropertyType *PropType){
3043 wxString PropertyData;
3044 wxString PropertyName;
3045 wxString PropertyValue;
3046 std::map<int,int>::iterator SLiter;
3048 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
3049 intiter != SplitPoints->end(); ++intiter){
3051 SLiter = SplitLength->find(intiter->first);
3053 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
3055 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3056 PropertyName = PropertyElement.GetNextToken();
3057 PropertyValue = PropertyElement.GetNextToken();
3059 *intPrevValue = intiter->second;
3061 if (PropertyName == wxT("TYPE")){
3063 if (PropertyValue == wxT("work")){
3065 *PropType = PROPERTY_WORK;
3067 } else if (PropertyValue == wxT("home")){
3069 *PropType = PROPERTY_HOME;
3073 *PropType = PROPERTY_NONE;