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 wxString PropertyLine;
91 wxString PropertySeg1;
92 wxString PropertySeg2;
93 wxString PropertyNextLine;
96 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
97 iter != ContactFileLines.end(); ++iter){
105 PropertyLine.Clear();
106 PropertySeg1.Clear();
107 PropertySeg2.Clear();
110 ContactLine = iter->second;
112 while (ExtraLineSeek == TRUE){
114 // Check if there is extra data on the next line
115 // (indicated by space or tab at the start) and add data.
119 if (iter == ContactFileLines.end()){
126 PropertyNextLine = iter->second;
128 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
130 PropertyNextLine.Remove(0, 1);
131 ContactLine.Append(PropertyNextLine);
136 ExtraLineSeek = FALSE;
142 ContactLineLen = ContactLine.Len();
144 // Make sure we are not in quotation mode.
145 // Make sure colon does not have \ or \\ before it.
147 for (int i = 0; i <= ContactLineLen; i++){
149 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
151 PropertyFind = FALSE;
153 } else if (PropertyFind == TRUE){
155 Property.Append(ContactLine.Mid(i, 1));
159 if (ContactLine.Mid(i, 1) == wxT("\"")){
161 if (QuoteMode == TRUE){
173 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
182 // Split that line at the point into two variables (ignore the colon).
184 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
185 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
187 if (Property == wxT("KIND") && KindProcessed == FALSE){
189 ProcessKind(PropertySeg2);
191 } else if (Property == wxT("MEMBER")){
193 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
196 } else if (Property == wxT("FN")){
198 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
201 } else if (Property == wxT("N") && NameProcessed == FALSE){
203 ProcessN(PropertySeg1, PropertySeg2);
204 NameProcessed = TRUE;
206 } else if (Property == wxT("NICKNAME")){
208 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
211 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
213 ProcessGender(PropertySeg1, PropertySeg2);
214 GenderProcessed = TRUE;
216 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
218 ProcessBirthday(PropertySeg1, PropertySeg2);
219 BirthdayProcessed = TRUE;
221 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
223 ProcessAnniversary(PropertySeg1, PropertySeg2);
224 AnniversaryProcessed = TRUE;
226 } else if (Property == wxT("TZ")){
228 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
231 } else if (Property == wxT("ADR")){
233 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
236 } else if (Property == wxT("EMAIL")){
238 // See frmContactEditor-LoadEmail.cpp
240 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
247 return CONTACTLOAD_OK;
251 void ContactDataObject::ProcessKind(wxString KindType){
253 if (KindType == wxT("individual")){
255 ContactKind = CONTACTKIND_INDIVIDUAL;
257 } else if (KindType == wxT("group")){
259 ContactKind = CONTACTKIND_GROUP;
261 } else if (KindType == wxT("org")){
263 ContactKind = CONTACTKIND_ORGANISATION;
265 } else if (KindType == wxT("location")){
267 ContactKind = CONTACTKIND_LOCATION;
271 ContactKind = CONTACTKIND_NONE;
276 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
278 std::map<int, int> SplitPoints;
279 std::map<int, int> SplitLength;
281 int intPrevValue = 8;
285 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
289 wxString PropertyName;
290 wxString PropertyValue;
291 wxString PropertyData;
292 wxString PropertyTokens;
293 std::map<int,int>::iterator SLiter;
294 bool FirstToken = TRUE;
296 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
297 intiter != SplitPoints.end(); ++intiter){
299 SLiter = SplitLength.find(intiter->first);
301 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
303 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
304 PropertyName = PropertyElement.GetNextToken();
305 PropertyValue = PropertyElement.GetNextToken();
307 intPrevValue = intiter->second;
309 CaptureString(&PropertyValue, FALSE);
311 if (PropertyName == wxT("ALTID")){
313 GroupsListAltID.erase(*GroupCount);
314 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
316 } else if (PropertyName == wxT("PID")){
318 GroupsListPID.erase(*GroupCount);
319 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
321 } else if (PropertyName == wxT("PREF")){
323 int PriorityNumber = 0;
324 bool ValidNumber = TRUE;
327 PriorityNumber = std::stoi(PropertyValue.ToStdString());
330 catch(std::invalid_argument &e){
334 if (ValidNumber == TRUE){
336 GroupsListPref.erase(*GroupCount);
337 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
341 } else if (PropertyName == wxT("MEDIATYPE")){
343 GroupsListMediaType.erase(*GroupCount);
344 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
346 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
348 if (FirstToken == TRUE){
350 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
355 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
363 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
365 if (!PropertyTokens.IsEmpty()){
367 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
374 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
376 std::map<int, int> SplitPoints;
377 std::map<int, int> SplitLength;
379 int intPrevValue = 4;
383 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
387 wxString PropertyName;
388 wxString PropertyValue;
389 wxString PropertyData;
390 wxString PropertyTokens;
391 std::map<int,int>::iterator SLiter;
392 bool FirstToken = TRUE;
394 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
395 intiter != SplitPoints.end(); ++intiter){
397 SLiter = SplitLength.find(intiter->first);
399 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
401 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
402 PropertyName = PropertyElement.GetNextToken();
403 PropertyValue = PropertyElement.GetNextToken();
405 intPrevValue = intiter->second;
407 CaptureString(&PropertyValue, FALSE);
409 if (PropertyName == wxT("TYPE")){
411 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
412 PropertyValue == wxT("work") ){
414 FullNamesListType.erase(*FNCount);
415 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
419 } else if (PropertyName == wxT("LANGUAGE")){
421 FullNamesListLanguage.erase(*FNCount);
422 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
424 } else if (PropertyName == wxT("ALTID")){
426 FullNamesListAltID.erase(*FNCount);
427 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
429 } else if (PropertyName == wxT("PID")){
431 FullNamesListPID.erase(*FNCount);
432 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
434 } else if (PropertyName == wxT("PREF")){
436 int PriorityNumber = 0;
437 bool ValidNumber = TRUE;
440 PriorityNumber = std::stoi(PropertyValue.ToStdString());
443 catch(std::invalid_argument &e){
447 if (ValidNumber == TRUE){
449 FullNamesListPref.erase(*FNCount);
450 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
454 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
456 if (FirstToken == TRUE){
458 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
463 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
471 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
473 if (!PropertyTokens.IsEmpty()){
475 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
481 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
483 std::map<int, int> SplitPoints;
484 std::map<int, int> SplitLength;
486 int intPrevValue = 3;
490 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
494 wxString PropertyName;
495 wxString PropertyValue;
496 wxString PropertyData;
497 wxString PropertyTokens;
498 std::map<int,int>::iterator SLiter;
499 bool FirstToken = TRUE;
501 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
502 intiter != SplitPoints.end(); ++intiter){
504 SLiter = SplitLength.find(intiter->first);
506 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
508 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
509 PropertyName = PropertyElement.GetNextToken();
510 PropertyValue = PropertyElement.GetNextToken();
512 intPrevValue = intiter->second;
514 CaptureString(&PropertyValue, FALSE);
516 if (PropertyName == wxT("ALTID")){
518 NameAltID = PropertyValue;
520 } else if (PropertyName == wxT("LANGUAGE")){
522 NameLanguage = PropertyValue;
524 } else if (PropertyName == wxT("SORT-AS")){
526 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
527 PropertyValue.Len() >= 3){
528 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
531 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
533 if (FirstToken == TRUE){
535 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
540 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
548 // Split the name data.
550 int intSplitSeek = 0;
551 int intSplitsFound = 0;
552 int intSplitSize = 0;
553 int intPropertyLen = PropertySeg2.Len();
555 std::map<int,wxString> NameValues;
558 for (int i = 0; i <= intPropertyLen; i++){
560 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
562 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
567 if (intSplitsFound == 4){
569 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
583 // Split the data into several parts.
585 for (std::map<int, wxString>::iterator iter = NameValues.begin();
586 iter != NameValues.end(); ++iter){
588 if (iter->first == 1){
590 // Deal with family name.
592 NameSurname = iter->second;
594 } else if (iter->first == 2){
596 // Deal with given names.
598 NameForename = iter->second;
600 } else if (iter->first == 3){
602 // Deal with additional names.
604 NameOtherNames = iter->second;
606 } else if (iter->first == 4){
608 // Deal with honorifix prefixes and suffixes.
610 NameTitle = iter->second;
614 if (iter == NameValues.end()){
620 NameSuffix = iter->second;
626 // Add the name token data.
628 if (!PropertyTokens.IsEmpty()){
630 NameTokens = PropertyTokens;
636 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
638 std::map<int, int> SplitPoints;
639 std::map<int, int> SplitLength;
641 int intPrevValue = 10;
644 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
648 PropertyType PropType;
650 // Look for type before continuing.
652 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
656 std::map<int, wxString> *NicknamesList = NULL;
657 std::map<int, wxString> *NicknamesListType = NULL;
658 std::map<int, wxString> *NicknamesListLanguage = NULL;
659 std::map<int, wxString> *NicknamesListAltID = NULL;
660 std::map<int, wxString> *NicknamesListPID = NULL;
661 std::map<int, wxString> *NicknamesListTokens = NULL;
662 std::map<int, int> *NicknamesListPref = NULL;
666 NicknamesList = &GeneralNicknamesList;
667 NicknamesListType = &GeneralNicknamesListType;
668 NicknamesListLanguage = &GeneralNicknamesListLanguage;
669 NicknamesListAltID = &GeneralNicknamesListAltID;
670 NicknamesListPID = &GeneralNicknamesListPID;
671 NicknamesListTokens = &GeneralNicknamesListTokens;
672 NicknamesListPref = &GeneralNicknamesListPref;
675 NicknamesList = &HomeNicknamesList;
676 NicknamesListType = &HomeNicknamesListType;
677 NicknamesListLanguage = &HomeNicknamesListLanguage;
678 NicknamesListAltID = &HomeNicknamesListAltID;
679 NicknamesListPID = &HomeNicknamesListPID;
680 NicknamesListTokens = &HomeNicknamesListTokens;
681 NicknamesListPref = &HomeNicknamesListPref;
684 NicknamesList = &BusinessNicknamesList;
685 NicknamesListType = &BusinessNicknamesListType;
686 NicknamesListLanguage = &BusinessNicknamesListLanguage;
687 NicknamesListAltID = &BusinessNicknamesListAltID;
688 NicknamesListPID = &BusinessNicknamesListPID;
689 NicknamesListTokens = &BusinessNicknamesListTokens;
690 NicknamesListPref = &BusinessNicknamesListPref;
694 std::map<int, int>::iterator SLiter;
695 wxString PropertyData;
696 wxString PropertyName;
697 wxString PropertyValue;
698 wxString PropertyTokens;
699 bool FirstToken = TRUE;
701 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
702 intiter != SplitPoints.end(); ++intiter){
704 SLiter = SplitLength.find(intiter->first);
706 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
708 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
709 PropertyName = PropertyElement.GetNextToken();
710 PropertyValue = PropertyElement.GetNextToken();
712 intPrevValue = intiter->second;
714 CaptureString(&PropertyValue, FALSE);
716 if (PropertyName == wxT("ALTID")){
718 NicknamesListAltID->erase(*NicknameCount);
719 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
721 } else if (PropertyName == wxT("PID")){
723 NicknamesListPID->erase(*NicknameCount);
724 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
726 } else if (PropertyName == wxT("PREF")){
728 int PriorityNumber = 0;
729 bool ValidNumber = TRUE;
732 PriorityNumber = std::stoi(PropertyValue.ToStdString());
735 catch(std::invalid_argument &e){
739 if (ValidNumber == TRUE){
741 NicknamesListPref->erase(*NicknameCount);
742 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
746 } else if (PropertyName == wxT("LANGUAGE")){
748 NicknamesListLanguage->erase(*NicknameCount);
749 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
753 // Something else we don't know about so append
754 // to the tokens variable.
756 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
758 if (FirstToken == TRUE){
760 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
765 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
775 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
777 // Add the name token data.
779 if (!PropertyTokens.IsEmpty()){
781 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
787 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
789 std::map<int, int> SplitPoints;
790 std::map<int, int> SplitLength;
791 std::map<int, int>::iterator SLiter;
792 wxString PropertyData;
793 wxString PropertyName;
794 wxString PropertyValue;
795 wxString PropertyTokens;
796 bool FirstToken = TRUE;
797 int intPrevValue = 8;
799 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
803 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
804 intiter != SplitPoints.end(); ++intiter){
806 SLiter = SplitLength.find(intiter->first);
808 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
810 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
811 PropertyName = PropertyElement.GetNextToken();
812 PropertyValue = PropertyElement.GetNextToken();
814 intPrevValue = intiter->second;
816 // Process properties.
818 size_t intPropertyValueLen = PropertyValue.Len();
820 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
822 PropertyValue.Trim();
823 PropertyValue.RemoveLast();
827 if (PropertyValue.Mid(0, 1) == wxT("\"")){
829 PropertyValue.Remove(0, 1);
833 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
835 if (FirstToken == TRUE){
837 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
842 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
850 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
852 wxString GenderComponent;
854 if (GenderData.CountTokens() >= 2){
856 Gender = GenderData.GetNextToken();
857 GenderDetails = GenderData.GetString();
859 CaptureString(&GenderDetails, FALSE);
863 Gender = GenderData.GetNextToken();
867 if (!PropertyTokens.IsEmpty()){
869 GenderTokens = PropertyTokens;
875 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
877 // Process date. Preserve the remainder in the string.
879 std::map<int, int> SplitPoints;
880 std::map<int, int> SplitLength;
881 std::map<int, int>::iterator SLiter;
882 wxString PropertyData;
883 wxString PropertyName;
884 wxString PropertyValue;
885 wxString PropertyTokens;
886 bool BirthdayText = FALSE;
887 int intPrevValue = 6;
889 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
893 // Look for type before continuing.
895 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
896 intiter != SplitPoints.end(); ++intiter){
898 SLiter = SplitLength.find(intiter->first);
900 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
902 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
903 PropertyName = PropertyElement.GetNextToken();
904 PropertyValue = PropertyElement.GetNextToken();
906 intPrevValue = intiter->second;
908 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
910 CaptureString(&PropertySeg2, FALSE);
911 Birthday = PropertySeg2;
918 // Setup blank lines for later on.
921 bool FirstToken = TRUE;
923 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
924 intiter != SplitPoints.end(); ++intiter){
926 SLiter = SplitLength.find(intiter->first);
928 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
930 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
931 PropertyName = PropertyElement.GetNextToken();
932 PropertyValue = PropertyElement.GetNextToken();
934 intPrevValue = intiter->second;
936 // Process properties.
938 CaptureString(&PropertyValue, FALSE);
940 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
942 PropertyValue.Trim();
943 PropertyValue.RemoveLast();
947 if (PropertyValue.Mid(0, 1) == wxT("\"")){
949 PropertyValue.Remove(0, 1);
953 if (PropertyName == wxT("ALTID")){
955 BirthdayAltID = PropertyValue;
957 } else if (PropertyName == wxT("CALSCALE")){
959 BirthdayCalScale = PropertyValue;
961 } else if (PropertyName != wxT("VALUE")) {
963 // Something else we don't know about so append
964 // to the tokens variable.
966 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
968 if (FirstToken == TRUE){
970 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
975 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
985 // Add the data to the variables and form.
987 if (BirthdayText == FALSE){
989 Birthday = PropertySeg2;
993 if (!PropertyTokens.IsEmpty()){
995 BirthdayTokens = PropertyTokens;
1001 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1003 // Process date. Preserve the remainder in the string.
1005 std::map<int, int> SplitPoints;
1006 std::map<int, int> SplitLength;
1007 std::map<int, int>::iterator SLiter;
1008 wxString PropertyData;
1009 wxString PropertyName;
1010 wxString PropertyValue;
1011 wxString PropertyTokens;
1012 bool AnniversaryText = FALSE;
1013 int intPrevValue = 13;
1015 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1019 // Look for type before continuing.
1021 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1022 intiter != SplitPoints.end(); ++intiter){
1024 SLiter = SplitLength.find(intiter->first);
1026 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1028 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1029 PropertyName = PropertyElement.GetNextToken();
1030 PropertyValue = PropertyElement.GetNextToken();
1032 intPrevValue = intiter->second;
1034 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1036 CaptureString(&PropertySeg2, FALSE);
1037 Anniversary = PropertySeg2;
1038 AnniversaryText = TRUE;
1044 // Setup blank lines for later on.
1047 bool FirstToken = TRUE;
1049 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1050 intiter != SplitPoints.end(); ++intiter){
1052 SLiter = SplitLength.find(intiter->first);
1054 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1056 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1057 PropertyName = PropertyElement.GetNextToken();
1058 PropertyValue = PropertyElement.GetNextToken();
1060 intPrevValue = intiter->second;
1062 // Process properties.
1064 CaptureString(&PropertyValue, FALSE);
1066 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1068 PropertyValue.Trim();
1069 PropertyValue.RemoveLast();
1073 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1075 PropertyValue.Remove(0, 1);
1079 if (PropertyName == wxT("ALTID")){
1081 AnniversaryAltID = PropertyValue;
1083 } else if (PropertyName == wxT("CALSCALE")){
1085 AnniversaryCalScale = PropertyValue;
1087 } else if (PropertyName != wxT("VALUE")) {
1089 // Something else we don't know about so append
1090 // to the tokens variable.
1092 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1094 if (FirstToken == TRUE){
1096 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1101 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1111 // Add the data to the variables and form.
1113 if (AnniversaryText == FALSE){
1115 Anniversary = PropertySeg2;
1119 if (!PropertyTokens.IsEmpty()){
1121 AnniversaryTokens = PropertyTokens;
1127 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1129 std::map<int, int> SplitPoints;
1130 std::map<int, int> SplitLength;
1132 int intPrevValue = 4;
1135 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1139 PropertyType PropType;
1141 // Look for type before continuing.
1143 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1147 std::map<int, wxString> *TZList = NULL;
1148 std::map<int, wxString> *TZListType = NULL;
1149 std::map<int, wxString> *TZListMediatype = NULL;
1150 std::map<int, wxString> *TZListAltID = NULL;
1151 std::map<int, wxString> *TZListPID = NULL;
1152 std::map<int, wxString> *TZListTokens = NULL;
1153 std::map<int, int> *TZListPref = NULL;
1157 TZList = &GeneralTZList;
1158 TZListType = &GeneralTZListType;
1159 TZListMediatype = &GeneralTZListMediatype;
1160 TZListAltID = &GeneralTZListAltID;
1161 TZListPID = &GeneralTZListPID;
1162 TZListTokens = &GeneralTZListTokens;
1163 TZListPref = &GeneralTZListPref;
1166 TZList = &HomeTZList;
1167 TZListType = &HomeTZListType;
1168 TZListMediatype = &HomeTZListMediatype;
1169 TZListAltID = &HomeTZListAltID;
1170 TZListPID = &HomeTZListPID;
1171 TZListTokens = &HomeTZListTokens;
1172 TZListPref = &HomeTZListPref;
1175 TZList = &BusinessTZList;
1176 TZListType = &BusinessTZListType;
1177 TZListMediatype = &BusinessTZListMediatype;
1178 TZListAltID = &BusinessTZListAltID;
1179 TZListPID = &BusinessTZListPID;
1180 TZListTokens = &BusinessTZListTokens;
1181 TZListPref = &BusinessTZListPref;
1185 std::map<int, int>::iterator SLiter;
1186 wxString PropertyData;
1187 wxString PropertyName;
1188 wxString PropertyValue;
1189 wxString PropertyTokens;
1190 bool FirstToken = TRUE;
1192 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1193 intiter != SplitPoints.end(); ++intiter){
1195 SLiter = SplitLength.find(intiter->first);
1197 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1199 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1200 PropertyName = PropertyElement.GetNextToken();
1201 PropertyValue = PropertyElement.GetNextToken();
1203 intPrevValue = intiter->second;
1205 CaptureString(&PropertyValue, FALSE);
1207 if (PropertyName == wxT("ALTID")){
1209 TZListAltID->erase(*TimeZoneCount);
1210 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1212 } else if (PropertyName == wxT("PID")){
1214 TZListPID->erase(*TimeZoneCount);
1215 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1217 } else if (PropertyName == wxT("PREF")){
1219 int PriorityNumber = 0;
1220 bool ValidNumber = TRUE;
1223 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1226 catch(std::invalid_argument &e){
1227 ValidNumber = FALSE;
1230 if (ValidNumber == TRUE){
1232 TZListPref->erase(*TimeZoneCount);
1233 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1237 } else if (PropertyName == wxT("MEDIATYPE")){
1239 TZListMediatype->erase(*TimeZoneCount);
1240 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1244 // Something else we don't know about so append
1245 // to the tokens variable.
1247 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1249 if (FirstToken == TRUE){
1251 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1256 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1266 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1268 // Add the name token data.
1270 if (!PropertyTokens.IsEmpty()){
1272 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1279 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1281 size_t intPropertyLen = PropertySeg1.Len();
1282 std::map<int, int> SplitPoints;
1283 std::map<int, int> SplitLength;
1284 std::map<int, int>::iterator SLiter;
1285 wxString PropertyData;
1286 wxString PropertyName;
1287 wxString PropertyValue;
1288 wxString PropertyTokens;
1289 wxString AddressLabel;
1290 wxString AddressLang;
1291 wxString AddressAltID;
1292 wxString AddressPID;
1293 wxString AddressTokens;
1294 wxString AddressGeo;
1295 wxString AddressTimezone;
1296 wxString AddressType;
1297 wxString AddressMediatype;
1298 wxString AddressPOBox;
1299 wxString AddressExtended;
1300 wxString AddressStreet;
1301 wxString AddressLocality;
1302 wxString AddressCity;
1303 wxString AddressRegion;
1304 wxString AddressPostalCode;
1305 wxString AddressCountry;
1306 bool FirstToken = TRUE;
1307 int intSplitsFound = 0;
1308 int intSplitSize = 0;
1309 int intPrevValue = 5;
1314 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1318 PropertyType PropType;
1320 // Look for type before continuing.
1322 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1326 std::map<int, wxString> *AddressList = NULL;
1327 std::map<int, wxString> *AddressListTown = NULL;
1328 std::map<int, wxString> *AddressListCounty = NULL;
1329 std::map<int, wxString> *AddressListPostCode = NULL;
1330 std::map<int, wxString> *AddressListCountry = NULL;
1331 std::map<int, wxString> *AddressListLabel = NULL;
1332 std::map<int, wxString> *AddressListLang = NULL;
1333 std::map<int, wxString> *AddressListAltID = NULL;
1334 std::map<int, wxString> *AddressListPID = NULL;
1335 std::map<int, wxString> *AddressListTokens = NULL;
1336 std::map<int, wxString> *AddressListGeo = NULL;
1337 std::map<int, wxString> *AddressListTimezone = NULL;
1338 std::map<int, wxString> *AddressListType = NULL;
1339 std::map<int, wxString> *AddressListMediatype = NULL;
1340 std::map<int, int> *AddressListPref = NULL;
1344 AddressList = &GeneralAddressList;
1345 AddressListTown = &GeneralAddressListTown;
1346 AddressListCounty = &GeneralAddressListCounty;
1347 AddressListPostCode = &GeneralAddressListPostCode;
1348 AddressListCountry = &GeneralAddressListCountry;
1349 AddressListLabel = &GeneralAddressListLabel;
1350 AddressListLang = &GeneralAddressListLang;
1351 AddressListAltID = &GeneralAddressListAltID;
1352 AddressListPID = &GeneralAddressListPID;
1353 AddressListTokens = &GeneralAddressListTokens;
1354 AddressListGeo = &GeneralAddressListGeo;
1355 AddressListTimezone = &GeneralAddressListTimezone;
1356 AddressListType = &GeneralAddressListType;
1357 AddressListMediatype = &GeneralAddressListMediatype;
1358 AddressListPref = &GeneralAddressListPref;
1361 AddressList = &HomeAddressList;
1362 AddressListTown = &HomeAddressListTown;
1363 AddressListCounty = &HomeAddressListCounty;
1364 AddressListPostCode = &HomeAddressListPostCode;
1365 AddressListCountry = &HomeAddressListCountry;
1366 AddressListLabel = &HomeAddressListLabel;
1367 AddressListLang = &HomeAddressListLang;
1368 AddressListAltID = &HomeAddressListAltID;
1369 AddressListPID = &HomeAddressListPID;
1370 AddressListTokens = &HomeAddressListTokens;
1371 AddressListGeo = &HomeAddressListGeo;
1372 AddressListTimezone = &HomeAddressListTimezone;
1373 AddressListType = &HomeAddressListType;
1374 AddressListMediatype = &HomeAddressListMediatype;
1375 AddressListPref = &HomeAddressListPref;
1378 AddressList = &BusinessAddressList;
1379 AddressListTown = &BusinessAddressListTown;
1380 AddressListCounty = &BusinessAddressListCounty;
1381 AddressListPostCode = &BusinessAddressListPostCode;
1382 AddressListCountry = &BusinessAddressListCountry;
1383 AddressListLabel = &BusinessAddressListLabel;
1384 AddressListLang = &BusinessAddressListLang;
1385 AddressListAltID = &BusinessAddressListAltID;
1386 AddressListPID = &BusinessAddressListPID;
1387 AddressListTokens = &BusinessAddressListTokens;
1388 AddressListGeo = &BusinessAddressListGeo;
1389 AddressListTimezone = &BusinessAddressListTimezone;
1390 AddressListType = &BusinessAddressListType;
1391 AddressListMediatype = &BusinessAddressListMediatype;
1392 AddressListPref = &BusinessAddressListPref;
1398 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1399 intiter != SplitPoints.end(); ++intiter){
1401 SLiter = SplitLength.find(intiter->first);
1403 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1405 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1406 PropertyName = PropertyElement.GetNextToken();
1407 PropertyValue = PropertyElement.GetNextToken();
1409 intPrevValue = intiter->second;
1411 CaptureString(&PropertyValue, FALSE);
1413 // Process properties.
1415 if (PropertyName == wxT("LABEL")){
1417 AddressListLabel->erase(*AddressCount);
1418 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1420 } else if (PropertyName == wxT("LANGUAGE")){
1422 AddressListLang->erase(*AddressCount);
1423 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1425 } else if (PropertyName == wxT("ALTID")){
1427 AddressListAltID->erase(*AddressCount);
1428 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1430 } else if (PropertyName == wxT("PID")){
1432 AddressListPID->erase(*AddressCount);
1433 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1435 } else if (PropertyName == wxT("GEO")){
1437 AddressListGeo->erase(*AddressCount);
1438 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1440 } else if (PropertyName == wxT("TZ")){
1442 AddressListTimezone->erase(*AddressCount);
1443 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1445 } else if (PropertyName == wxT("MEDIATYPE")){
1447 AddressListMediatype->erase(*AddressCount);
1448 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1450 } else if (PropertyName == wxT("PREF")){
1452 int PriorityNumber = 0;
1453 bool ValidNumber = TRUE;
1456 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1459 catch(std::invalid_argument &e){
1460 ValidNumber = FALSE;
1463 if (ValidNumber == TRUE){
1465 AddressListPref->erase(*AddressCount);
1466 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1472 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1474 if (FirstToken == TRUE){
1476 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1481 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1491 // Split the address.
1493 //std::map<int, int>::iterator SLiter;
1494 intPropertyLen = PropertySeg2.Len();
1495 SplitPoints.clear();
1496 SplitLength.clear();
1501 for (int i = 0; i <= intPropertyLen; i++){
1505 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1508 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1510 if (intSplitsFound == 6){
1512 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1517 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1527 // Split the data into several parts.
1529 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1530 intiter != SplitPoints.end(); ++intiter){
1532 if (intiter->first == 1){
1534 // Deal with PO Box.
1536 SLiter = SplitLength.find(1);
1538 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1539 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1540 intPrevValue = intiter->second;
1542 } else if (intiter->first == 2){
1544 // Deal with extended address.
1546 SLiter = SplitLength.find(2);
1548 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1549 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1550 intPrevValue = intiter->second;
1552 } else if (intiter->first == 3){
1554 // Deal with street address.
1556 SLiter = SplitLength.find(3);
1558 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1559 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1560 intPrevValue = intiter->second;
1562 } else if (intiter->first == 4){
1564 // Deal with locality
1566 SLiter = SplitLength.find(4);
1568 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1569 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1570 intPrevValue = intiter->second;
1572 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1574 } else if (intiter->first == 5){
1576 // Deal with region.
1578 SLiter = SplitLength.find(5);
1580 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1581 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1582 intPrevValue = intiter->second;
1584 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1586 } else if (intiter->first == 6){
1588 // Deal with post code.
1590 SLiter = SplitLength.find(6);
1592 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1593 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1594 intPrevValue = intiter->second;
1596 // Deal with country.
1598 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1599 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1607 // Add the data to the General/Home/Work address variables.
1609 CaptureString(&AddressStreet, FALSE);
1610 CaptureString(&AddressLocality, FALSE);
1611 CaptureString(&AddressRegion, FALSE);
1612 CaptureString(&AddressPostalCode, FALSE);
1613 CaptureString(&AddressCountry, FALSE);
1615 if (!PropertyTokens.IsEmpty()){
1617 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1621 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1622 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1623 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1624 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1625 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1629 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1632 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1635 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1639 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1643 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1645 std::map<int, int> SplitPoints;
1646 std::map<int, int> SplitLength;
1648 int intPrevValue = 7;
1651 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1655 PropertyType PropType;
1657 // Look for type before continuing.
1659 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1661 std::map<int, wxString> *EmailList = NULL;
1662 std::map<int, wxString> *EmailListType = NULL;
1663 std::map<int, wxString> *EmailListAltID = NULL;
1664 std::map<int, wxString> *EmailListPID = NULL;
1665 std::map<int, wxString> *EmailListTokens = NULL;
1666 std::map<int, int> *EmailListPref = NULL;
1670 EmailList = &GeneralEmailList;
1671 EmailListType = &GeneralEmailListType;
1672 EmailListAltID = &GeneralEmailListAltID;
1673 EmailListPID = &GeneralEmailListPID;
1674 EmailListTokens = &GeneralEmailListTokens;
1675 EmailListPref = &GeneralEmailListPref;
1678 EmailList = &HomeEmailList;
1679 EmailListType = &HomeEmailListType;
1680 EmailListAltID = &HomeEmailListAltID;
1681 EmailListPID = &HomeEmailListPID;
1682 EmailListTokens = &HomeEmailListTokens;
1683 EmailListPref = &HomeEmailListPref;
1686 EmailList = &BusinessEmailList;
1687 EmailListType = &BusinessEmailListType;
1688 EmailListAltID = &BusinessEmailListAltID;
1689 EmailListPID = &BusinessEmailListPID;
1690 EmailListTokens = &BusinessEmailListTokens;
1691 EmailListPref = &BusinessEmailListPref;
1697 std::map<int,int>::iterator SLiter;
1698 wxString PropertyData;
1699 wxString PropertyName;
1700 wxString PropertyValue;
1701 wxString PropertyTokens;
1702 bool FirstToken = TRUE;
1704 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1705 intiter != SplitPoints.end(); ++intiter){
1707 SLiter = SplitLength.find(intiter->first);
1709 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1711 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1712 PropertyName = PropertyElement.GetNextToken();
1713 PropertyValue = PropertyElement.GetNextToken();
1715 intPrevValue = intiter->second;
1717 CaptureString(&PropertyValue, FALSE);
1719 // Process properties.
1721 if (PropertyName == wxT("ALTID")){
1723 EmailListAltID->erase(*EmailCount);
1724 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1726 } else if (PropertyName == wxT("PID")){
1728 EmailListPID->erase(*EmailCount);
1729 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1731 } else if (PropertyName == wxT("PREF")){
1733 int PriorityNumber = 0;
1734 bool ValidNumber = TRUE;
1737 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1740 catch(std::invalid_argument &e){
1741 ValidNumber = FALSE;
1744 if (ValidNumber == TRUE){
1746 EmailListPref->erase(*EmailCount);
1747 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1753 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1755 if (FirstToken == TRUE){
1757 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1762 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1772 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1774 // Add the name token data.
1776 if (!PropertyTokens.IsEmpty()){
1778 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1785 void SplitValues(wxString *PropertyLine,
1786 std::map<int,int> *SplitPoints,
1787 std::map<int,int> *SplitLength,
1790 size_t intPropertyLen = PropertyLine->Len();
1791 int intSplitsFound = 0;
1792 int intSplitSize = 0;
1793 int intSplitSeek = 0;
1795 for (int i = intSize; i <= intPropertyLen; i++){
1799 if (PropertyLine->Mid(i, 1) == wxT(";") &&
1800 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
1802 if (intSplitsFound == 0){
1804 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
1808 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1812 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
1822 if (intSplitsFound == 0){
1824 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
1825 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1829 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
1830 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1836 void CheckType(wxString *PropertySeg1,
1837 std::map<int,int> *SplitPoints,
1838 std::map<int,int> *SplitLength,
1840 PropertyType *PropType){
1842 wxString PropertyData;
1843 wxString PropertyName;
1844 wxString PropertyValue;
1845 std::map<int,int>::iterator SLiter;
1847 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
1848 intiter != SplitPoints->end(); ++intiter){
1850 SLiter = SplitLength->find(intiter->first);
1852 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
1854 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1855 PropertyName = PropertyElement.GetNextToken();
1856 PropertyValue = PropertyElement.GetNextToken();
1858 *intPrevValue = intiter->second;
1860 if (PropertyName == wxT("TYPE")){
1862 if (PropertyValue == wxT("work")){
1864 *PropType = PROPERTY_WORK;
1866 } else if (PropertyValue == wxT("home")){
1868 *PropType = PROPERTY_HOME;
1872 *PropType = PROPERTY_NONE;