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 wxString PropertyLine;
98 wxString PropertySeg1;
99 wxString PropertySeg2;
100 wxString PropertyNextLine;
103 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
104 iter != ContactFileLines.end(); ++iter){
106 ExtraLineSeek = TRUE;
112 PropertyLine.Clear();
113 PropertySeg1.Clear();
114 PropertySeg2.Clear();
117 ContactLine = iter->second;
119 while (ExtraLineSeek == TRUE){
121 // Check if there is extra data on the next line
122 // (indicated by space or tab at the start) and add data.
126 if (iter == ContactFileLines.end()){
133 PropertyNextLine = iter->second;
135 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
137 PropertyNextLine.Remove(0, 1);
138 ContactLine.Append(PropertyNextLine);
143 ExtraLineSeek = FALSE;
149 ContactLineLen = ContactLine.Len();
151 // Make sure we are not in quotation mode.
152 // Make sure colon does not have \ or \\ before it.
154 for (int i = 0; i <= ContactLineLen; i++){
156 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
158 PropertyFind = FALSE;
160 } else if (PropertyFind == TRUE){
162 Property.Append(ContactLine.Mid(i, 1));
166 if (ContactLine.Mid(i, 1) == wxT("\"")){
168 if (QuoteMode == TRUE){
180 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
189 // Split that line at the point into two variables (ignore the colon).
191 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
192 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
194 if (Property == wxT("KIND") && KindProcessed == FALSE){
196 ProcessKind(PropertySeg2);
198 } else if (Property == wxT("MEMBER")){
200 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
203 } else if (Property == wxT("FN")){
205 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
208 } else if (Property == wxT("N") && NameProcessed == FALSE){
210 ProcessN(PropertySeg1, PropertySeg2);
211 NameProcessed = TRUE;
213 } else if (Property == wxT("NICKNAME")){
215 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
218 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
220 ProcessGender(PropertySeg1, PropertySeg2);
221 GenderProcessed = TRUE;
223 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
225 ProcessBirthday(PropertySeg1, PropertySeg2);
226 BirthdayProcessed = TRUE;
228 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
230 ProcessAnniversary(PropertySeg1, PropertySeg2);
231 AnniversaryProcessed = TRUE;
233 } else if (Property == wxT("TZ")){
235 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
238 } else if (Property == wxT("ADR")){
240 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
243 } else if (Property == wxT("EMAIL")){
245 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
248 } else if (Property == wxT("IMPP")){
250 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
253 } else if (Property == wxT("TEL")){
255 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
258 } else if (Property == wxT("LANG")){
260 // See frmContactEditor-LoadLanguage.cpp
262 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
265 } else if (Property == wxT("GEO")){
267 // See frmContactEditor-LoadGeo.cpp
269 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
272 } else if (Property == wxT("RELATED")){
274 // See fromContactEditor-LoadRelated.cpp
276 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
279 } else if (Property == wxT("URL")){
281 // See frmContactEditor-LoadURL.cpp
283 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
286 } else if (Property == wxT("TITLE")) {
288 // See frmContactEditor-LoadTitle.cpp
290 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
297 return CONTACTLOAD_OK;
301 void ContactDataObject::ProcessKind(wxString KindType){
303 if (KindType == wxT("individual")){
305 ContactKind = CONTACTKIND_INDIVIDUAL;
307 } else if (KindType == wxT("group")){
309 ContactKind = CONTACTKIND_GROUP;
311 } else if (KindType == wxT("org")){
313 ContactKind = CONTACTKIND_ORGANISATION;
315 } else if (KindType == wxT("location")){
317 ContactKind = CONTACTKIND_LOCATION;
321 ContactKind = CONTACTKIND_NONE;
326 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
328 std::map<int, int> SplitPoints;
329 std::map<int, int> SplitLength;
331 int intPrevValue = 8;
335 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
339 wxString PropertyName;
340 wxString PropertyValue;
341 wxString PropertyData;
342 wxString PropertyTokens;
343 std::map<int,int>::iterator SLiter;
344 bool FirstToken = TRUE;
346 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
347 intiter != SplitPoints.end(); ++intiter){
349 SLiter = SplitLength.find(intiter->first);
351 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
353 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
354 PropertyName = PropertyElement.GetNextToken();
355 PropertyValue = PropertyElement.GetNextToken();
357 intPrevValue = intiter->second;
359 CaptureString(&PropertyValue, FALSE);
361 if (PropertyName == wxT("ALTID")){
363 GroupsListAltID.erase(*GroupCount);
364 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
366 } else if (PropertyName == wxT("PID")){
368 GroupsListPID.erase(*GroupCount);
369 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
371 } else if (PropertyName == wxT("PREF")){
373 int PriorityNumber = 0;
374 bool ValidNumber = TRUE;
377 PriorityNumber = std::stoi(PropertyValue.ToStdString());
380 catch(std::invalid_argument &e){
384 if (ValidNumber == TRUE){
386 GroupsListPref.erase(*GroupCount);
387 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
391 } else if (PropertyName == wxT("MEDIATYPE")){
393 GroupsListMediaType.erase(*GroupCount);
394 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
396 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
398 if (FirstToken == TRUE){
400 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
405 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
413 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
415 if (!PropertyTokens.IsEmpty()){
417 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
424 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
426 std::map<int, int> SplitPoints;
427 std::map<int, int> SplitLength;
429 int intPrevValue = 4;
433 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
437 wxString PropertyName;
438 wxString PropertyValue;
439 wxString PropertyData;
440 wxString PropertyTokens;
441 std::map<int,int>::iterator SLiter;
442 bool FirstToken = TRUE;
444 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
445 intiter != SplitPoints.end(); ++intiter){
447 SLiter = SplitLength.find(intiter->first);
449 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
451 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
452 PropertyName = PropertyElement.GetNextToken();
453 PropertyValue = PropertyElement.GetNextToken();
455 intPrevValue = intiter->second;
457 CaptureString(&PropertyValue, FALSE);
459 if (PropertyName == wxT("TYPE")){
461 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
462 PropertyValue == wxT("work") ){
464 FullNamesListType.erase(*FNCount);
465 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
469 } else if (PropertyName == wxT("LANGUAGE")){
471 FullNamesListLanguage.erase(*FNCount);
472 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
474 } else if (PropertyName == wxT("ALTID")){
476 FullNamesListAltID.erase(*FNCount);
477 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
479 } else if (PropertyName == wxT("PID")){
481 FullNamesListPID.erase(*FNCount);
482 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
484 } else if (PropertyName == wxT("PREF")){
486 int PriorityNumber = 0;
487 bool ValidNumber = TRUE;
490 PriorityNumber = std::stoi(PropertyValue.ToStdString());
493 catch(std::invalid_argument &e){
497 if (ValidNumber == TRUE){
499 FullNamesListPref.erase(*FNCount);
500 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
504 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
506 if (FirstToken == TRUE){
508 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
513 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
521 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
523 if (!PropertyTokens.IsEmpty()){
525 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
531 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
533 std::map<int, int> SplitPoints;
534 std::map<int, int> SplitLength;
536 int intPrevValue = 3;
540 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
544 wxString PropertyName;
545 wxString PropertyValue;
546 wxString PropertyData;
547 wxString PropertyTokens;
548 std::map<int,int>::iterator SLiter;
549 bool FirstToken = TRUE;
551 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
552 intiter != SplitPoints.end(); ++intiter){
554 SLiter = SplitLength.find(intiter->first);
556 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
558 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
559 PropertyName = PropertyElement.GetNextToken();
560 PropertyValue = PropertyElement.GetNextToken();
562 intPrevValue = intiter->second;
564 CaptureString(&PropertyValue, FALSE);
566 if (PropertyName == wxT("ALTID")){
568 NameAltID = PropertyValue;
570 } else if (PropertyName == wxT("LANGUAGE")){
572 NameLanguage = PropertyValue;
574 } else if (PropertyName == wxT("SORT-AS")){
576 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
577 PropertyValue.Len() >= 3){
578 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
581 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
583 if (FirstToken == TRUE){
585 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
590 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
598 // Split the name data.
600 int intSplitSeek = 0;
601 int intSplitsFound = 0;
602 int intSplitSize = 0;
603 int intPropertyLen = PropertySeg2.Len();
605 std::map<int,wxString> NameValues;
608 for (int i = 0; i <= intPropertyLen; i++){
610 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
612 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
617 if (intSplitsFound == 4){
619 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
633 // Split the data into several parts.
635 for (std::map<int, wxString>::iterator iter = NameValues.begin();
636 iter != NameValues.end(); ++iter){
638 if (iter->first == 1){
640 // Deal with family name.
642 NameSurname = iter->second;
644 } else if (iter->first == 2){
646 // Deal with given names.
648 NameForename = iter->second;
650 } else if (iter->first == 3){
652 // Deal with additional names.
654 NameOtherNames = iter->second;
656 } else if (iter->first == 4){
658 // Deal with honorifix prefixes and suffixes.
660 NameTitle = iter->second;
664 if (iter == NameValues.end()){
670 NameSuffix = iter->second;
676 // Add the name token data.
678 if (!PropertyTokens.IsEmpty()){
680 NameTokens = PropertyTokens;
686 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
688 std::map<int, int> SplitPoints;
689 std::map<int, int> SplitLength;
691 int intPrevValue = 10;
694 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
698 PropertyType PropType = PROPERTY_NONE;
700 // Look for type before continuing.
702 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
706 std::map<int, wxString> *NicknamesList = NULL;
707 std::map<int, wxString> *NicknamesListType = NULL;
708 std::map<int, wxString> *NicknamesListLanguage = NULL;
709 std::map<int, wxString> *NicknamesListAltID = NULL;
710 std::map<int, wxString> *NicknamesListPID = NULL;
711 std::map<int, wxString> *NicknamesListTokens = NULL;
712 std::map<int, int> *NicknamesListPref = NULL;
716 NicknamesList = &GeneralNicknamesList;
717 NicknamesListType = &GeneralNicknamesListType;
718 NicknamesListLanguage = &GeneralNicknamesListLanguage;
719 NicknamesListAltID = &GeneralNicknamesListAltID;
720 NicknamesListPID = &GeneralNicknamesListPID;
721 NicknamesListTokens = &GeneralNicknamesListTokens;
722 NicknamesListPref = &GeneralNicknamesListPref;
725 NicknamesList = &HomeNicknamesList;
726 NicknamesListType = &HomeNicknamesListType;
727 NicknamesListLanguage = &HomeNicknamesListLanguage;
728 NicknamesListAltID = &HomeNicknamesListAltID;
729 NicknamesListPID = &HomeNicknamesListPID;
730 NicknamesListTokens = &HomeNicknamesListTokens;
731 NicknamesListPref = &HomeNicknamesListPref;
734 NicknamesList = &BusinessNicknamesList;
735 NicknamesListType = &BusinessNicknamesListType;
736 NicknamesListLanguage = &BusinessNicknamesListLanguage;
737 NicknamesListAltID = &BusinessNicknamesListAltID;
738 NicknamesListPID = &BusinessNicknamesListPID;
739 NicknamesListTokens = &BusinessNicknamesListTokens;
740 NicknamesListPref = &BusinessNicknamesListPref;
744 std::map<int, int>::iterator SLiter;
745 wxString PropertyData;
746 wxString PropertyName;
747 wxString PropertyValue;
748 wxString PropertyTokens;
749 bool FirstToken = TRUE;
751 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
752 intiter != SplitPoints.end(); ++intiter){
754 SLiter = SplitLength.find(intiter->first);
756 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
758 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
759 PropertyName = PropertyElement.GetNextToken();
760 PropertyValue = PropertyElement.GetNextToken();
762 intPrevValue = intiter->second;
764 CaptureString(&PropertyValue, FALSE);
766 if (PropertyName == wxT("ALTID")){
768 NicknamesListAltID->erase(*NicknameCount);
769 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
771 } else if (PropertyName == wxT("PID")){
773 NicknamesListPID->erase(*NicknameCount);
774 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
776 } else if (PropertyName == wxT("PREF")){
778 int PriorityNumber = 0;
779 bool ValidNumber = TRUE;
782 PriorityNumber = std::stoi(PropertyValue.ToStdString());
785 catch(std::invalid_argument &e){
789 if (ValidNumber == TRUE){
791 NicknamesListPref->erase(*NicknameCount);
792 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
796 } else if (PropertyName == wxT("LANGUAGE")){
798 NicknamesListLanguage->erase(*NicknameCount);
799 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
803 // Something else we don't know about so append
804 // to the tokens variable.
806 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
808 if (FirstToken == TRUE){
810 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
815 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
825 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
827 // Add the name token data.
829 if (!PropertyTokens.IsEmpty()){
831 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
837 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
839 std::map<int, int> SplitPoints;
840 std::map<int, int> SplitLength;
841 std::map<int, int>::iterator SLiter;
842 wxString PropertyData;
843 wxString PropertyName;
844 wxString PropertyValue;
845 wxString PropertyTokens;
846 bool FirstToken = TRUE;
847 int intPrevValue = 8;
849 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
853 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
854 intiter != SplitPoints.end(); ++intiter){
856 SLiter = SplitLength.find(intiter->first);
858 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
860 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
861 PropertyName = PropertyElement.GetNextToken();
862 PropertyValue = PropertyElement.GetNextToken();
864 intPrevValue = intiter->second;
866 // Process properties.
868 size_t intPropertyValueLen = PropertyValue.Len();
870 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
872 PropertyValue.Trim();
873 PropertyValue.RemoveLast();
877 if (PropertyValue.Mid(0, 1) == wxT("\"")){
879 PropertyValue.Remove(0, 1);
883 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
885 if (FirstToken == TRUE){
887 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
892 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
900 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
902 wxString GenderComponent;
904 if (GenderData.CountTokens() >= 2){
906 Gender = GenderData.GetNextToken();
907 GenderDetails = GenderData.GetString();
909 CaptureString(&GenderDetails, FALSE);
913 Gender = GenderData.GetNextToken();
917 if (!PropertyTokens.IsEmpty()){
919 GenderTokens = PropertyTokens;
925 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
927 // Process date. Preserve the remainder in the string.
929 std::map<int, int> SplitPoints;
930 std::map<int, int> SplitLength;
931 std::map<int, int>::iterator SLiter;
932 wxString PropertyData;
933 wxString PropertyName;
934 wxString PropertyValue;
935 wxString PropertyTokens;
936 bool BirthdayText = FALSE;
937 int intPrevValue = 6;
939 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
943 // Look for type before continuing.
945 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
946 intiter != SplitPoints.end(); ++intiter){
948 SLiter = SplitLength.find(intiter->first);
950 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
952 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
953 PropertyName = PropertyElement.GetNextToken();
954 PropertyValue = PropertyElement.GetNextToken();
956 intPrevValue = intiter->second;
958 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
960 CaptureString(&PropertySeg2, FALSE);
961 Birthday = PropertySeg2;
968 // Setup blank lines for later on.
971 bool FirstToken = TRUE;
973 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
974 intiter != SplitPoints.end(); ++intiter){
976 SLiter = SplitLength.find(intiter->first);
978 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
980 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
981 PropertyName = PropertyElement.GetNextToken();
982 PropertyValue = PropertyElement.GetNextToken();
984 intPrevValue = intiter->second;
986 // Process properties.
988 CaptureString(&PropertyValue, FALSE);
990 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
992 PropertyValue.Trim();
993 PropertyValue.RemoveLast();
997 if (PropertyValue.Mid(0, 1) == wxT("\"")){
999 PropertyValue.Remove(0, 1);
1003 if (PropertyName == wxT("ALTID")){
1005 BirthdayAltID = PropertyValue;
1007 } else if (PropertyName == wxT("CALSCALE")){
1009 BirthdayCalScale = PropertyValue;
1011 } else if (PropertyName != wxT("VALUE")) {
1013 // Something else we don't know about so append
1014 // to the tokens variable.
1016 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1018 if (FirstToken == TRUE){
1020 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1025 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1035 // Add the data to the variables and form.
1037 if (BirthdayText == FALSE){
1039 Birthday = PropertySeg2;
1043 if (!PropertyTokens.IsEmpty()){
1045 BirthdayTokens = PropertyTokens;
1051 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1053 // Process date. Preserve the remainder in the string.
1055 std::map<int, int> SplitPoints;
1056 std::map<int, int> SplitLength;
1057 std::map<int, int>::iterator SLiter;
1058 wxString PropertyData;
1059 wxString PropertyName;
1060 wxString PropertyValue;
1061 wxString PropertyTokens;
1062 bool AnniversaryText = FALSE;
1063 int intPrevValue = 13;
1065 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1069 // Look for type before continuing.
1071 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1072 intiter != SplitPoints.end(); ++intiter){
1074 SLiter = SplitLength.find(intiter->first);
1076 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1078 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1079 PropertyName = PropertyElement.GetNextToken();
1080 PropertyValue = PropertyElement.GetNextToken();
1082 intPrevValue = intiter->second;
1084 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1086 CaptureString(&PropertySeg2, FALSE);
1087 Anniversary = PropertySeg2;
1088 AnniversaryText = TRUE;
1094 // Setup blank lines for later on.
1097 bool FirstToken = TRUE;
1099 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1100 intiter != SplitPoints.end(); ++intiter){
1102 SLiter = SplitLength.find(intiter->first);
1104 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1106 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1107 PropertyName = PropertyElement.GetNextToken();
1108 PropertyValue = PropertyElement.GetNextToken();
1110 intPrevValue = intiter->second;
1112 // Process properties.
1114 CaptureString(&PropertyValue, FALSE);
1116 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1118 PropertyValue.Trim();
1119 PropertyValue.RemoveLast();
1123 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1125 PropertyValue.Remove(0, 1);
1129 if (PropertyName == wxT("ALTID")){
1131 AnniversaryAltID = PropertyValue;
1133 } else if (PropertyName == wxT("CALSCALE")){
1135 AnniversaryCalScale = PropertyValue;
1137 } else if (PropertyName != wxT("VALUE")) {
1139 // Something else we don't know about so append
1140 // to the tokens variable.
1142 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1144 if (FirstToken == TRUE){
1146 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1151 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1161 // Add the data to the variables and form.
1163 if (AnniversaryText == FALSE){
1165 Anniversary = PropertySeg2;
1169 if (!PropertyTokens.IsEmpty()){
1171 AnniversaryTokens = PropertyTokens;
1177 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1179 std::map<int, int> SplitPoints;
1180 std::map<int, int> SplitLength;
1182 int intPrevValue = 4;
1185 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1189 PropertyType PropType = PROPERTY_NONE;
1191 // Look for type before continuing.
1193 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1197 std::map<int, wxString> *TZList = NULL;
1198 std::map<int, wxString> *TZListType = NULL;
1199 std::map<int, wxString> *TZListMediatype = NULL;
1200 std::map<int, wxString> *TZListAltID = NULL;
1201 std::map<int, wxString> *TZListPID = NULL;
1202 std::map<int, wxString> *TZListTokens = NULL;
1203 std::map<int, int> *TZListPref = NULL;
1207 TZList = &GeneralTZList;
1208 TZListType = &GeneralTZListType;
1209 TZListMediatype = &GeneralTZListMediatype;
1210 TZListAltID = &GeneralTZListAltID;
1211 TZListPID = &GeneralTZListPID;
1212 TZListTokens = &GeneralTZListTokens;
1213 TZListPref = &GeneralTZListPref;
1216 TZList = &HomeTZList;
1217 TZListType = &HomeTZListType;
1218 TZListMediatype = &HomeTZListMediatype;
1219 TZListAltID = &HomeTZListAltID;
1220 TZListPID = &HomeTZListPID;
1221 TZListTokens = &HomeTZListTokens;
1222 TZListPref = &HomeTZListPref;
1225 TZList = &BusinessTZList;
1226 TZListType = &BusinessTZListType;
1227 TZListMediatype = &BusinessTZListMediatype;
1228 TZListAltID = &BusinessTZListAltID;
1229 TZListPID = &BusinessTZListPID;
1230 TZListTokens = &BusinessTZListTokens;
1231 TZListPref = &BusinessTZListPref;
1235 std::map<int, int>::iterator SLiter;
1236 wxString PropertyData;
1237 wxString PropertyName;
1238 wxString PropertyValue;
1239 wxString PropertyTokens;
1240 bool FirstToken = TRUE;
1242 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1243 intiter != SplitPoints.end(); ++intiter){
1245 SLiter = SplitLength.find(intiter->first);
1247 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1249 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1250 PropertyName = PropertyElement.GetNextToken();
1251 PropertyValue = PropertyElement.GetNextToken();
1253 intPrevValue = intiter->second;
1255 CaptureString(&PropertyValue, FALSE);
1257 if (PropertyName == wxT("ALTID")){
1259 TZListAltID->erase(*TimeZoneCount);
1260 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1262 } else if (PropertyName == wxT("PID")){
1264 TZListPID->erase(*TimeZoneCount);
1265 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1267 } else if (PropertyName == wxT("PREF")){
1269 int PriorityNumber = 0;
1270 bool ValidNumber = TRUE;
1273 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1276 catch(std::invalid_argument &e){
1277 ValidNumber = FALSE;
1280 if (ValidNumber == TRUE){
1282 TZListPref->erase(*TimeZoneCount);
1283 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1287 } else if (PropertyName == wxT("MEDIATYPE")){
1289 TZListMediatype->erase(*TimeZoneCount);
1290 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1294 // Something else we don't know about so append
1295 // to the tokens variable.
1297 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1299 if (FirstToken == TRUE){
1301 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1306 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1316 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1318 // Add the name token data.
1320 if (!PropertyTokens.IsEmpty()){
1322 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1329 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1331 size_t intPropertyLen = PropertySeg1.Len();
1332 std::map<int, int> SplitPoints;
1333 std::map<int, int> SplitLength;
1334 std::map<int, int>::iterator SLiter;
1335 wxString PropertyData;
1336 wxString PropertyName;
1337 wxString PropertyValue;
1338 wxString PropertyTokens;
1339 wxString AddressLabel;
1340 wxString AddressLang;
1341 wxString AddressAltID;
1342 wxString AddressPID;
1343 wxString AddressTokens;
1344 wxString AddressGeo;
1345 wxString AddressTimezone;
1346 wxString AddressType;
1347 wxString AddressMediatype;
1348 wxString AddressPOBox;
1349 wxString AddressExtended;
1350 wxString AddressStreet;
1351 wxString AddressLocality;
1352 wxString AddressCity;
1353 wxString AddressRegion;
1354 wxString AddressPostalCode;
1355 wxString AddressCountry;
1356 bool FirstToken = TRUE;
1357 int intSplitsFound = 0;
1358 int intSplitSize = 0;
1359 int intPrevValue = 5;
1364 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1368 PropertyType PropType = PROPERTY_NONE;
1370 // Look for type before continuing.
1372 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1376 std::map<int, wxString> *AddressList = NULL;
1377 std::map<int, wxString> *AddressListTown = NULL;
1378 std::map<int, wxString> *AddressListCounty = NULL;
1379 std::map<int, wxString> *AddressListPostCode = NULL;
1380 std::map<int, wxString> *AddressListCountry = NULL;
1381 std::map<int, wxString> *AddressListLabel = NULL;
1382 std::map<int, wxString> *AddressListLang = NULL;
1383 std::map<int, wxString> *AddressListAltID = NULL;
1384 std::map<int, wxString> *AddressListPID = NULL;
1385 std::map<int, wxString> *AddressListTokens = NULL;
1386 std::map<int, wxString> *AddressListGeo = NULL;
1387 std::map<int, wxString> *AddressListTimezone = NULL;
1388 std::map<int, wxString> *AddressListType = NULL;
1389 std::map<int, wxString> *AddressListMediatype = NULL;
1390 std::map<int, int> *AddressListPref = NULL;
1394 AddressList = &GeneralAddressList;
1395 AddressListTown = &GeneralAddressListTown;
1396 AddressListCounty = &GeneralAddressListCounty;
1397 AddressListPostCode = &GeneralAddressListPostCode;
1398 AddressListCountry = &GeneralAddressListCountry;
1399 AddressListLabel = &GeneralAddressListLabel;
1400 AddressListLang = &GeneralAddressListLang;
1401 AddressListAltID = &GeneralAddressListAltID;
1402 AddressListPID = &GeneralAddressListPID;
1403 AddressListTokens = &GeneralAddressListTokens;
1404 AddressListGeo = &GeneralAddressListGeo;
1405 AddressListTimezone = &GeneralAddressListTimezone;
1406 AddressListType = &GeneralAddressListType;
1407 AddressListMediatype = &GeneralAddressListMediatype;
1408 AddressListPref = &GeneralAddressListPref;
1411 AddressList = &HomeAddressList;
1412 AddressListTown = &HomeAddressListTown;
1413 AddressListCounty = &HomeAddressListCounty;
1414 AddressListPostCode = &HomeAddressListPostCode;
1415 AddressListCountry = &HomeAddressListCountry;
1416 AddressListLabel = &HomeAddressListLabel;
1417 AddressListLang = &HomeAddressListLang;
1418 AddressListAltID = &HomeAddressListAltID;
1419 AddressListPID = &HomeAddressListPID;
1420 AddressListTokens = &HomeAddressListTokens;
1421 AddressListGeo = &HomeAddressListGeo;
1422 AddressListTimezone = &HomeAddressListTimezone;
1423 AddressListType = &HomeAddressListType;
1424 AddressListMediatype = &HomeAddressListMediatype;
1425 AddressListPref = &HomeAddressListPref;
1428 AddressList = &BusinessAddressList;
1429 AddressListTown = &BusinessAddressListTown;
1430 AddressListCounty = &BusinessAddressListCounty;
1431 AddressListPostCode = &BusinessAddressListPostCode;
1432 AddressListCountry = &BusinessAddressListCountry;
1433 AddressListLabel = &BusinessAddressListLabel;
1434 AddressListLang = &BusinessAddressListLang;
1435 AddressListAltID = &BusinessAddressListAltID;
1436 AddressListPID = &BusinessAddressListPID;
1437 AddressListTokens = &BusinessAddressListTokens;
1438 AddressListGeo = &BusinessAddressListGeo;
1439 AddressListTimezone = &BusinessAddressListTimezone;
1440 AddressListType = &BusinessAddressListType;
1441 AddressListMediatype = &BusinessAddressListMediatype;
1442 AddressListPref = &BusinessAddressListPref;
1448 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1449 intiter != SplitPoints.end(); ++intiter){
1451 SLiter = SplitLength.find(intiter->first);
1453 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1455 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1456 PropertyName = PropertyElement.GetNextToken();
1457 PropertyValue = PropertyElement.GetNextToken();
1459 intPrevValue = intiter->second;
1461 CaptureString(&PropertyValue, FALSE);
1463 // Process properties.
1465 if (PropertyName == wxT("LABEL")){
1467 AddressListLabel->erase(*AddressCount);
1468 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1470 } else if (PropertyName == wxT("LANGUAGE")){
1472 AddressListLang->erase(*AddressCount);
1473 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1475 } else if (PropertyName == wxT("ALTID")){
1477 AddressListAltID->erase(*AddressCount);
1478 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1480 } else if (PropertyName == wxT("PID")){
1482 AddressListPID->erase(*AddressCount);
1483 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1485 } else if (PropertyName == wxT("GEO")){
1487 AddressListGeo->erase(*AddressCount);
1488 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1490 } else if (PropertyName == wxT("TZ")){
1492 AddressListTimezone->erase(*AddressCount);
1493 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1495 } else if (PropertyName == wxT("MEDIATYPE")){
1497 AddressListMediatype->erase(*AddressCount);
1498 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1500 } else if (PropertyName == wxT("PREF")){
1502 int PriorityNumber = 0;
1503 bool ValidNumber = TRUE;
1506 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1509 catch(std::invalid_argument &e){
1510 ValidNumber = FALSE;
1513 if (ValidNumber == TRUE){
1515 AddressListPref->erase(*AddressCount);
1516 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1522 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1524 if (FirstToken == TRUE){
1526 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1531 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1541 // Split the address.
1543 //std::map<int, int>::iterator SLiter;
1544 intPropertyLen = PropertySeg2.Len();
1545 SplitPoints.clear();
1546 SplitLength.clear();
1551 for (int i = 0; i <= intPropertyLen; i++){
1555 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1558 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1560 if (intSplitsFound == 6){
1562 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1567 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1577 // Split the data into several parts.
1579 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1580 intiter != SplitPoints.end(); ++intiter){
1582 if (intiter->first == 1){
1584 // Deal with PO Box.
1586 SLiter = SplitLength.find(1);
1588 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1589 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1590 intPrevValue = intiter->second;
1592 } else if (intiter->first == 2){
1594 // Deal with extended address.
1596 SLiter = SplitLength.find(2);
1598 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1599 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1600 intPrevValue = intiter->second;
1602 } else if (intiter->first == 3){
1604 // Deal with street address.
1606 SLiter = SplitLength.find(3);
1608 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1609 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1610 intPrevValue = intiter->second;
1612 } else if (intiter->first == 4){
1614 // Deal with locality
1616 SLiter = SplitLength.find(4);
1618 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1619 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1620 intPrevValue = intiter->second;
1622 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1624 } else if (intiter->first == 5){
1626 // Deal with region.
1628 SLiter = SplitLength.find(5);
1630 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1631 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1632 intPrevValue = intiter->second;
1634 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1636 } else if (intiter->first == 6){
1638 // Deal with post code.
1640 SLiter = SplitLength.find(6);
1642 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1643 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1644 intPrevValue = intiter->second;
1646 // Deal with country.
1648 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1649 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1657 // Add the data to the General/Home/Work address variables.
1659 CaptureString(&AddressStreet, FALSE);
1660 CaptureString(&AddressLocality, FALSE);
1661 CaptureString(&AddressRegion, FALSE);
1662 CaptureString(&AddressPostalCode, FALSE);
1663 CaptureString(&AddressCountry, FALSE);
1665 if (!PropertyTokens.IsEmpty()){
1667 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1671 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1672 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1673 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1674 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1675 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1679 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1682 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1685 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1689 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1693 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1695 std::map<int, int> SplitPoints;
1696 std::map<int, int> SplitLength;
1698 int intPrevValue = 7;
1701 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1705 PropertyType PropType = PROPERTY_NONE;
1707 // Look for type before continuing.
1709 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1711 std::map<int, wxString> *EmailList = NULL;
1712 std::map<int, wxString> *EmailListType = NULL;
1713 std::map<int, wxString> *EmailListAltID = NULL;
1714 std::map<int, wxString> *EmailListPID = NULL;
1715 std::map<int, wxString> *EmailListTokens = NULL;
1716 std::map<int, int> *EmailListPref = NULL;
1720 EmailList = &GeneralEmailList;
1721 EmailListType = &GeneralEmailListType;
1722 EmailListAltID = &GeneralEmailListAltID;
1723 EmailListPID = &GeneralEmailListPID;
1724 EmailListTokens = &GeneralEmailListTokens;
1725 EmailListPref = &GeneralEmailListPref;
1728 EmailList = &HomeEmailList;
1729 EmailListType = &HomeEmailListType;
1730 EmailListAltID = &HomeEmailListAltID;
1731 EmailListPID = &HomeEmailListPID;
1732 EmailListTokens = &HomeEmailListTokens;
1733 EmailListPref = &HomeEmailListPref;
1736 EmailList = &BusinessEmailList;
1737 EmailListType = &BusinessEmailListType;
1738 EmailListAltID = &BusinessEmailListAltID;
1739 EmailListPID = &BusinessEmailListPID;
1740 EmailListTokens = &BusinessEmailListTokens;
1741 EmailListPref = &BusinessEmailListPref;
1747 std::map<int,int>::iterator SLiter;
1748 wxString PropertyData;
1749 wxString PropertyName;
1750 wxString PropertyValue;
1751 wxString PropertyTokens;
1752 bool FirstToken = TRUE;
1754 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1755 intiter != SplitPoints.end(); ++intiter){
1757 SLiter = SplitLength.find(intiter->first);
1759 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1761 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1762 PropertyName = PropertyElement.GetNextToken();
1763 PropertyValue = PropertyElement.GetNextToken();
1765 intPrevValue = intiter->second;
1767 CaptureString(&PropertyValue, FALSE);
1769 // Process properties.
1771 if (PropertyName == wxT("ALTID")){
1773 EmailListAltID->erase(*EmailCount);
1774 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1776 } else if (PropertyName == wxT("PID")){
1778 EmailListPID->erase(*EmailCount);
1779 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1781 } else if (PropertyName == wxT("PREF")){
1783 int PriorityNumber = 0;
1784 bool ValidNumber = TRUE;
1787 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1790 catch(std::invalid_argument &e){
1791 ValidNumber = FALSE;
1794 if (ValidNumber == TRUE){
1796 EmailListPref->erase(*EmailCount);
1797 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1803 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1805 if (FirstToken == TRUE){
1807 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1812 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1822 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1824 // Add the name token data.
1826 if (!PropertyTokens.IsEmpty()){
1828 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1835 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1837 std::map<int, int> SplitPoints;
1838 std::map<int, int> SplitLength;
1840 int intPrevValue = 6;
1843 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1847 PropertyType PropType = PROPERTY_NONE;
1849 // Look for type before continuing.
1851 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1853 std::map<int, wxString> *IMList = NULL;
1854 std::map<int, wxString> *IMListType = NULL;
1855 std::map<int, wxString> *IMListAltID = NULL;
1856 std::map<int, wxString> *IMListPID = NULL;
1857 std::map<int, wxString> *IMListTokens = NULL;
1858 std::map<int, wxString> *IMListMediatype = NULL;
1859 std::map<int, int> *IMListPref = NULL;
1863 IMList = &GeneralIMList;
1864 IMListType = &GeneralIMListType;
1865 IMListAltID = &GeneralIMListAltID;
1866 IMListPID = &GeneralIMListPID;
1867 IMListTokens = &GeneralIMListTokens;
1868 IMListMediatype = &GeneralIMListMediatype;
1869 IMListPref = &GeneralIMListPref;
1872 IMList = &HomeIMList;
1873 IMListType = &HomeIMListType;
1874 IMListAltID = &HomeIMListAltID;
1875 IMListPID = &HomeIMListPID;
1876 IMListTokens = &HomeIMListTokens;
1877 IMListMediatype = &HomeIMListMediatype;
1878 IMListPref = &HomeIMListPref;
1881 IMList = &BusinessIMList;
1882 IMListType = &BusinessIMListType;
1883 IMListAltID = &BusinessIMListAltID;
1884 IMListPID = &BusinessIMListPID;
1885 IMListTokens = &BusinessIMListTokens;
1886 IMListMediatype = &BusinessIMListMediatype;
1887 IMListPref = &BusinessIMListPref;
1893 std::map<int,int>::iterator SLiter;
1894 wxString PropertyData;
1895 wxString PropertyName;
1896 wxString PropertyValue;
1897 wxString PropertyTokens;
1898 bool FirstToken = TRUE;
1900 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1901 intiter != SplitPoints.end(); ++intiter){
1903 SLiter = SplitLength.find(intiter->first);
1905 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1907 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1908 PropertyName = PropertyElement.GetNextToken();
1909 PropertyValue = PropertyElement.GetNextToken();
1911 intPrevValue = intiter->second;
1913 CaptureString(&PropertyValue, FALSE);
1915 // Process properties.
1917 if (PropertyName == wxT("ALTID")){
1919 IMListAltID->erase(*IMCount);
1920 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1922 } else if (PropertyName == wxT("PID")){
1924 IMListPID->erase(*IMCount);
1925 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1927 } else if (PropertyName == wxT("MEDIATYPE")){
1929 IMListMediatype->erase(*IMCount);
1930 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1932 } else if (PropertyName == wxT("PREF")){
1934 int PriorityNumber = 0;
1935 bool ValidNumber = TRUE;
1938 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1941 catch(std::invalid_argument &e){
1942 ValidNumber = FALSE;
1945 if (ValidNumber == TRUE){
1947 IMListPref->erase(*IMCount);
1948 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1954 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1956 if (FirstToken == TRUE){
1958 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1963 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1973 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1975 // Add the name token data.
1977 if (!PropertyTokens.IsEmpty()){
1979 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1985 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1987 std::map<int, int> SplitPoints;
1988 std::map<int, int> SplitLength;
1989 std::map<int, int>::iterator SLiter;
1993 PropertyType PropType = PROPERTY_NONE;
1995 // Look for type before continuing.
1998 wxString TelTypeDetail;
1999 wxString PropertyData;
2000 wxString PropertyName;
2001 wxString PropertyValue;
2002 wxString PropertyTokens;
2004 std::map<int,int> TypeSplitPoints;
2005 std::map<int,int> TypeSplitLength;
2006 std::map<int,int>::iterator TSLiter;
2008 int intSplitSize = 0;
2009 int intSplitsFound = 0;
2010 int intSplitPoint = 0;
2012 int intPrevValue = 5;
2014 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2018 // Look for type before continuing.
2020 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2021 intiter != SplitPoints.end(); ++intiter){
2023 SLiter = SplitLength.find(intiter->first);
2025 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2027 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2028 PropertyName = PropertyElement.GetNextToken();
2029 PropertyValue = PropertyElement.GetNextToken();
2031 intPrevValue = intiter->second;
2033 if (PropertyName == wxT("TYPE")){
2035 // Process each value in type and translate each
2038 // Strip out the quotes if they are there.
2040 size_t intPropertyValueLen = PropertyValue.Len();
2042 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2044 PropertyValue.Trim();
2045 PropertyValue.RemoveLast();
2049 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2051 PropertyValue.Remove(0, 1);
2055 TelTypeDetail = PropertyValue;
2061 for (int i = 0; i <= intPropertyValueLen; i++){
2065 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2067 if (intSplitsFound == 0){
2069 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2070 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2074 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2075 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2088 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2089 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2091 int intTypeSeek = 0;
2093 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2094 typeiter != TypeSplitPoints.end(); ++typeiter){
2096 wxString TypePropertyName;
2098 TSLiter = TypeSplitLength.find(typeiter->first);
2100 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2102 if (intTypeSeek == 0){
2107 TelTypeUI.Append(wxT(","));
2111 if (TypePropertyName == wxT("home")){
2113 PropType = PROPERTY_HOME;
2115 } else if (TypePropertyName == wxT("work")){
2117 PropType = PROPERTY_WORK;
2122 if (TypePropertyName == wxT("text")){
2124 TelTypeUI.Append(_("text"));
2127 } else if (TypePropertyName == wxT("voice")){
2129 TelTypeUI.Append(_("voice"));
2132 } else if (TypePropertyName == wxT("fax")){
2134 TelTypeUI.Append(_("fax"));
2137 } else if (TypePropertyName == wxT("cell")){
2139 TelTypeUI.Append(_("mobile"));
2142 } else if (TypePropertyName == wxT("video")){
2144 TelTypeUI.Append(_("video"));
2147 } else if (TypePropertyName == wxT("pager")){
2149 TelTypeUI.Append(_("pager"));
2152 } else if (TypePropertyName == wxT("textphone")){
2154 TelTypeUI.Append(_("textphone"));
2165 std::map<int, wxString> *TelephoneList = NULL;
2166 std::map<int, wxString> *TelephoneListType = NULL;
2167 std::map<int, wxString> *TelephoneListAltID = NULL;
2168 std::map<int, wxString> *TelephoneListPID = NULL;
2169 std::map<int, wxString> *TelephoneListTokens = NULL;
2170 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2171 std::map<int, int> *TelephoneListPref = NULL;
2175 TelephoneList = &GeneralTelephoneList;
2176 TelephoneListType = &GeneralTelephoneListType;
2177 TelephoneListAltID = &GeneralTelephoneListAltID;
2178 TelephoneListPID = &GeneralTelephoneListPID;
2179 TelephoneListTokens = &GeneralTelephoneListTokens;
2180 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2181 TelephoneListPref = &GeneralTelephoneListPref;
2184 TelephoneList = &HomeTelephoneList;
2185 TelephoneListType = &HomeTelephoneListType;
2186 TelephoneListAltID = &HomeTelephoneListAltID;
2187 TelephoneListPID = &HomeTelephoneListPID;
2188 TelephoneListTokens = &HomeTelephoneListTokens;
2189 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2190 TelephoneListPref = &HomeTelephoneListPref;
2193 TelephoneList = &BusinessTelephoneList;
2194 TelephoneListType = &BusinessTelephoneListType;
2195 TelephoneListAltID = &BusinessTelephoneListAltID;
2196 TelephoneListPID = &BusinessTelephoneListPID;
2197 TelephoneListTokens = &BusinessTelephoneListTokens;
2198 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2199 TelephoneListPref = &BusinessTelephoneListPref;
2203 // Process the properties.
2205 bool FirstToken = TRUE;
2208 SplitPoints.clear();
2209 SplitLength.clear();
2211 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2215 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2216 intiter != SplitPoints.end(); ++intiter){
2218 SLiter = SplitLength.find(intiter->first);
2220 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2222 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2223 PropertyName = PropertyElement.GetNextToken();
2224 PropertyValue = PropertyElement.GetNextToken();
2226 intPrevValue = intiter->second;
2228 CaptureString(&PropertyValue, FALSE);
2230 // Process properties.
2232 if (PropertyName == wxT("ALTID")){
2234 TelephoneListAltID->erase(*TelephoneCount);
2235 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2237 } else if (PropertyName == wxT("PID")){
2239 TelephoneListPID->erase(*TelephoneCount);
2240 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2242 } else if (PropertyName == wxT("PREF")){
2244 int PriorityNumber = 0;
2245 bool ValidNumber = TRUE;
2248 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2251 catch(std::invalid_argument &e){
2252 ValidNumber = FALSE;
2255 if (ValidNumber == TRUE){
2257 TelephoneListPref->erase(*TelephoneCount);
2258 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2264 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2266 if (FirstToken == TRUE){
2268 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2273 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2283 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2284 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2286 // Add the name token data.
2288 if (!PropertyTokens.IsEmpty()){
2290 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2296 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2298 std::map<int, int> SplitPoints;
2299 std::map<int, int> SplitLength;
2301 int intPrevValue = 6;
2304 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2308 PropertyType PropType = PROPERTY_NONE;
2310 // Look for type before continuing.
2312 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2314 std::map<int, wxString> *LanguageList = NULL;
2315 std::map<int, wxString> *LanguageListType = NULL;
2316 std::map<int, wxString> *LanguageListAltID = NULL;
2317 std::map<int, wxString> *LanguageListPID = NULL;
2318 std::map<int, wxString> *LanguageListTokens = NULL;
2319 std::map<int, int> *LanguageListPref = NULL;
2323 LanguageList = &GeneralLanguageList;
2324 LanguageListType = &GeneralLanguageListType;
2325 LanguageListAltID = &GeneralLanguageListAltID;
2326 LanguageListPID = &GeneralLanguageListPID;
2327 LanguageListTokens = &GeneralLanguageListTokens;
2328 LanguageListPref = &GeneralLanguageListPref;
2331 LanguageList = &HomeLanguageList;
2332 LanguageListType = &HomeLanguageListType;
2333 LanguageListAltID = &HomeLanguageListAltID;
2334 LanguageListPID = &HomeLanguageListPID;
2335 LanguageListTokens = &HomeLanguageListTokens;
2336 LanguageListPref = &HomeLanguageListPref;
2339 LanguageList = &BusinessLanguageList;
2340 LanguageListType = &BusinessLanguageListType;
2341 LanguageListAltID = &BusinessLanguageListAltID;
2342 LanguageListPID = &BusinessLanguageListPID;
2343 LanguageListTokens = &BusinessLanguageListTokens;
2344 LanguageListPref = &BusinessLanguageListPref;
2350 std::map<int,int>::iterator SLiter;
2351 wxString PropertyData;
2352 wxString PropertyName;
2353 wxString PropertyValue;
2354 wxString PropertyTokens;
2355 bool FirstToken = TRUE;
2357 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2358 intiter != SplitPoints.end(); ++intiter){
2360 SLiter = SplitLength.find(intiter->first);
2362 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2364 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2365 PropertyName = PropertyElement.GetNextToken();
2366 PropertyValue = PropertyElement.GetNextToken();
2368 intPrevValue = intiter->second;
2370 CaptureString(&PropertyValue, FALSE);
2372 // Process properties.
2374 if (PropertyName == wxT("ALTID")){
2376 LanguageListAltID->erase(*LanguageCount);
2377 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2379 } else if (PropertyName == wxT("PID")){
2381 LanguageListPID->erase(*LanguageCount);
2382 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2384 } else if (PropertyName == wxT("PREF")){
2386 int PriorityNumber = 0;
2387 bool ValidNumber = TRUE;
2390 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2393 catch(std::invalid_argument &e){
2394 ValidNumber = FALSE;
2397 if (ValidNumber == TRUE){
2399 LanguageListPref->erase(*LanguageCount);
2400 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2406 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2408 if (FirstToken == TRUE){
2410 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2415 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2425 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2427 // Add the name token data.
2429 if (!PropertyTokens.IsEmpty()){
2431 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2437 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2439 std::map<int, int> SplitPoints;
2440 std::map<int, int> SplitLength;
2442 int intPrevValue = 5;
2445 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2449 PropertyType PropType = PROPERTY_NONE;
2451 // Look for type before continuing.
2453 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2455 std::map<int, wxString> *GeopositionList = NULL;
2456 std::map<int, wxString> *GeopositionListType = NULL;
2457 std::map<int, wxString> *GeopositionListAltID = NULL;
2458 std::map<int, wxString> *GeopositionListPID = NULL;
2459 std::map<int, wxString> *GeopositionListTokens = NULL;
2460 std::map<int, wxString> *GeopositionListMediatype = NULL;
2461 std::map<int, int> *GeopositionListPref = NULL;
2465 GeopositionList = &GeneralGeographyList;
2466 GeopositionListType = &GeneralGeographyListType;
2467 GeopositionListAltID = &GeneralGeographyListAltID;
2468 GeopositionListPID = &GeneralGeographyListPID;
2469 GeopositionListTokens = &GeneralGeographyListTokens;
2470 GeopositionListMediatype = &GeneralGeographyListMediatype;
2471 GeopositionListPref = &GeneralGeographyListPref;
2474 GeopositionList = &HomeGeographyList;
2475 GeopositionListType = &HomeGeographyListType;
2476 GeopositionListAltID = &HomeGeographyListAltID;
2477 GeopositionListPID = &HomeGeographyListPID;
2478 GeopositionListTokens = &HomeGeographyListTokens;
2479 GeopositionListMediatype = &HomeGeographyListMediatype;
2480 GeopositionListPref = &HomeGeographyListPref;
2483 GeopositionList = &BusinessGeographyList;
2484 GeopositionListType = &BusinessGeographyListType;
2485 GeopositionListAltID = &BusinessGeographyListAltID;
2486 GeopositionListPID = &BusinessGeographyListPID;
2487 GeopositionListTokens = &BusinessGeographyListTokens;
2488 GeopositionListMediatype = &BusinessGeographyListMediatype;
2489 GeopositionListPref = &BusinessGeographyListPref;
2495 std::map<int,int>::iterator SLiter;
2496 wxString PropertyData;
2497 wxString PropertyName;
2498 wxString PropertyValue;
2499 wxString PropertyTokens;
2500 bool FirstToken = TRUE;
2502 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2503 intiter != SplitPoints.end(); ++intiter){
2505 SLiter = SplitLength.find(intiter->first);
2507 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2509 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2510 PropertyName = PropertyElement.GetNextToken();
2511 PropertyValue = PropertyElement.GetNextToken();
2513 intPrevValue = intiter->second;
2515 CaptureString(&PropertyValue, FALSE);
2517 // Process properties.
2519 if (PropertyName == wxT("ALTID")){
2521 GeopositionListAltID->erase(*GeographicCount);
2522 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2524 } else if (PropertyName == wxT("PID")){
2526 GeopositionListPID->erase(*GeographicCount);
2527 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2529 } else if (PropertyName == wxT("MEDIATYPE")){
2531 GeopositionListMediatype->erase(*GeographicCount);
2532 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2534 } else if (PropertyName == wxT("PREF")){
2536 int PriorityNumber = 0;
2537 bool ValidNumber = TRUE;
2540 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2543 catch(std::invalid_argument &e){
2544 ValidNumber = FALSE;
2547 if (ValidNumber == TRUE){
2549 GeopositionListPref->erase(*GeographicCount);
2550 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2556 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2558 if (FirstToken == TRUE){
2560 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2565 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2575 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2577 // Add the name token data.
2579 if (!PropertyTokens.IsEmpty()){
2581 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2587 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2589 size_t intPropertyLen = PropertySeg1.Len();
2590 std::map<int, int> SplitPoints;
2591 std::map<int, int> SplitLength;
2592 std::map<int, int>::iterator SLiter;
2593 wxString PropertyData;
2594 wxString PropertyName;
2595 wxString PropertyValue;
2596 wxString PropertyTokens;
2597 wxString RelatedType;
2598 wxString RelatedTypeOriginal;
2599 wxString RelatedName;
2600 bool FirstToken = TRUE;
2601 int intSplitsFound = 0;
2602 int intSplitSize = 0;
2603 int intPrevValue = 9;
2607 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2611 // Look for type before continuing.
2613 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2614 intiter != SplitPoints.end(); ++intiter){
2616 SLiter = SplitLength.find(intiter->first);
2618 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2620 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2621 PropertyName = PropertyElement.GetNextToken();
2622 PropertyValue = PropertyElement.GetNextToken();
2624 intPrevValue = intiter->second;
2628 RelatedTypeOriginal = PropertyValue;
2630 if (PropertyName == wxT("TYPE")){
2632 if (PropertyValue == wxT("contact")){
2634 RelatedType = _("Contact");
2636 } else if (PropertyValue == wxT("acquaintance")){
2638 RelatedType = _("Acquaintance");
2640 } else if (PropertyValue == wxT("friend")){
2642 RelatedType = _("Friend");
2644 } else if (PropertyValue == wxT("met")){
2646 RelatedType = _("Met");
2648 } else if (PropertyValue == wxT("co-worker")){
2650 RelatedType = _("Co-worker");
2652 } else if (PropertyValue == wxT("colleague")){
2654 RelatedType = _("Colleague");
2656 } else if (PropertyValue == wxT("co-resident")){
2658 RelatedType = _("Co-resident");
2660 } else if (PropertyValue == wxT("neighbor")){
2662 RelatedType = _("Neighbour");
2664 } else if (PropertyValue == wxT("child")){
2666 RelatedType = _("Child");
2668 } else if (PropertyValue == wxT("parent")){
2670 RelatedType = _("Parent");
2672 } else if (PropertyValue == wxT("sibling")){
2674 RelatedType = _("Sibling");
2676 } else if (PropertyValue == wxT("spouse")){
2678 RelatedType = _("Spouse");
2680 } else if (PropertyValue == wxT("kin")){
2682 RelatedType = _("Kin");
2684 } else if (PropertyValue == wxT("muse")){
2686 RelatedType = _("Muse");
2688 } else if (PropertyValue == wxT("crush")){
2690 RelatedType = _("Crush");
2692 } else if (PropertyValue == wxT("date")){
2694 RelatedType = _("Date");
2696 } else if (PropertyValue == wxT("sweetheart")){
2698 RelatedType = _("Sweetheart");
2700 } else if (PropertyValue == wxT("me")){
2702 RelatedType = _("Me");
2704 } else if (PropertyValue == wxT("agent")){
2706 RelatedType = _("Agent");
2708 } else if (PropertyValue == wxT("emergency")){
2710 RelatedType = _("Emergency");
2714 RelatedType = PropertyValue;
2724 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2725 intiter != SplitPoints.end(); ++intiter){
2727 SLiter = SplitLength.find(intiter->first);
2729 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2731 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2732 PropertyName = PropertyElement.GetNextToken();
2733 PropertyValue = PropertyElement.GetNextToken();
2735 intPrevValue = intiter->second;
2737 // Process properties.
2739 size_t intPropertyValueLen = PropertyValue.Len();
2741 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2743 PropertyValue.Trim();
2744 PropertyValue.RemoveLast();
2748 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2750 PropertyValue.Remove(0, 1);
2754 CaptureString(&PropertyValue, FALSE);
2756 if (PropertyName == wxT("ALTID")){
2758 GeneralRelatedListAltID.erase(*RelatedCount);
2759 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2761 } else if (PropertyName == wxT("PID")){
2763 GeneralRelatedListPID.erase(*RelatedCount);
2764 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2766 } else if (PropertyName == wxT("PREF")){
2768 int PriorityNumber = 0;
2769 bool ValidNumber = TRUE;
2772 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2775 catch(std::invalid_argument &e){
2776 ValidNumber = FALSE;
2779 if (ValidNumber == TRUE){
2781 GeneralRelatedListPref.erase(*RelatedCount);
2782 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2786 } else if (PropertyName == wxT("LANGUAGE")){
2788 GeneralRelatedListLanguage.erase(*RelatedCount);
2789 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2791 } else if (PropertyName != wxT("TYPE")) {
2793 // Something else we don't know about so append
2794 // to the tokens variable.
2796 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2798 if (FirstToken == TRUE){
2800 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2805 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2815 // Add the data to the General/Home/Work address variables.
2817 GeneralRelatedList.erase(*RelatedCount);
2818 GeneralRelatedListRelType.erase(*RelatedCount);
2819 GeneralRelatedListType.erase(*RelatedCount);
2820 GeneralRelatedListTokens.erase(*RelatedCount);
2821 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2822 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2823 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2824 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2828 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2830 std::map<int, int> SplitPoints;
2831 std::map<int, int> SplitLength;
2832 std::map<int, int>::iterator SLiter;
2833 wxString PropertyData;
2834 wxString PropertyName;
2835 wxString PropertyValue;
2836 wxString PropertyTokens;
2837 bool FirstToken = TRUE;
2838 int intPrevValue = 5;
2843 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2847 PropertyType PropType = PROPERTY_NONE;
2849 // Look for type before continuing.
2851 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2853 // Setup the pointers.
2855 std::map<int, wxString> *WebsiteList = NULL;
2856 std::map<int, wxString> *WebsiteListAltID = NULL;
2857 std::map<int, wxString> *WebsiteListPID = NULL;
2858 std::map<int, wxString> *WebsiteListType = NULL;
2859 std::map<int, wxString> *WebsiteListTokens = NULL;
2860 std::map<int, wxString> *WebsiteListMediatype = NULL;
2861 std::map<int, int> *WebsiteListPref = NULL;
2863 // Setup blank lines for later on.
2867 WebsiteList = &GeneralWebsiteList;
2868 WebsiteListType = &GeneralWebsiteListType;
2869 WebsiteListAltID = &GeneralWebsiteListAltID;
2870 WebsiteListPID = &GeneralWebsiteListPID;
2871 WebsiteListTokens = &GeneralWebsiteListTokens;
2872 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2873 WebsiteListPref = &GeneralWebsiteListPref;
2876 WebsiteList = &HomeWebsiteList;
2877 WebsiteListType = &HomeWebsiteListType;
2878 WebsiteListAltID = &HomeWebsiteListAltID;
2879 WebsiteListPID = &HomeWebsiteListPID;
2880 WebsiteListTokens = &HomeWebsiteListTokens;
2881 WebsiteListMediatype = &HomeWebsiteListMediatype;
2882 WebsiteListPref = &HomeWebsiteListPref;
2885 WebsiteList = &BusinessWebsiteList;
2886 WebsiteListType = &BusinessWebsiteListType;
2887 WebsiteListAltID = &BusinessWebsiteListAltID;
2888 WebsiteListPID = &BusinessWebsiteListPID;
2889 WebsiteListTokens = &BusinessWebsiteListTokens;
2890 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2891 WebsiteListPref = &BusinessWebsiteListPref;
2897 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2898 intiter != SplitPoints.end(); ++intiter){
2900 SLiter = SplitLength.find(intiter->first);
2902 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2904 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2905 PropertyName = PropertyElement.GetNextToken();
2906 PropertyValue = PropertyElement.GetNextToken();
2908 intPrevValue = intiter->second;
2910 // Process properties.
2912 size_t intPropertyValueLen = PropertyValue.Len();
2914 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2916 PropertyValue.Trim();
2917 PropertyValue.RemoveLast();
2921 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2923 PropertyValue.Remove(0, 1);
2927 CaptureString(&PropertyValue, FALSE);
2929 if (PropertyName == wxT("ALTID")){
2931 WebsiteListAltID->erase(*URLCount);
2932 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2934 } else if (PropertyName == wxT("PID")){
2936 WebsiteListPID->erase(*URLCount);
2937 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2939 } else if (PropertyName == wxT("PREF")){
2941 int PriorityNumber = 0;
2942 bool ValidNumber = TRUE;
2945 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2948 catch(std::invalid_argument &e){
2949 ValidNumber = FALSE;
2952 if (ValidNumber == TRUE){
2954 WebsiteListPref->erase(*URLCount);
2955 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2959 } else if (PropertyName == wxT("MEDIATYPE")){
2961 WebsiteListMediatype->erase(*URLCount);
2962 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2966 // Something else we don't know about so append
2967 // to the tokens variable.
2969 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2971 if (FirstToken == TRUE){
2973 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2978 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2988 // Add the data to the General/Home/Work address variables.
2990 CaptureString(&PropertySeg2, FALSE);
2992 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2994 if (!PropertyTokens.IsEmpty()){
2996 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3002 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3004 std::map<int, int> SplitPoints;
3005 std::map<int, int> SplitLength;
3006 std::map<int, int>::iterator SLiter;
3007 wxString PropertyData;
3008 wxString PropertyName;
3009 wxString PropertyValue;
3010 wxString PropertyTokens;
3011 bool FirstToken = TRUE;
3012 int intPrevValue = 7;
3017 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3021 PropertyType PropType = PROPERTY_NONE;
3023 // Look for type before continuing.
3025 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3027 // Setup the pointers.
3029 std::map<int, wxString> *TitleList = NULL;
3030 std::map<int, wxString> *TitleListAltID = NULL;
3031 std::map<int, wxString> *TitleListPID = NULL;
3032 std::map<int, wxString> *TitleListType = NULL;
3033 std::map<int, wxString> *TitleListTokens = NULL;
3034 std::map<int, wxString> *TitleListLanguage = NULL;
3035 std::map<int, int> *TitleListPref = NULL;
3037 // Setup blank lines for later on.
3041 TitleList = &GeneralTitleList;
3042 TitleListType = &GeneralTitleListType;
3043 TitleListAltID = &GeneralTitleListAltID;
3044 TitleListPID = &GeneralTitleListPID;
3045 TitleListTokens = &GeneralTitleListTokens;
3046 TitleListLanguage = &GeneralTitleListLanguage;
3047 TitleListPref = &GeneralTitleListPref;
3050 TitleList = &HomeTitleList;
3051 TitleListType = &HomeTitleListType;
3052 TitleListAltID = &HomeTitleListAltID;
3053 TitleListPID = &HomeTitleListPID;
3054 TitleListTokens = &HomeTitleListTokens;
3055 TitleListLanguage = &HomeTitleListLanguage;
3056 TitleListPref = &HomeTitleListPref;
3059 TitleList = &BusinessTitleList;
3060 TitleListType = &BusinessTitleListType;
3061 TitleListAltID = &BusinessTitleListAltID;
3062 TitleListPID = &BusinessTitleListPID;
3063 TitleListTokens = &BusinessTitleListTokens;
3064 TitleListLanguage = &BusinessTitleListLanguage;
3065 TitleListPref = &BusinessTitleListPref;
3071 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3072 intiter != SplitPoints.end(); ++intiter){
3074 SLiter = SplitLength.find(intiter->first);
3076 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3078 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3079 PropertyName = PropertyElement.GetNextToken();
3080 PropertyValue = PropertyElement.GetNextToken();
3082 intPrevValue = intiter->second;
3084 // Process properties.
3086 size_t intPropertyValueLen = PropertyValue.Len();
3088 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3090 PropertyValue.Trim();
3091 PropertyValue.RemoveLast();
3095 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3097 PropertyValue.Remove(0, 1);
3101 CaptureString(&PropertyValue, FALSE);
3103 if (PropertyName == wxT("ALTID")){
3105 TitleListAltID->erase(*TitleCount);
3106 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3108 } else if (PropertyName == wxT("PID")){
3110 TitleListPID->erase(*TitleCount);
3111 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3113 } else if (PropertyName == wxT("PREF")){
3115 int PriorityNumber = 0;
3116 bool ValidNumber = TRUE;
3119 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3122 catch(std::invalid_argument &e){
3123 ValidNumber = FALSE;
3126 if (ValidNumber == TRUE){
3128 TitleListPref->erase(*TitleCount);
3129 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3133 } else if (PropertyName == wxT("LANGUAGE")){
3135 TitleListLanguage->erase(*TitleCount);
3136 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3140 // Something else we don't know about so append
3141 // to the tokens variable.
3143 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3145 if (FirstToken == TRUE){
3147 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3152 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3162 // Add the data to the General/Home/Work address variables.
3164 CaptureString(&PropertySeg2, FALSE);
3166 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3168 if (!PropertyTokens.IsEmpty()){
3170 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3176 void SplitValues(wxString *PropertyLine,
3177 std::map<int,int> *SplitPoints,
3178 std::map<int,int> *SplitLength,
3181 size_t intPropertyLen = PropertyLine->Len();
3182 int intSplitsFound = 0;
3183 int intSplitSize = 0;
3184 int intSplitSeek = 0;
3186 for (int i = intSize; i <= intPropertyLen; i++){
3190 if (PropertyLine->Mid(i, 1) == wxT(";") &&
3191 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
3193 if (intSplitsFound == 0){
3195 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
3199 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3203 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
3213 if (intSplitsFound == 0){
3215 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
3216 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3220 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3221 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3227 void CheckType(wxString *PropertySeg1,
3228 std::map<int,int> *SplitPoints,
3229 std::map<int,int> *SplitLength,
3231 PropertyType *PropType){
3233 wxString PropertyData;
3234 wxString PropertyName;
3235 wxString PropertyValue;
3236 std::map<int,int>::iterator SLiter;
3238 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
3239 intiter != SplitPoints->end(); ++intiter){
3241 SLiter = SplitLength->find(intiter->first);
3243 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
3245 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3246 PropertyName = PropertyElement.GetNextToken();
3247 PropertyValue = PropertyElement.GetNextToken();
3249 *intPrevValue = intiter->second;
3251 if (PropertyName == wxT("TYPE")){
3253 if (PropertyValue == wxT("work")){
3255 *PropType = PROPERTY_WORK;
3257 } else if (PropertyValue == wxT("home")){
3259 *PropType = PROPERTY_HOME;
3263 *PropType = PROPERTY_NONE;