1 // ContactDataObject.cpp - Client Data Object.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 int ContactLineLen = 0;
82 int QuoteBreakPoint = 0;
85 int NicknameCount = 0;
86 int TimeZoneCount = 0;
90 int TelephoneCount = 0;
91 int LanguageCount = 0;
92 int GeographicCount = 0;
97 int OrganisationCount = 0;
99 int CategoryCount = 0;
100 wxString ContactLine;
101 wxString PropertyLine;
102 wxString PropertySeg1;
103 wxString PropertySeg2;
104 wxString PropertyNextLine;
107 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
108 iter != ContactFileLines.end(); ++iter){
110 ExtraLineSeek = TRUE;
116 PropertyLine.Clear();
117 PropertySeg1.Clear();
118 PropertySeg2.Clear();
121 ContactLine = iter->second;
123 while (ExtraLineSeek == TRUE){
125 // Check if there is extra data on the next line
126 // (indicated by space or tab at the start) and add data.
130 if (iter == ContactFileLines.end()){
137 PropertyNextLine = iter->second;
139 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
141 PropertyNextLine.Remove(0, 1);
142 ContactLine.Append(PropertyNextLine);
147 ExtraLineSeek = FALSE;
153 ContactLineLen = ContactLine.Len();
155 // Make sure we are not in quotation mode.
156 // Make sure colon does not have \ or \\ before it.
158 for (int i = 0; i <= ContactLineLen; i++){
160 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
162 PropertyFind = FALSE;
164 } else if (PropertyFind == TRUE){
166 Property.Append(ContactLine.Mid(i, 1));
170 if (ContactLine.Mid(i, 1) == wxT("\"")){
172 if (QuoteMode == TRUE){
184 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
193 // Split that line at the point into two variables (ignore the colon).
195 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
196 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
198 if (Property == wxT("KIND") && KindProcessed == FALSE){
200 ProcessKind(PropertySeg2);
202 } else if (Property == wxT("MEMBER")){
204 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
207 } else if (Property == wxT("FN")){
209 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
212 } else if (Property == wxT("N") && NameProcessed == FALSE){
214 ProcessN(PropertySeg1, PropertySeg2);
215 NameProcessed = TRUE;
217 } else if (Property == wxT("NICKNAME")){
219 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
222 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
224 ProcessGender(PropertySeg1, PropertySeg2);
225 GenderProcessed = TRUE;
227 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
229 ProcessBirthday(PropertySeg1, PropertySeg2);
230 BirthdayProcessed = TRUE;
232 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
234 ProcessAnniversary(PropertySeg1, PropertySeg2);
235 AnniversaryProcessed = TRUE;
237 } else if (Property == wxT("TZ")){
239 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
242 } else if (Property == wxT("ADR")){
244 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
247 } else if (Property == wxT("EMAIL")){
249 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
252 } else if (Property == wxT("IMPP")){
254 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
257 } else if (Property == wxT("TEL")){
259 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
262 } else if (Property == wxT("LANG")){
264 // See frmContactEditor-LoadLanguage.cpp
266 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
269 } else if (Property == wxT("GEO")){
271 // See frmContactEditor-LoadGeo.cpp
273 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
276 } else if (Property == wxT("RELATED")){
278 // See fromContactEditor-LoadRelated.cpp
280 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
283 } else if (Property == wxT("URL")){
285 // See frmContactEditor-LoadURL.cpp
287 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
290 } else if (Property == wxT("TITLE")) {
292 // See frmContactEditor-LoadTitle.cpp
294 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
297 } else if (Property == wxT("ROLE")) {
299 // See frmContactEditor-LoadTitle.cpp
301 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
304 } else if (Property == wxT("ORG")) {
306 // See frmContactEditor-LoadOrg.cpp
308 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
311 } else if (Property == wxT("NOTE")) {
313 // See frmContactEditor-LoadNote.cpp
315 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
318 } else if (Property == wxT("CATEGORIES")) {
320 // See frmContactEditor-LoadCategory.cpp
322 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
329 return CONTACTLOAD_OK;
333 void ContactDataObject::ProcessKind(wxString KindType){
335 if (KindType == wxT("individual")){
337 ContactKind = CONTACTKIND_INDIVIDUAL;
339 } else if (KindType == wxT("group")){
341 ContactKind = CONTACTKIND_GROUP;
343 } else if (KindType == wxT("org")){
345 ContactKind = CONTACTKIND_ORGANISATION;
347 } else if (KindType == wxT("location")){
349 ContactKind = CONTACTKIND_LOCATION;
353 ContactKind = CONTACTKIND_NONE;
358 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
360 std::map<int, int> SplitPoints;
361 std::map<int, int> SplitLength;
363 int intPrevValue = 8;
367 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
371 wxString PropertyName;
372 wxString PropertyValue;
373 wxString PropertyData;
374 wxString PropertyTokens;
375 std::map<int,int>::iterator SLiter;
376 bool FirstToken = TRUE;
378 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
379 intiter != SplitPoints.end(); ++intiter){
381 SLiter = SplitLength.find(intiter->first);
383 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
385 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
386 PropertyName = PropertyElement.GetNextToken();
387 PropertyValue = PropertyElement.GetNextToken();
389 intPrevValue = intiter->second;
391 CaptureString(&PropertyValue, FALSE);
393 if (PropertyName == wxT("ALTID")){
395 GroupsListAltID.erase(*GroupCount);
396 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
398 } else if (PropertyName == wxT("PID")){
400 GroupsListPID.erase(*GroupCount);
401 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
403 } else if (PropertyName == wxT("PREF")){
405 int PriorityNumber = 0;
406 bool ValidNumber = TRUE;
409 PriorityNumber = std::stoi(PropertyValue.ToStdString());
412 catch(std::invalid_argument &e){
416 if (ValidNumber == TRUE){
418 GroupsListPref.erase(*GroupCount);
419 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
423 } else if (PropertyName == wxT("MEDIATYPE")){
425 GroupsListMediaType.erase(*GroupCount);
426 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
428 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
430 if (FirstToken == TRUE){
432 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
437 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
445 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
447 if (!PropertyTokens.IsEmpty()){
449 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
456 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
458 std::map<int, int> SplitPoints;
459 std::map<int, int> SplitLength;
461 int intPrevValue = 4;
465 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
469 wxString PropertyName;
470 wxString PropertyValue;
471 wxString PropertyData;
472 wxString PropertyTokens;
473 std::map<int,int>::iterator SLiter;
474 bool FirstToken = TRUE;
476 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
477 intiter != SplitPoints.end(); ++intiter){
479 SLiter = SplitLength.find(intiter->first);
481 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
483 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
484 PropertyName = PropertyElement.GetNextToken();
485 PropertyValue = PropertyElement.GetNextToken();
487 intPrevValue = intiter->second;
489 CaptureString(&PropertyValue, FALSE);
491 if (PropertyName == wxT("TYPE")){
493 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
494 PropertyValue == wxT("work") ){
496 FullNamesListType.erase(*FNCount);
497 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
501 } else if (PropertyName == wxT("LANGUAGE")){
503 FullNamesListLanguage.erase(*FNCount);
504 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
506 } else if (PropertyName == wxT("ALTID")){
508 FullNamesListAltID.erase(*FNCount);
509 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
511 } else if (PropertyName == wxT("PID")){
513 FullNamesListPID.erase(*FNCount);
514 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
516 } else if (PropertyName == wxT("PREF")){
518 int PriorityNumber = 0;
519 bool ValidNumber = TRUE;
522 PriorityNumber = std::stoi(PropertyValue.ToStdString());
525 catch(std::invalid_argument &e){
529 if (ValidNumber == TRUE){
531 FullNamesListPref.erase(*FNCount);
532 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
536 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
538 if (FirstToken == TRUE){
540 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
545 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
553 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
555 if (!PropertyTokens.IsEmpty()){
557 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
563 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
565 std::map<int, int> SplitPoints;
566 std::map<int, int> SplitLength;
568 int intPrevValue = 3;
572 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
576 wxString PropertyName;
577 wxString PropertyValue;
578 wxString PropertyData;
579 wxString PropertyTokens;
580 std::map<int,int>::iterator SLiter;
581 bool FirstToken = TRUE;
583 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
584 intiter != SplitPoints.end(); ++intiter){
586 SLiter = SplitLength.find(intiter->first);
588 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
590 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
591 PropertyName = PropertyElement.GetNextToken();
592 PropertyValue = PropertyElement.GetNextToken();
594 intPrevValue = intiter->second;
596 CaptureString(&PropertyValue, FALSE);
598 if (PropertyName == wxT("ALTID")){
600 NameAltID = PropertyValue;
602 } else if (PropertyName == wxT("LANGUAGE")){
604 NameLanguage = PropertyValue;
606 } else if (PropertyName == wxT("SORT-AS")){
608 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
609 PropertyValue.Len() >= 3){
610 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
613 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
615 if (FirstToken == TRUE){
617 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
622 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
630 // Split the name data.
632 int intSplitSeek = 0;
633 int intSplitsFound = 0;
634 int intSplitSize = 0;
635 int intPropertyLen = PropertySeg2.Len();
637 std::map<int,wxString> NameValues;
640 for (int i = 0; i <= intPropertyLen; i++){
642 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
644 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
649 if (intSplitsFound == 4){
651 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
665 // Split the data into several parts.
667 for (std::map<int, wxString>::iterator iter = NameValues.begin();
668 iter != NameValues.end(); ++iter){
670 if (iter->first == 1){
672 // Deal with family name.
674 NameSurname = iter->second;
676 } else if (iter->first == 2){
678 // Deal with given names.
680 NameForename = iter->second;
682 } else if (iter->first == 3){
684 // Deal with additional names.
686 NameOtherNames = iter->second;
688 } else if (iter->first == 4){
690 // Deal with honorifix prefixes and suffixes.
692 NameTitle = iter->second;
696 if (iter == NameValues.end()){
702 NameSuffix = iter->second;
708 // Add the name token data.
710 if (!PropertyTokens.IsEmpty()){
712 NameTokens = PropertyTokens;
718 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
720 std::map<int, int> SplitPoints;
721 std::map<int, int> SplitLength;
723 int intPrevValue = 10;
726 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
730 PropertyType PropType = PROPERTY_NONE;
732 // Look for type before continuing.
734 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
738 std::map<int, wxString> *NicknamesList = NULL;
739 std::map<int, wxString> *NicknamesListType = NULL;
740 std::map<int, wxString> *NicknamesListLanguage = NULL;
741 std::map<int, wxString> *NicknamesListAltID = NULL;
742 std::map<int, wxString> *NicknamesListPID = NULL;
743 std::map<int, wxString> *NicknamesListTokens = NULL;
744 std::map<int, int> *NicknamesListPref = NULL;
748 NicknamesList = &GeneralNicknamesList;
749 NicknamesListType = &GeneralNicknamesListType;
750 NicknamesListLanguage = &GeneralNicknamesListLanguage;
751 NicknamesListAltID = &GeneralNicknamesListAltID;
752 NicknamesListPID = &GeneralNicknamesListPID;
753 NicknamesListTokens = &GeneralNicknamesListTokens;
754 NicknamesListPref = &GeneralNicknamesListPref;
757 NicknamesList = &HomeNicknamesList;
758 NicknamesListType = &HomeNicknamesListType;
759 NicknamesListLanguage = &HomeNicknamesListLanguage;
760 NicknamesListAltID = &HomeNicknamesListAltID;
761 NicknamesListPID = &HomeNicknamesListPID;
762 NicknamesListTokens = &HomeNicknamesListTokens;
763 NicknamesListPref = &HomeNicknamesListPref;
766 NicknamesList = &BusinessNicknamesList;
767 NicknamesListType = &BusinessNicknamesListType;
768 NicknamesListLanguage = &BusinessNicknamesListLanguage;
769 NicknamesListAltID = &BusinessNicknamesListAltID;
770 NicknamesListPID = &BusinessNicknamesListPID;
771 NicknamesListTokens = &BusinessNicknamesListTokens;
772 NicknamesListPref = &BusinessNicknamesListPref;
776 std::map<int, int>::iterator SLiter;
777 wxString PropertyData;
778 wxString PropertyName;
779 wxString PropertyValue;
780 wxString PropertyTokens;
781 bool FirstToken = TRUE;
783 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
784 intiter != SplitPoints.end(); ++intiter){
786 SLiter = SplitLength.find(intiter->first);
788 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
790 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
791 PropertyName = PropertyElement.GetNextToken();
792 PropertyValue = PropertyElement.GetNextToken();
794 intPrevValue = intiter->second;
796 CaptureString(&PropertyValue, FALSE);
798 if (PropertyName == wxT("ALTID")){
800 NicknamesListAltID->erase(*NicknameCount);
801 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
803 } else if (PropertyName == wxT("PID")){
805 NicknamesListPID->erase(*NicknameCount);
806 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
808 } else if (PropertyName == wxT("PREF")){
810 int PriorityNumber = 0;
811 bool ValidNumber = TRUE;
814 PriorityNumber = std::stoi(PropertyValue.ToStdString());
817 catch(std::invalid_argument &e){
821 if (ValidNumber == TRUE){
823 NicknamesListPref->erase(*NicknameCount);
824 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
828 } else if (PropertyName == wxT("LANGUAGE")){
830 NicknamesListLanguage->erase(*NicknameCount);
831 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
835 // Something else we don't know about so append
836 // to the tokens variable.
838 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
840 if (FirstToken == TRUE){
842 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
847 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
857 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
859 // Add the name token data.
861 if (!PropertyTokens.IsEmpty()){
863 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
869 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
871 std::map<int, int> SplitPoints;
872 std::map<int, int> SplitLength;
873 std::map<int, int>::iterator SLiter;
874 wxString PropertyData;
875 wxString PropertyName;
876 wxString PropertyValue;
877 wxString PropertyTokens;
878 bool FirstToken = TRUE;
879 int intPrevValue = 8;
881 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
885 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
886 intiter != SplitPoints.end(); ++intiter){
888 SLiter = SplitLength.find(intiter->first);
890 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
892 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
893 PropertyName = PropertyElement.GetNextToken();
894 PropertyValue = PropertyElement.GetNextToken();
896 intPrevValue = intiter->second;
898 // Process properties.
900 size_t intPropertyValueLen = PropertyValue.Len();
902 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
904 PropertyValue.Trim();
905 PropertyValue.RemoveLast();
909 if (PropertyValue.Mid(0, 1) == wxT("\"")){
911 PropertyValue.Remove(0, 1);
915 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
917 if (FirstToken == TRUE){
919 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
924 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
932 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
934 wxString GenderComponent;
936 if (GenderData.CountTokens() >= 2){
938 Gender = GenderData.GetNextToken();
939 GenderDetails = GenderData.GetString();
941 CaptureString(&GenderDetails, FALSE);
945 Gender = GenderData.GetNextToken();
949 if (!PropertyTokens.IsEmpty()){
951 GenderTokens = PropertyTokens;
957 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
959 // Process date. Preserve the remainder in the string.
961 std::map<int, int> SplitPoints;
962 std::map<int, int> SplitLength;
963 std::map<int, int>::iterator SLiter;
964 wxString PropertyData;
965 wxString PropertyName;
966 wxString PropertyValue;
967 wxString PropertyTokens;
968 bool BirthdayText = FALSE;
969 int intPrevValue = 6;
971 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
975 // Look for type before continuing.
977 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
978 intiter != SplitPoints.end(); ++intiter){
980 SLiter = SplitLength.find(intiter->first);
982 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
984 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
985 PropertyName = PropertyElement.GetNextToken();
986 PropertyValue = PropertyElement.GetNextToken();
988 intPrevValue = intiter->second;
990 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
992 CaptureString(&PropertySeg2, FALSE);
993 Birthday = PropertySeg2;
1000 // Setup blank lines for later on.
1003 bool FirstToken = TRUE;
1005 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1006 intiter != SplitPoints.end(); ++intiter){
1008 SLiter = SplitLength.find(intiter->first);
1010 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1012 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1013 PropertyName = PropertyElement.GetNextToken();
1014 PropertyValue = PropertyElement.GetNextToken();
1016 intPrevValue = intiter->second;
1018 // Process properties.
1020 CaptureString(&PropertyValue, FALSE);
1022 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1024 PropertyValue.Trim();
1025 PropertyValue.RemoveLast();
1029 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1031 PropertyValue.Remove(0, 1);
1035 if (PropertyName == wxT("ALTID")){
1037 BirthdayAltID = PropertyValue;
1039 } else if (PropertyName == wxT("CALSCALE")){
1041 BirthdayCalScale = PropertyValue;
1043 } else if (PropertyName != wxT("VALUE")) {
1045 // Something else we don't know about so append
1046 // to the tokens variable.
1048 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1050 if (FirstToken == TRUE){
1052 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1057 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1067 // Add the data to the variables and form.
1069 if (BirthdayText == FALSE){
1071 Birthday = PropertySeg2;
1075 if (!PropertyTokens.IsEmpty()){
1077 BirthdayTokens = PropertyTokens;
1083 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1085 // Process date. Preserve the remainder in the string.
1087 std::map<int, int> SplitPoints;
1088 std::map<int, int> SplitLength;
1089 std::map<int, int>::iterator SLiter;
1090 wxString PropertyData;
1091 wxString PropertyName;
1092 wxString PropertyValue;
1093 wxString PropertyTokens;
1094 bool AnniversaryText = FALSE;
1095 int intPrevValue = 13;
1097 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1101 // Look for type before continuing.
1103 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1104 intiter != SplitPoints.end(); ++intiter){
1106 SLiter = SplitLength.find(intiter->first);
1108 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1110 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1111 PropertyName = PropertyElement.GetNextToken();
1112 PropertyValue = PropertyElement.GetNextToken();
1114 intPrevValue = intiter->second;
1116 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1118 CaptureString(&PropertySeg2, FALSE);
1119 Anniversary = PropertySeg2;
1120 AnniversaryText = TRUE;
1126 // Setup blank lines for later on.
1129 bool FirstToken = TRUE;
1131 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1132 intiter != SplitPoints.end(); ++intiter){
1134 SLiter = SplitLength.find(intiter->first);
1136 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1138 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1139 PropertyName = PropertyElement.GetNextToken();
1140 PropertyValue = PropertyElement.GetNextToken();
1142 intPrevValue = intiter->second;
1144 // Process properties.
1146 CaptureString(&PropertyValue, FALSE);
1148 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1150 PropertyValue.Trim();
1151 PropertyValue.RemoveLast();
1155 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1157 PropertyValue.Remove(0, 1);
1161 if (PropertyName == wxT("ALTID")){
1163 AnniversaryAltID = PropertyValue;
1165 } else if (PropertyName == wxT("CALSCALE")){
1167 AnniversaryCalScale = PropertyValue;
1169 } else if (PropertyName != wxT("VALUE")) {
1171 // Something else we don't know about so append
1172 // to the tokens variable.
1174 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1176 if (FirstToken == TRUE){
1178 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1183 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1193 // Add the data to the variables and form.
1195 if (AnniversaryText == FALSE){
1197 Anniversary = PropertySeg2;
1201 if (!PropertyTokens.IsEmpty()){
1203 AnniversaryTokens = PropertyTokens;
1209 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1211 std::map<int, int> SplitPoints;
1212 std::map<int, int> SplitLength;
1214 int intPrevValue = 4;
1217 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1221 PropertyType PropType = PROPERTY_NONE;
1223 // Look for type before continuing.
1225 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1229 std::map<int, wxString> *TZList = NULL;
1230 std::map<int, wxString> *TZListType = NULL;
1231 std::map<int, wxString> *TZListMediatype = NULL;
1232 std::map<int, wxString> *TZListAltID = NULL;
1233 std::map<int, wxString> *TZListPID = NULL;
1234 std::map<int, wxString> *TZListTokens = NULL;
1235 std::map<int, int> *TZListPref = NULL;
1239 TZList = &GeneralTZList;
1240 TZListType = &GeneralTZListType;
1241 TZListMediatype = &GeneralTZListMediatype;
1242 TZListAltID = &GeneralTZListAltID;
1243 TZListPID = &GeneralTZListPID;
1244 TZListTokens = &GeneralTZListTokens;
1245 TZListPref = &GeneralTZListPref;
1248 TZList = &HomeTZList;
1249 TZListType = &HomeTZListType;
1250 TZListMediatype = &HomeTZListMediatype;
1251 TZListAltID = &HomeTZListAltID;
1252 TZListPID = &HomeTZListPID;
1253 TZListTokens = &HomeTZListTokens;
1254 TZListPref = &HomeTZListPref;
1257 TZList = &BusinessTZList;
1258 TZListType = &BusinessTZListType;
1259 TZListMediatype = &BusinessTZListMediatype;
1260 TZListAltID = &BusinessTZListAltID;
1261 TZListPID = &BusinessTZListPID;
1262 TZListTokens = &BusinessTZListTokens;
1263 TZListPref = &BusinessTZListPref;
1267 std::map<int, int>::iterator SLiter;
1268 wxString PropertyData;
1269 wxString PropertyName;
1270 wxString PropertyValue;
1271 wxString PropertyTokens;
1272 bool FirstToken = TRUE;
1274 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1275 intiter != SplitPoints.end(); ++intiter){
1277 SLiter = SplitLength.find(intiter->first);
1279 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1281 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1282 PropertyName = PropertyElement.GetNextToken();
1283 PropertyValue = PropertyElement.GetNextToken();
1285 intPrevValue = intiter->second;
1287 CaptureString(&PropertyValue, FALSE);
1289 if (PropertyName == wxT("ALTID")){
1291 TZListAltID->erase(*TimeZoneCount);
1292 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1294 } else if (PropertyName == wxT("PID")){
1296 TZListPID->erase(*TimeZoneCount);
1297 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1299 } else if (PropertyName == wxT("PREF")){
1301 int PriorityNumber = 0;
1302 bool ValidNumber = TRUE;
1305 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1308 catch(std::invalid_argument &e){
1309 ValidNumber = FALSE;
1312 if (ValidNumber == TRUE){
1314 TZListPref->erase(*TimeZoneCount);
1315 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1319 } else if (PropertyName == wxT("MEDIATYPE")){
1321 TZListMediatype->erase(*TimeZoneCount);
1322 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1326 // Something else we don't know about so append
1327 // to the tokens variable.
1329 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1331 if (FirstToken == TRUE){
1333 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1338 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1348 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1350 // Add the name token data.
1352 if (!PropertyTokens.IsEmpty()){
1354 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1361 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1363 size_t intPropertyLen = PropertySeg1.Len();
1364 std::map<int, int> SplitPoints;
1365 std::map<int, int> SplitLength;
1366 std::map<int, int>::iterator SLiter;
1367 wxString PropertyData;
1368 wxString PropertyName;
1369 wxString PropertyValue;
1370 wxString PropertyTokens;
1371 wxString AddressLabel;
1372 wxString AddressLang;
1373 wxString AddressAltID;
1374 wxString AddressPID;
1375 wxString AddressTokens;
1376 wxString AddressGeo;
1377 wxString AddressTimezone;
1378 wxString AddressType;
1379 wxString AddressMediatype;
1380 wxString AddressPOBox;
1381 wxString AddressExtended;
1382 wxString AddressStreet;
1383 wxString AddressLocality;
1384 wxString AddressCity;
1385 wxString AddressRegion;
1386 wxString AddressPostalCode;
1387 wxString AddressCountry;
1388 bool FirstToken = TRUE;
1389 int intSplitsFound = 0;
1390 int intSplitSize = 0;
1391 int intPrevValue = 5;
1396 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1400 PropertyType PropType = PROPERTY_NONE;
1402 // Look for type before continuing.
1404 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1408 std::map<int, wxString> *AddressList = NULL;
1409 std::map<int, wxString> *AddressListTown = NULL;
1410 std::map<int, wxString> *AddressListCounty = NULL;
1411 std::map<int, wxString> *AddressListPostCode = NULL;
1412 std::map<int, wxString> *AddressListCountry = NULL;
1413 std::map<int, wxString> *AddressListLabel = NULL;
1414 std::map<int, wxString> *AddressListLang = NULL;
1415 std::map<int, wxString> *AddressListAltID = NULL;
1416 std::map<int, wxString> *AddressListPID = NULL;
1417 std::map<int, wxString> *AddressListTokens = NULL;
1418 std::map<int, wxString> *AddressListGeo = NULL;
1419 std::map<int, wxString> *AddressListTimezone = NULL;
1420 std::map<int, wxString> *AddressListType = NULL;
1421 std::map<int, wxString> *AddressListMediatype = NULL;
1422 std::map<int, int> *AddressListPref = NULL;
1426 AddressList = &GeneralAddressList;
1427 AddressListTown = &GeneralAddressListTown;
1428 AddressListCounty = &GeneralAddressListCounty;
1429 AddressListPostCode = &GeneralAddressListPostCode;
1430 AddressListCountry = &GeneralAddressListCountry;
1431 AddressListLabel = &GeneralAddressListLabel;
1432 AddressListLang = &GeneralAddressListLang;
1433 AddressListAltID = &GeneralAddressListAltID;
1434 AddressListPID = &GeneralAddressListPID;
1435 AddressListTokens = &GeneralAddressListTokens;
1436 AddressListGeo = &GeneralAddressListGeo;
1437 AddressListTimezone = &GeneralAddressListTimezone;
1438 AddressListType = &GeneralAddressListType;
1439 AddressListMediatype = &GeneralAddressListMediatype;
1440 AddressListPref = &GeneralAddressListPref;
1443 AddressList = &HomeAddressList;
1444 AddressListTown = &HomeAddressListTown;
1445 AddressListCounty = &HomeAddressListCounty;
1446 AddressListPostCode = &HomeAddressListPostCode;
1447 AddressListCountry = &HomeAddressListCountry;
1448 AddressListLabel = &HomeAddressListLabel;
1449 AddressListLang = &HomeAddressListLang;
1450 AddressListAltID = &HomeAddressListAltID;
1451 AddressListPID = &HomeAddressListPID;
1452 AddressListTokens = &HomeAddressListTokens;
1453 AddressListGeo = &HomeAddressListGeo;
1454 AddressListTimezone = &HomeAddressListTimezone;
1455 AddressListType = &HomeAddressListType;
1456 AddressListMediatype = &HomeAddressListMediatype;
1457 AddressListPref = &HomeAddressListPref;
1460 AddressList = &BusinessAddressList;
1461 AddressListTown = &BusinessAddressListTown;
1462 AddressListCounty = &BusinessAddressListCounty;
1463 AddressListPostCode = &BusinessAddressListPostCode;
1464 AddressListCountry = &BusinessAddressListCountry;
1465 AddressListLabel = &BusinessAddressListLabel;
1466 AddressListLang = &BusinessAddressListLang;
1467 AddressListAltID = &BusinessAddressListAltID;
1468 AddressListPID = &BusinessAddressListPID;
1469 AddressListTokens = &BusinessAddressListTokens;
1470 AddressListGeo = &BusinessAddressListGeo;
1471 AddressListTimezone = &BusinessAddressListTimezone;
1472 AddressListType = &BusinessAddressListType;
1473 AddressListMediatype = &BusinessAddressListMediatype;
1474 AddressListPref = &BusinessAddressListPref;
1480 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1481 intiter != SplitPoints.end(); ++intiter){
1483 SLiter = SplitLength.find(intiter->first);
1485 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1487 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1488 PropertyName = PropertyElement.GetNextToken();
1489 PropertyValue = PropertyElement.GetNextToken();
1491 intPrevValue = intiter->second;
1493 CaptureString(&PropertyValue, FALSE);
1495 // Process properties.
1497 if (PropertyName == wxT("LABEL")){
1499 AddressListLabel->erase(*AddressCount);
1500 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1502 } else if (PropertyName == wxT("LANGUAGE")){
1504 AddressListLang->erase(*AddressCount);
1505 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1507 } else if (PropertyName == wxT("ALTID")){
1509 AddressListAltID->erase(*AddressCount);
1510 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1512 } else if (PropertyName == wxT("PID")){
1514 AddressListPID->erase(*AddressCount);
1515 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1517 } else if (PropertyName == wxT("GEO")){
1519 AddressListGeo->erase(*AddressCount);
1520 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1522 } else if (PropertyName == wxT("TZ")){
1524 AddressListTimezone->erase(*AddressCount);
1525 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1527 } else if (PropertyName == wxT("MEDIATYPE")){
1529 AddressListMediatype->erase(*AddressCount);
1530 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1532 } else if (PropertyName == wxT("PREF")){
1534 int PriorityNumber = 0;
1535 bool ValidNumber = TRUE;
1538 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1541 catch(std::invalid_argument &e){
1542 ValidNumber = FALSE;
1545 if (ValidNumber == TRUE){
1547 AddressListPref->erase(*AddressCount);
1548 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1554 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1556 if (FirstToken == TRUE){
1558 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1563 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1573 // Split the address.
1575 //std::map<int, int>::iterator SLiter;
1576 intPropertyLen = PropertySeg2.Len();
1577 SplitPoints.clear();
1578 SplitLength.clear();
1583 for (int i = 0; i <= intPropertyLen; i++){
1587 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1590 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1592 if (intSplitsFound == 6){
1594 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1599 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1609 // Split the data into several parts.
1611 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1612 intiter != SplitPoints.end(); ++intiter){
1614 if (intiter->first == 1){
1616 // Deal with PO Box.
1618 SLiter = SplitLength.find(1);
1620 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1621 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1622 intPrevValue = intiter->second;
1624 } else if (intiter->first == 2){
1626 // Deal with extended address.
1628 SLiter = SplitLength.find(2);
1630 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1631 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1632 intPrevValue = intiter->second;
1634 } else if (intiter->first == 3){
1636 // Deal with street address.
1638 SLiter = SplitLength.find(3);
1640 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1641 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1642 intPrevValue = intiter->second;
1644 } else if (intiter->first == 4){
1646 // Deal with locality
1648 SLiter = SplitLength.find(4);
1650 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1651 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1652 intPrevValue = intiter->second;
1654 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1656 } else if (intiter->first == 5){
1658 // Deal with region.
1660 SLiter = SplitLength.find(5);
1662 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1663 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1664 intPrevValue = intiter->second;
1666 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1668 } else if (intiter->first == 6){
1670 // Deal with post code.
1672 SLiter = SplitLength.find(6);
1674 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1675 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1676 intPrevValue = intiter->second;
1678 // Deal with country.
1680 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1681 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1689 // Add the data to the General/Home/Work address variables.
1691 CaptureString(&AddressStreet, FALSE);
1692 CaptureString(&AddressLocality, FALSE);
1693 CaptureString(&AddressRegion, FALSE);
1694 CaptureString(&AddressPostalCode, FALSE);
1695 CaptureString(&AddressCountry, FALSE);
1697 if (!PropertyTokens.IsEmpty()){
1699 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1703 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1704 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1705 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1706 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1707 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1711 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1714 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1717 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1721 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1725 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1727 std::map<int, int> SplitPoints;
1728 std::map<int, int> SplitLength;
1730 int intPrevValue = 7;
1733 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1737 PropertyType PropType = PROPERTY_NONE;
1739 // Look for type before continuing.
1741 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1743 std::map<int, wxString> *EmailList = NULL;
1744 std::map<int, wxString> *EmailListType = NULL;
1745 std::map<int, wxString> *EmailListAltID = NULL;
1746 std::map<int, wxString> *EmailListPID = NULL;
1747 std::map<int, wxString> *EmailListTokens = NULL;
1748 std::map<int, int> *EmailListPref = NULL;
1752 EmailList = &GeneralEmailList;
1753 EmailListType = &GeneralEmailListType;
1754 EmailListAltID = &GeneralEmailListAltID;
1755 EmailListPID = &GeneralEmailListPID;
1756 EmailListTokens = &GeneralEmailListTokens;
1757 EmailListPref = &GeneralEmailListPref;
1760 EmailList = &HomeEmailList;
1761 EmailListType = &HomeEmailListType;
1762 EmailListAltID = &HomeEmailListAltID;
1763 EmailListPID = &HomeEmailListPID;
1764 EmailListTokens = &HomeEmailListTokens;
1765 EmailListPref = &HomeEmailListPref;
1768 EmailList = &BusinessEmailList;
1769 EmailListType = &BusinessEmailListType;
1770 EmailListAltID = &BusinessEmailListAltID;
1771 EmailListPID = &BusinessEmailListPID;
1772 EmailListTokens = &BusinessEmailListTokens;
1773 EmailListPref = &BusinessEmailListPref;
1779 std::map<int,int>::iterator SLiter;
1780 wxString PropertyData;
1781 wxString PropertyName;
1782 wxString PropertyValue;
1783 wxString PropertyTokens;
1784 bool FirstToken = TRUE;
1786 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1787 intiter != SplitPoints.end(); ++intiter){
1789 SLiter = SplitLength.find(intiter->first);
1791 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1793 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1794 PropertyName = PropertyElement.GetNextToken();
1795 PropertyValue = PropertyElement.GetNextToken();
1797 intPrevValue = intiter->second;
1799 CaptureString(&PropertyValue, FALSE);
1801 // Process properties.
1803 if (PropertyName == wxT("ALTID")){
1805 EmailListAltID->erase(*EmailCount);
1806 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1808 } else if (PropertyName == wxT("PID")){
1810 EmailListPID->erase(*EmailCount);
1811 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1813 } else if (PropertyName == wxT("PREF")){
1815 int PriorityNumber = 0;
1816 bool ValidNumber = TRUE;
1819 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1822 catch(std::invalid_argument &e){
1823 ValidNumber = FALSE;
1826 if (ValidNumber == TRUE){
1828 EmailListPref->erase(*EmailCount);
1829 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1835 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1837 if (FirstToken == TRUE){
1839 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1844 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1854 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1856 // Add the name token data.
1858 if (!PropertyTokens.IsEmpty()){
1860 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1867 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1869 std::map<int, int> SplitPoints;
1870 std::map<int, int> SplitLength;
1872 int intPrevValue = 6;
1875 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1879 PropertyType PropType = PROPERTY_NONE;
1881 // Look for type before continuing.
1883 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1885 std::map<int, wxString> *IMList = NULL;
1886 std::map<int, wxString> *IMListType = NULL;
1887 std::map<int, wxString> *IMListAltID = NULL;
1888 std::map<int, wxString> *IMListPID = NULL;
1889 std::map<int, wxString> *IMListTokens = NULL;
1890 std::map<int, wxString> *IMListMediatype = NULL;
1891 std::map<int, int> *IMListPref = NULL;
1895 IMList = &GeneralIMList;
1896 IMListType = &GeneralIMListType;
1897 IMListAltID = &GeneralIMListAltID;
1898 IMListPID = &GeneralIMListPID;
1899 IMListTokens = &GeneralIMListTokens;
1900 IMListMediatype = &GeneralIMListMediatype;
1901 IMListPref = &GeneralIMListPref;
1904 IMList = &HomeIMList;
1905 IMListType = &HomeIMListType;
1906 IMListAltID = &HomeIMListAltID;
1907 IMListPID = &HomeIMListPID;
1908 IMListTokens = &HomeIMListTokens;
1909 IMListMediatype = &HomeIMListMediatype;
1910 IMListPref = &HomeIMListPref;
1913 IMList = &BusinessIMList;
1914 IMListType = &BusinessIMListType;
1915 IMListAltID = &BusinessIMListAltID;
1916 IMListPID = &BusinessIMListPID;
1917 IMListTokens = &BusinessIMListTokens;
1918 IMListMediatype = &BusinessIMListMediatype;
1919 IMListPref = &BusinessIMListPref;
1925 std::map<int,int>::iterator SLiter;
1926 wxString PropertyData;
1927 wxString PropertyName;
1928 wxString PropertyValue;
1929 wxString PropertyTokens;
1930 bool FirstToken = TRUE;
1932 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1933 intiter != SplitPoints.end(); ++intiter){
1935 SLiter = SplitLength.find(intiter->first);
1937 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1939 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1940 PropertyName = PropertyElement.GetNextToken();
1941 PropertyValue = PropertyElement.GetNextToken();
1943 intPrevValue = intiter->second;
1945 CaptureString(&PropertyValue, FALSE);
1947 // Process properties.
1949 if (PropertyName == wxT("ALTID")){
1951 IMListAltID->erase(*IMCount);
1952 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1954 } else if (PropertyName == wxT("PID")){
1956 IMListPID->erase(*IMCount);
1957 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1959 } else if (PropertyName == wxT("MEDIATYPE")){
1961 IMListMediatype->erase(*IMCount);
1962 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1964 } else if (PropertyName == wxT("PREF")){
1966 int PriorityNumber = 0;
1967 bool ValidNumber = TRUE;
1970 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1973 catch(std::invalid_argument &e){
1974 ValidNumber = FALSE;
1977 if (ValidNumber == TRUE){
1979 IMListPref->erase(*IMCount);
1980 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1986 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1988 if (FirstToken == TRUE){
1990 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1995 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2005 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2007 // Add the name token data.
2009 if (!PropertyTokens.IsEmpty()){
2011 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2017 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2019 std::map<int, int> SplitPoints;
2020 std::map<int, int> SplitLength;
2021 std::map<int, int>::iterator SLiter;
2025 PropertyType PropType = PROPERTY_NONE;
2027 // Look for type before continuing.
2030 wxString TelTypeDetail;
2031 wxString PropertyData;
2032 wxString PropertyName;
2033 wxString PropertyValue;
2034 wxString PropertyTokens;
2036 std::map<int,int> TypeSplitPoints;
2037 std::map<int,int> TypeSplitLength;
2038 std::map<int,int>::iterator TSLiter;
2040 int intSplitSize = 0;
2041 int intSplitsFound = 0;
2042 int intSplitPoint = 0;
2044 int intPrevValue = 5;
2046 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2050 // Look for type before continuing.
2052 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2053 intiter != SplitPoints.end(); ++intiter){
2055 SLiter = SplitLength.find(intiter->first);
2057 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2059 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2060 PropertyName = PropertyElement.GetNextToken();
2061 PropertyValue = PropertyElement.GetNextToken();
2063 intPrevValue = intiter->second;
2065 if (PropertyName == wxT("TYPE")){
2067 // Process each value in type and translate each
2070 // Strip out the quotes if they are there.
2072 size_t intPropertyValueLen = PropertyValue.Len();
2074 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2076 PropertyValue.Trim();
2077 PropertyValue.RemoveLast();
2081 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2083 PropertyValue.Remove(0, 1);
2087 TelTypeDetail = PropertyValue;
2093 for (int i = 0; i <= intPropertyValueLen; i++){
2097 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2099 if (intSplitsFound == 0){
2101 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2102 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2106 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2107 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2120 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2121 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2123 int intTypeSeek = 0;
2125 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2126 typeiter != TypeSplitPoints.end(); ++typeiter){
2128 wxString TypePropertyName;
2130 TSLiter = TypeSplitLength.find(typeiter->first);
2132 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2134 if (intTypeSeek == 0){
2139 TelTypeUI.Append(wxT(","));
2143 if (TypePropertyName == wxT("home")){
2145 PropType = PROPERTY_HOME;
2147 } else if (TypePropertyName == wxT("work")){
2149 PropType = PROPERTY_WORK;
2154 if (TypePropertyName == wxT("text")){
2156 TelTypeUI.Append(_("text"));
2159 } else if (TypePropertyName == wxT("voice")){
2161 TelTypeUI.Append(_("voice"));
2164 } else if (TypePropertyName == wxT("fax")){
2166 TelTypeUI.Append(_("fax"));
2169 } else if (TypePropertyName == wxT("cell")){
2171 TelTypeUI.Append(_("mobile"));
2174 } else if (TypePropertyName == wxT("video")){
2176 TelTypeUI.Append(_("video"));
2179 } else if (TypePropertyName == wxT("pager")){
2181 TelTypeUI.Append(_("pager"));
2184 } else if (TypePropertyName == wxT("textphone")){
2186 TelTypeUI.Append(_("textphone"));
2197 std::map<int, wxString> *TelephoneList = NULL;
2198 std::map<int, wxString> *TelephoneListType = NULL;
2199 std::map<int, wxString> *TelephoneListAltID = NULL;
2200 std::map<int, wxString> *TelephoneListPID = NULL;
2201 std::map<int, wxString> *TelephoneListTokens = NULL;
2202 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2203 std::map<int, int> *TelephoneListPref = NULL;
2207 TelephoneList = &GeneralTelephoneList;
2208 TelephoneListType = &GeneralTelephoneListType;
2209 TelephoneListAltID = &GeneralTelephoneListAltID;
2210 TelephoneListPID = &GeneralTelephoneListPID;
2211 TelephoneListTokens = &GeneralTelephoneListTokens;
2212 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2213 TelephoneListPref = &GeneralTelephoneListPref;
2216 TelephoneList = &HomeTelephoneList;
2217 TelephoneListType = &HomeTelephoneListType;
2218 TelephoneListAltID = &HomeTelephoneListAltID;
2219 TelephoneListPID = &HomeTelephoneListPID;
2220 TelephoneListTokens = &HomeTelephoneListTokens;
2221 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2222 TelephoneListPref = &HomeTelephoneListPref;
2225 TelephoneList = &BusinessTelephoneList;
2226 TelephoneListType = &BusinessTelephoneListType;
2227 TelephoneListAltID = &BusinessTelephoneListAltID;
2228 TelephoneListPID = &BusinessTelephoneListPID;
2229 TelephoneListTokens = &BusinessTelephoneListTokens;
2230 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2231 TelephoneListPref = &BusinessTelephoneListPref;
2235 // Process the properties.
2237 bool FirstToken = TRUE;
2240 SplitPoints.clear();
2241 SplitLength.clear();
2243 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2247 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2248 intiter != SplitPoints.end(); ++intiter){
2250 SLiter = SplitLength.find(intiter->first);
2252 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2254 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2255 PropertyName = PropertyElement.GetNextToken();
2256 PropertyValue = PropertyElement.GetNextToken();
2258 intPrevValue = intiter->second;
2260 CaptureString(&PropertyValue, FALSE);
2262 // Process properties.
2264 if (PropertyName == wxT("ALTID")){
2266 TelephoneListAltID->erase(*TelephoneCount);
2267 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2269 } else if (PropertyName == wxT("PID")){
2271 TelephoneListPID->erase(*TelephoneCount);
2272 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2274 } else if (PropertyName == wxT("PREF")){
2276 int PriorityNumber = 0;
2277 bool ValidNumber = TRUE;
2280 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2283 catch(std::invalid_argument &e){
2284 ValidNumber = FALSE;
2287 if (ValidNumber == TRUE){
2289 TelephoneListPref->erase(*TelephoneCount);
2290 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2296 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2298 if (FirstToken == TRUE){
2300 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2305 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2315 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2316 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2318 // Add the name token data.
2320 if (!PropertyTokens.IsEmpty()){
2322 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2328 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2330 std::map<int, int> SplitPoints;
2331 std::map<int, int> SplitLength;
2333 int intPrevValue = 6;
2336 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2340 PropertyType PropType = PROPERTY_NONE;
2342 // Look for type before continuing.
2344 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2346 std::map<int, wxString> *LanguageList = NULL;
2347 std::map<int, wxString> *LanguageListType = NULL;
2348 std::map<int, wxString> *LanguageListAltID = NULL;
2349 std::map<int, wxString> *LanguageListPID = NULL;
2350 std::map<int, wxString> *LanguageListTokens = NULL;
2351 std::map<int, int> *LanguageListPref = NULL;
2355 LanguageList = &GeneralLanguageList;
2356 LanguageListType = &GeneralLanguageListType;
2357 LanguageListAltID = &GeneralLanguageListAltID;
2358 LanguageListPID = &GeneralLanguageListPID;
2359 LanguageListTokens = &GeneralLanguageListTokens;
2360 LanguageListPref = &GeneralLanguageListPref;
2363 LanguageList = &HomeLanguageList;
2364 LanguageListType = &HomeLanguageListType;
2365 LanguageListAltID = &HomeLanguageListAltID;
2366 LanguageListPID = &HomeLanguageListPID;
2367 LanguageListTokens = &HomeLanguageListTokens;
2368 LanguageListPref = &HomeLanguageListPref;
2371 LanguageList = &BusinessLanguageList;
2372 LanguageListType = &BusinessLanguageListType;
2373 LanguageListAltID = &BusinessLanguageListAltID;
2374 LanguageListPID = &BusinessLanguageListPID;
2375 LanguageListTokens = &BusinessLanguageListTokens;
2376 LanguageListPref = &BusinessLanguageListPref;
2382 std::map<int,int>::iterator SLiter;
2383 wxString PropertyData;
2384 wxString PropertyName;
2385 wxString PropertyValue;
2386 wxString PropertyTokens;
2387 bool FirstToken = TRUE;
2389 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2390 intiter != SplitPoints.end(); ++intiter){
2392 SLiter = SplitLength.find(intiter->first);
2394 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2396 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2397 PropertyName = PropertyElement.GetNextToken();
2398 PropertyValue = PropertyElement.GetNextToken();
2400 intPrevValue = intiter->second;
2402 CaptureString(&PropertyValue, FALSE);
2404 // Process properties.
2406 if (PropertyName == wxT("ALTID")){
2408 LanguageListAltID->erase(*LanguageCount);
2409 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2411 } else if (PropertyName == wxT("PID")){
2413 LanguageListPID->erase(*LanguageCount);
2414 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2416 } else if (PropertyName == wxT("PREF")){
2418 int PriorityNumber = 0;
2419 bool ValidNumber = TRUE;
2422 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2425 catch(std::invalid_argument &e){
2426 ValidNumber = FALSE;
2429 if (ValidNumber == TRUE){
2431 LanguageListPref->erase(*LanguageCount);
2432 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2438 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2440 if (FirstToken == TRUE){
2442 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2447 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2457 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2459 // Add the name token data.
2461 if (!PropertyTokens.IsEmpty()){
2463 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2469 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2471 std::map<int, int> SplitPoints;
2472 std::map<int, int> SplitLength;
2474 int intPrevValue = 5;
2477 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2481 PropertyType PropType = PROPERTY_NONE;
2483 // Look for type before continuing.
2485 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2487 std::map<int, wxString> *GeopositionList = NULL;
2488 std::map<int, wxString> *GeopositionListType = NULL;
2489 std::map<int, wxString> *GeopositionListAltID = NULL;
2490 std::map<int, wxString> *GeopositionListPID = NULL;
2491 std::map<int, wxString> *GeopositionListTokens = NULL;
2492 std::map<int, wxString> *GeopositionListMediatype = NULL;
2493 std::map<int, int> *GeopositionListPref = NULL;
2497 GeopositionList = &GeneralGeographyList;
2498 GeopositionListType = &GeneralGeographyListType;
2499 GeopositionListAltID = &GeneralGeographyListAltID;
2500 GeopositionListPID = &GeneralGeographyListPID;
2501 GeopositionListTokens = &GeneralGeographyListTokens;
2502 GeopositionListMediatype = &GeneralGeographyListMediatype;
2503 GeopositionListPref = &GeneralGeographyListPref;
2506 GeopositionList = &HomeGeographyList;
2507 GeopositionListType = &HomeGeographyListType;
2508 GeopositionListAltID = &HomeGeographyListAltID;
2509 GeopositionListPID = &HomeGeographyListPID;
2510 GeopositionListTokens = &HomeGeographyListTokens;
2511 GeopositionListMediatype = &HomeGeographyListMediatype;
2512 GeopositionListPref = &HomeGeographyListPref;
2515 GeopositionList = &BusinessGeographyList;
2516 GeopositionListType = &BusinessGeographyListType;
2517 GeopositionListAltID = &BusinessGeographyListAltID;
2518 GeopositionListPID = &BusinessGeographyListPID;
2519 GeopositionListTokens = &BusinessGeographyListTokens;
2520 GeopositionListMediatype = &BusinessGeographyListMediatype;
2521 GeopositionListPref = &BusinessGeographyListPref;
2527 std::map<int,int>::iterator SLiter;
2528 wxString PropertyData;
2529 wxString PropertyName;
2530 wxString PropertyValue;
2531 wxString PropertyTokens;
2532 bool FirstToken = TRUE;
2534 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2535 intiter != SplitPoints.end(); ++intiter){
2537 SLiter = SplitLength.find(intiter->first);
2539 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2541 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2542 PropertyName = PropertyElement.GetNextToken();
2543 PropertyValue = PropertyElement.GetNextToken();
2545 intPrevValue = intiter->second;
2547 CaptureString(&PropertyValue, FALSE);
2549 // Process properties.
2551 if (PropertyName == wxT("ALTID")){
2553 GeopositionListAltID->erase(*GeographicCount);
2554 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2556 } else if (PropertyName == wxT("PID")){
2558 GeopositionListPID->erase(*GeographicCount);
2559 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2561 } else if (PropertyName == wxT("MEDIATYPE")){
2563 GeopositionListMediatype->erase(*GeographicCount);
2564 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2566 } else if (PropertyName == wxT("PREF")){
2568 int PriorityNumber = 0;
2569 bool ValidNumber = TRUE;
2572 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2575 catch(std::invalid_argument &e){
2576 ValidNumber = FALSE;
2579 if (ValidNumber == TRUE){
2581 GeopositionListPref->erase(*GeographicCount);
2582 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2588 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2590 if (FirstToken == TRUE){
2592 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2597 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2607 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2609 // Add the name token data.
2611 if (!PropertyTokens.IsEmpty()){
2613 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2619 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2621 size_t intPropertyLen = PropertySeg1.Len();
2622 std::map<int, int> SplitPoints;
2623 std::map<int, int> SplitLength;
2624 std::map<int, int>::iterator SLiter;
2625 wxString PropertyData;
2626 wxString PropertyName;
2627 wxString PropertyValue;
2628 wxString PropertyTokens;
2629 wxString RelatedType;
2630 wxString RelatedTypeOriginal;
2631 wxString RelatedName;
2632 bool FirstToken = TRUE;
2633 int intSplitsFound = 0;
2634 int intSplitSize = 0;
2635 int intPrevValue = 9;
2639 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2643 // Look for type before continuing.
2645 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2646 intiter != SplitPoints.end(); ++intiter){
2648 SLiter = SplitLength.find(intiter->first);
2650 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2652 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2653 PropertyName = PropertyElement.GetNextToken();
2654 PropertyValue = PropertyElement.GetNextToken();
2656 intPrevValue = intiter->second;
2660 RelatedTypeOriginal = PropertyValue;
2662 if (PropertyName == wxT("TYPE")){
2664 if (PropertyValue == wxT("contact")){
2666 RelatedType = _("Contact");
2668 } else if (PropertyValue == wxT("acquaintance")){
2670 RelatedType = _("Acquaintance");
2672 } else if (PropertyValue == wxT("friend")){
2674 RelatedType = _("Friend");
2676 } else if (PropertyValue == wxT("met")){
2678 RelatedType = _("Met");
2680 } else if (PropertyValue == wxT("co-worker")){
2682 RelatedType = _("Co-worker");
2684 } else if (PropertyValue == wxT("colleague")){
2686 RelatedType = _("Colleague");
2688 } else if (PropertyValue == wxT("co-resident")){
2690 RelatedType = _("Co-resident");
2692 } else if (PropertyValue == wxT("neighbor")){
2694 RelatedType = _("Neighbour");
2696 } else if (PropertyValue == wxT("child")){
2698 RelatedType = _("Child");
2700 } else if (PropertyValue == wxT("parent")){
2702 RelatedType = _("Parent");
2704 } else if (PropertyValue == wxT("sibling")){
2706 RelatedType = _("Sibling");
2708 } else if (PropertyValue == wxT("spouse")){
2710 RelatedType = _("Spouse");
2712 } else if (PropertyValue == wxT("kin")){
2714 RelatedType = _("Kin");
2716 } else if (PropertyValue == wxT("muse")){
2718 RelatedType = _("Muse");
2720 } else if (PropertyValue == wxT("crush")){
2722 RelatedType = _("Crush");
2724 } else if (PropertyValue == wxT("date")){
2726 RelatedType = _("Date");
2728 } else if (PropertyValue == wxT("sweetheart")){
2730 RelatedType = _("Sweetheart");
2732 } else if (PropertyValue == wxT("me")){
2734 RelatedType = _("Me");
2736 } else if (PropertyValue == wxT("agent")){
2738 RelatedType = _("Agent");
2740 } else if (PropertyValue == wxT("emergency")){
2742 RelatedType = _("Emergency");
2746 RelatedType = PropertyValue;
2756 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2757 intiter != SplitPoints.end(); ++intiter){
2759 SLiter = SplitLength.find(intiter->first);
2761 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2763 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2764 PropertyName = PropertyElement.GetNextToken();
2765 PropertyValue = PropertyElement.GetNextToken();
2767 intPrevValue = intiter->second;
2769 // Process properties.
2771 size_t intPropertyValueLen = PropertyValue.Len();
2773 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2775 PropertyValue.Trim();
2776 PropertyValue.RemoveLast();
2780 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2782 PropertyValue.Remove(0, 1);
2786 CaptureString(&PropertyValue, FALSE);
2788 if (PropertyName == wxT("ALTID")){
2790 GeneralRelatedListAltID.erase(*RelatedCount);
2791 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2793 } else if (PropertyName == wxT("PID")){
2795 GeneralRelatedListPID.erase(*RelatedCount);
2796 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2798 } else if (PropertyName == wxT("PREF")){
2800 int PriorityNumber = 0;
2801 bool ValidNumber = TRUE;
2804 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2807 catch(std::invalid_argument &e){
2808 ValidNumber = FALSE;
2811 if (ValidNumber == TRUE){
2813 GeneralRelatedListPref.erase(*RelatedCount);
2814 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2818 } else if (PropertyName == wxT("LANGUAGE")){
2820 GeneralRelatedListLanguage.erase(*RelatedCount);
2821 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2823 } else if (PropertyName != wxT("TYPE")) {
2825 // Something else we don't know about so append
2826 // to the tokens variable.
2828 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2830 if (FirstToken == TRUE){
2832 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2837 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2847 // Add the data to the General/Home/Work address variables.
2849 GeneralRelatedList.erase(*RelatedCount);
2850 GeneralRelatedListRelType.erase(*RelatedCount);
2851 GeneralRelatedListType.erase(*RelatedCount);
2852 GeneralRelatedListTokens.erase(*RelatedCount);
2853 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2854 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2855 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2856 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2860 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2862 std::map<int, int> SplitPoints;
2863 std::map<int, int> SplitLength;
2864 std::map<int, int>::iterator SLiter;
2865 wxString PropertyData;
2866 wxString PropertyName;
2867 wxString PropertyValue;
2868 wxString PropertyTokens;
2869 bool FirstToken = TRUE;
2870 int intPrevValue = 5;
2875 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2879 PropertyType PropType = PROPERTY_NONE;
2881 // Look for type before continuing.
2883 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2885 // Setup the pointers.
2887 std::map<int, wxString> *WebsiteList = NULL;
2888 std::map<int, wxString> *WebsiteListAltID = NULL;
2889 std::map<int, wxString> *WebsiteListPID = NULL;
2890 std::map<int, wxString> *WebsiteListType = NULL;
2891 std::map<int, wxString> *WebsiteListTokens = NULL;
2892 std::map<int, wxString> *WebsiteListMediatype = NULL;
2893 std::map<int, int> *WebsiteListPref = NULL;
2895 // Setup blank lines for later on.
2899 WebsiteList = &GeneralWebsiteList;
2900 WebsiteListType = &GeneralWebsiteListType;
2901 WebsiteListAltID = &GeneralWebsiteListAltID;
2902 WebsiteListPID = &GeneralWebsiteListPID;
2903 WebsiteListTokens = &GeneralWebsiteListTokens;
2904 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2905 WebsiteListPref = &GeneralWebsiteListPref;
2908 WebsiteList = &HomeWebsiteList;
2909 WebsiteListType = &HomeWebsiteListType;
2910 WebsiteListAltID = &HomeWebsiteListAltID;
2911 WebsiteListPID = &HomeWebsiteListPID;
2912 WebsiteListTokens = &HomeWebsiteListTokens;
2913 WebsiteListMediatype = &HomeWebsiteListMediatype;
2914 WebsiteListPref = &HomeWebsiteListPref;
2917 WebsiteList = &BusinessWebsiteList;
2918 WebsiteListType = &BusinessWebsiteListType;
2919 WebsiteListAltID = &BusinessWebsiteListAltID;
2920 WebsiteListPID = &BusinessWebsiteListPID;
2921 WebsiteListTokens = &BusinessWebsiteListTokens;
2922 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2923 WebsiteListPref = &BusinessWebsiteListPref;
2929 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2930 intiter != SplitPoints.end(); ++intiter){
2932 SLiter = SplitLength.find(intiter->first);
2934 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2936 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2937 PropertyName = PropertyElement.GetNextToken();
2938 PropertyValue = PropertyElement.GetNextToken();
2940 intPrevValue = intiter->second;
2942 // Process properties.
2944 size_t intPropertyValueLen = PropertyValue.Len();
2946 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2948 PropertyValue.Trim();
2949 PropertyValue.RemoveLast();
2953 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2955 PropertyValue.Remove(0, 1);
2959 CaptureString(&PropertyValue, FALSE);
2961 if (PropertyName == wxT("ALTID")){
2963 WebsiteListAltID->erase(*URLCount);
2964 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2966 } else if (PropertyName == wxT("PID")){
2968 WebsiteListPID->erase(*URLCount);
2969 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2971 } else if (PropertyName == wxT("PREF")){
2973 int PriorityNumber = 0;
2974 bool ValidNumber = TRUE;
2977 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2980 catch(std::invalid_argument &e){
2981 ValidNumber = FALSE;
2984 if (ValidNumber == TRUE){
2986 WebsiteListPref->erase(*URLCount);
2987 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2991 } else if (PropertyName == wxT("MEDIATYPE")){
2993 WebsiteListMediatype->erase(*URLCount);
2994 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2998 // Something else we don't know about so append
2999 // to the tokens variable.
3001 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3003 if (FirstToken == TRUE){
3005 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3010 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3020 // Add the data to the General/Home/Work address variables.
3022 CaptureString(&PropertySeg2, FALSE);
3024 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3026 if (!PropertyTokens.IsEmpty()){
3028 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3034 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3036 std::map<int, int> SplitPoints;
3037 std::map<int, int> SplitLength;
3038 std::map<int, int>::iterator SLiter;
3039 wxString PropertyData;
3040 wxString PropertyName;
3041 wxString PropertyValue;
3042 wxString PropertyTokens;
3043 bool FirstToken = TRUE;
3044 int intPrevValue = 7;
3049 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3053 PropertyType PropType = PROPERTY_NONE;
3055 // Look for type before continuing.
3057 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3059 // Setup the pointers.
3061 std::map<int, wxString> *TitleList = NULL;
3062 std::map<int, wxString> *TitleListAltID = NULL;
3063 std::map<int, wxString> *TitleListPID = NULL;
3064 std::map<int, wxString> *TitleListType = NULL;
3065 std::map<int, wxString> *TitleListTokens = NULL;
3066 std::map<int, wxString> *TitleListLanguage = NULL;
3067 std::map<int, int> *TitleListPref = NULL;
3069 // Setup blank lines for later on.
3073 TitleList = &GeneralTitleList;
3074 TitleListType = &GeneralTitleListType;
3075 TitleListAltID = &GeneralTitleListAltID;
3076 TitleListPID = &GeneralTitleListPID;
3077 TitleListTokens = &GeneralTitleListTokens;
3078 TitleListLanguage = &GeneralTitleListLanguage;
3079 TitleListPref = &GeneralTitleListPref;
3082 TitleList = &HomeTitleList;
3083 TitleListType = &HomeTitleListType;
3084 TitleListAltID = &HomeTitleListAltID;
3085 TitleListPID = &HomeTitleListPID;
3086 TitleListTokens = &HomeTitleListTokens;
3087 TitleListLanguage = &HomeTitleListLanguage;
3088 TitleListPref = &HomeTitleListPref;
3091 TitleList = &BusinessTitleList;
3092 TitleListType = &BusinessTitleListType;
3093 TitleListAltID = &BusinessTitleListAltID;
3094 TitleListPID = &BusinessTitleListPID;
3095 TitleListTokens = &BusinessTitleListTokens;
3096 TitleListLanguage = &BusinessTitleListLanguage;
3097 TitleListPref = &BusinessTitleListPref;
3103 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3104 intiter != SplitPoints.end(); ++intiter){
3106 SLiter = SplitLength.find(intiter->first);
3108 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3110 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3111 PropertyName = PropertyElement.GetNextToken();
3112 PropertyValue = PropertyElement.GetNextToken();
3114 intPrevValue = intiter->second;
3116 // Process properties.
3118 size_t intPropertyValueLen = PropertyValue.Len();
3120 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3122 PropertyValue.Trim();
3123 PropertyValue.RemoveLast();
3127 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3129 PropertyValue.Remove(0, 1);
3133 CaptureString(&PropertyValue, FALSE);
3135 if (PropertyName == wxT("ALTID")){
3137 TitleListAltID->erase(*TitleCount);
3138 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3140 } else if (PropertyName == wxT("PID")){
3142 TitleListPID->erase(*TitleCount);
3143 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3145 } else if (PropertyName == wxT("PREF")){
3147 int PriorityNumber = 0;
3148 bool ValidNumber = TRUE;
3151 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3154 catch(std::invalid_argument &e){
3155 ValidNumber = FALSE;
3158 if (ValidNumber == TRUE){
3160 TitleListPref->erase(*TitleCount);
3161 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3165 } else if (PropertyName == wxT("LANGUAGE")){
3167 TitleListLanguage->erase(*TitleCount);
3168 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3172 // Something else we don't know about so append
3173 // to the tokens variable.
3175 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3177 if (FirstToken == TRUE){
3179 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3184 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3194 // Add the data to the General/Home/Work address variables.
3196 CaptureString(&PropertySeg2, FALSE);
3198 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3200 if (!PropertyTokens.IsEmpty()){
3202 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3208 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3210 std::map<int, int> SplitPoints;
3211 std::map<int, int> SplitLength;
3212 std::map<int, int>::iterator SLiter;
3213 wxString PropertyData;
3214 wxString PropertyName;
3215 wxString PropertyValue;
3216 wxString PropertyTokens;
3217 bool FirstToken = TRUE;
3218 int intPrevValue = 6;
3223 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3227 PropertyType PropType = PROPERTY_NONE;
3229 // Look for type before continuing.
3231 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3233 // Setup the pointers.
3235 std::map<int, wxString> *RoleList = NULL;
3236 std::map<int, wxString> *RoleListAltID = NULL;
3237 std::map<int, wxString> *RoleListPID = NULL;
3238 std::map<int, wxString> *RoleListType = NULL;
3239 std::map<int, wxString> *RoleListTokens = NULL;
3240 std::map<int, wxString> *RoleListLanguage = NULL;
3241 std::map<int, int> *RoleListPref = NULL;
3243 // Setup blank lines for later on.
3247 RoleList = &GeneralRoleList;
3248 RoleListType = &GeneralRoleListType;
3249 RoleListAltID = &GeneralRoleListAltID;
3250 RoleListPID = &GeneralRoleListPID;
3251 RoleListTokens = &GeneralRoleListTokens;
3252 RoleListLanguage = &GeneralRoleListLanguage;
3253 RoleListPref = &GeneralRoleListPref;
3256 RoleList = &HomeRoleList;
3257 RoleListType = &HomeRoleListType;
3258 RoleListAltID = &HomeRoleListAltID;
3259 RoleListPID = &HomeRoleListPID;
3260 RoleListTokens = &HomeRoleListTokens;
3261 RoleListLanguage = &HomeRoleListLanguage;
3262 RoleListPref = &HomeRoleListPref;
3265 RoleList = &BusinessRoleList;
3266 RoleListType = &BusinessRoleListType;
3267 RoleListAltID = &BusinessRoleListAltID;
3268 RoleListPID = &BusinessRoleListPID;
3269 RoleListTokens = &BusinessRoleListTokens;
3270 RoleListLanguage = &BusinessRoleListLanguage;
3271 RoleListPref = &BusinessRoleListPref;
3277 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3278 intiter != SplitPoints.end(); ++intiter){
3280 SLiter = SplitLength.find(intiter->first);
3282 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3284 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3285 PropertyName = PropertyElement.GetNextToken();
3286 PropertyValue = PropertyElement.GetNextToken();
3288 intPrevValue = intiter->second;
3290 // Process properties.
3292 size_t intPropertyValueLen = PropertyValue.Len();
3294 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3296 PropertyValue.Trim();
3297 PropertyValue.RemoveLast();
3301 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3303 PropertyValue.Remove(0, 1);
3307 CaptureString(&PropertyValue, FALSE);
3309 if (PropertyName == wxT("ALTID")){
3311 RoleListAltID->erase(*RoleCount);
3312 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3314 } else if (PropertyName == wxT("PID")){
3316 RoleListPID->erase(*RoleCount);
3317 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3319 } else if (PropertyName == wxT("PREF")){
3321 int PriorityNumber = 0;
3322 bool ValidNumber = TRUE;
3325 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3328 catch(std::invalid_argument &e){
3329 ValidNumber = FALSE;
3332 if (ValidNumber == TRUE){
3334 RoleListPref->erase(*RoleCount);
3335 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3339 } else if (PropertyName == wxT("LANGUAGE")){
3341 RoleListLanguage->erase(*RoleCount);
3342 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3346 // Something else we don't know about so append
3347 // to the tokens variable.
3349 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3351 if (FirstToken == TRUE){
3353 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3358 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3368 // Add the data to the General/Home/Work address variables.
3370 CaptureString(&PropertySeg2, FALSE);
3372 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3374 if (!PropertyTokens.IsEmpty()){
3376 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3382 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3384 std::map<int, int> SplitPoints;
3385 std::map<int, int> SplitLength;
3386 std::map<int, int>::iterator SLiter;
3387 wxString PropertyData;
3388 wxString PropertyName;
3389 wxString PropertyValue;
3390 wxString PropertyTokens;
3391 bool FirstToken = TRUE;
3392 int intPrevValue = 5;
3397 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3401 PropertyType PropType = PROPERTY_NONE;
3403 // Look for type before continuing.
3405 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3407 // Setup the pointers.
3409 std::map<int, wxString> *OrganisationsList = NULL;
3410 std::map<int, wxString> *OrganisationsListAltID = NULL;
3411 std::map<int, wxString> *OrganisationsListPID = NULL;
3412 std::map<int, wxString> *OrganisationsListType = NULL;
3413 std::map<int, wxString> *OrganisationsListTokens = NULL;
3414 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3415 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3416 std::map<int, int> *OrganisationsListPref = NULL;
3418 // Setup blank lines for later on.
3422 OrganisationsList = &GeneralOrganisationsList;
3423 OrganisationsListType = &GeneralOrganisationsListType;
3424 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3425 OrganisationsListPID = &GeneralOrganisationsListPID;
3426 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3427 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3428 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3429 OrganisationsListPref = &GeneralOrganisationsListPref;
3432 OrganisationsList = &HomeOrganisationsList;
3433 OrganisationsListType = &HomeOrganisationsListType;
3434 OrganisationsListAltID = &HomeOrganisationsListAltID;
3435 OrganisationsListPID = &HomeOrganisationsListPID;
3436 OrganisationsListTokens = &HomeOrganisationsListTokens;
3437 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3438 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3439 OrganisationsListPref = &HomeOrganisationsListPref;
3442 OrganisationsList = &BusinessOrganisationsList;
3443 OrganisationsListType = &BusinessOrganisationsListType;
3444 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3445 OrganisationsListPID = &BusinessOrganisationsListPID;
3446 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3447 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3448 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3449 OrganisationsListPref = &BusinessOrganisationsListPref;
3455 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3456 intiter != SplitPoints.end(); ++intiter){
3458 SLiter = SplitLength.find(intiter->first);
3460 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3462 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3463 PropertyName = PropertyElement.GetNextToken();
3464 PropertyValue = PropertyElement.GetNextToken();
3466 intPrevValue = intiter->second;
3468 // Process properties.
3470 size_t intPropertyValueLen = PropertyValue.Len();
3472 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3474 PropertyValue.Trim();
3475 PropertyValue.RemoveLast();
3479 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3481 PropertyValue.Remove(0, 1);
3485 CaptureString(&PropertyValue, FALSE);
3487 if (PropertyName == wxT("ALTID")){
3489 OrganisationsListAltID->erase(*OrganisationCount);
3490 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3492 } else if (PropertyName == wxT("PID")){
3494 OrganisationsListPID->erase(*OrganisationCount);
3495 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3497 } else if (PropertyName == wxT("SORT-AS")){
3499 OrganisationsListSortAs->erase(*OrganisationCount);
3500 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3502 } else if (PropertyName == wxT("PREF")){
3504 int PriorityNumber = 0;
3505 bool ValidNumber = TRUE;
3508 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3511 catch(std::invalid_argument &e){
3512 ValidNumber = FALSE;
3515 if (ValidNumber == TRUE){
3517 OrganisationsListPref->erase(*OrganisationCount);
3518 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3522 } else if (PropertyName == wxT("LANGUAGE")){
3524 OrganisationsListLanguage->erase(*OrganisationCount);
3525 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3529 // Something else we don't know about so append
3530 // to the tokens variable.
3532 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3534 if (FirstToken == TRUE){
3536 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3541 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3551 // Add the data to the General/Home/Work address variables.
3553 CaptureString(&PropertySeg2, FALSE);
3555 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3557 if (!PropertyTokens.IsEmpty()){
3559 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3565 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3567 std::map<int, int> SplitPoints;
3568 std::map<int, int> SplitLength;
3569 std::map<int, int>::iterator SLiter;
3570 wxString PropertyData;
3571 wxString PropertyName;
3572 wxString PropertyValue;
3573 wxString PropertyTokens;
3574 bool FirstToken = TRUE;
3575 int intPrevValue = 6;
3580 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3584 PropertyType PropType = PROPERTY_NONE;
3586 // Look for type before continuing.
3588 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3590 // Setup the pointers.
3592 std::map<int, wxString> *NoteList = NULL;
3593 std::map<int, wxString> *NoteListAltID = NULL;
3594 std::map<int, wxString> *NoteListPID = NULL;
3595 std::map<int, wxString> *NoteListType = NULL;
3596 std::map<int, wxString> *NoteListTokens = NULL;
3597 std::map<int, wxString> *NoteListLanguage = NULL;
3598 std::map<int, int> *NoteListPref = NULL;
3600 // Setup blank lines for later on.
3604 NoteList = &GeneralNoteList;
3605 NoteListType = &GeneralNoteListType;
3606 NoteListAltID = &GeneralNoteListAltID;
3607 NoteListPID = &GeneralNoteListPID;
3608 NoteListTokens = &GeneralNoteListTokens;
3609 NoteListLanguage = &GeneralNoteListLanguage;
3610 NoteListPref = &GeneralNoteListPref;
3613 NoteList = &HomeNoteList;
3614 NoteListType = &HomeNoteListType;
3615 NoteListAltID = &HomeNoteListAltID;
3616 NoteListPID = &HomeNoteListPID;
3617 NoteListTokens = &HomeNoteListTokens;
3618 NoteListLanguage = &HomeNoteListLanguage;
3619 NoteListPref = &HomeNoteListPref;
3622 NoteList = &BusinessNoteList;
3623 NoteListType = &BusinessNoteListType;
3624 NoteListAltID = &BusinessNoteListAltID;
3625 NoteListPID = &BusinessNoteListPID;
3626 NoteListTokens = &BusinessNoteListTokens;
3627 NoteListLanguage = &BusinessNoteListLanguage;
3628 NoteListPref = &BusinessNoteListPref;
3634 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3635 intiter != SplitPoints.end(); ++intiter){
3637 SLiter = SplitLength.find(intiter->first);
3639 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3641 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3642 PropertyName = PropertyElement.GetNextToken();
3643 PropertyValue = PropertyElement.GetNextToken();
3645 intPrevValue = intiter->second;
3647 // Process properties.
3649 size_t intPropertyValueLen = PropertyValue.Len();
3651 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3653 PropertyValue.Trim();
3654 PropertyValue.RemoveLast();
3658 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3660 PropertyValue.Remove(0, 1);
3664 CaptureString(&PropertyValue, FALSE);
3666 if (PropertyName == wxT("ALTID")){
3668 NoteListAltID->erase(*NoteCount);
3669 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3671 } else if (PropertyName == wxT("PID")){
3673 NoteListPID->erase(*NoteCount);
3674 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3676 } else if (PropertyName == wxT("PREF")){
3678 int PriorityNumber = 0;
3679 bool ValidNumber = TRUE;
3682 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3685 catch(std::invalid_argument &e){
3686 ValidNumber = FALSE;
3689 if (ValidNumber == TRUE){
3691 NoteListPref->erase(*NoteCount);
3692 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3696 } else if (PropertyName == wxT("LANGUAGE")){
3698 NoteListLanguage->erase(*NoteCount);
3699 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3703 // Something else we don't know about so append
3704 // to the tokens variable.
3706 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3708 if (FirstToken == TRUE){
3710 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3715 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3725 // Add the data to the General/Home/Work address variables.
3727 CaptureString(&PropertySeg2, FALSE);
3729 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3731 if (!PropertyTokens.IsEmpty()){
3733 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3739 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3741 std::map<int, int> SplitPoints;
3742 std::map<int, int> SplitLength;
3743 std::map<int, int>::iterator SLiter;
3744 wxString PropertyData;
3745 wxString PropertyName;
3746 wxString PropertyValue;
3747 wxString PropertyTokens;
3748 bool FirstToken = TRUE;
3749 int intPrevValue = 12;
3754 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3758 PropertyType PropType = PROPERTY_NONE;
3760 // Look for type before continuing.
3762 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3764 // Setup blank lines for later on.
3770 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3773 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3779 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3780 intiter != SplitPoints.end(); ++intiter){
3782 SLiter = SplitLength.find(intiter->first);
3784 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3786 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3787 PropertyName = PropertyElement.GetNextToken();
3788 PropertyValue = PropertyElement.GetNextToken();
3790 intPrevValue = intiter->second;
3792 // Process properties.
3794 size_t intPropertyValueLen = PropertyValue.Len();
3796 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3798 PropertyValue.Trim();
3799 PropertyValue.RemoveLast();
3803 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3805 PropertyValue.Remove(0, 1);
3809 CaptureString(&PropertyValue, FALSE);
3811 if (PropertyName == wxT("ALTID")){
3813 CategoriesListAltID.erase(*CategoryCount);
3814 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3816 } else if (PropertyName == wxT("PID")){
3818 CategoriesListPID.erase(*CategoryCount);
3819 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3821 } else if (PropertyName == wxT("PREF")){
3823 int PriorityNumber = 0;
3824 bool ValidNumber = TRUE;
3827 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3830 catch(std::invalid_argument &e){
3831 ValidNumber = FALSE;
3834 if (ValidNumber == TRUE){
3836 CategoriesListPref.erase(*CategoryCount);
3837 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3841 } else if (PropertyName == wxT("LANGUAGE")){
3843 CategoriesListLanguage.erase(*CategoryCount);
3844 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3848 // Something else we don't know about so append
3849 // to the tokens variable.
3851 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3853 if (FirstToken == TRUE){
3855 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3860 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3870 // Deal with multiple categories.
3872 int intOrigCatCount = *CategoryCount;
3873 bool FirstCategoryProcessed = TRUE;
3874 bool AfterFirstToken = FALSE;
3875 int intSplitSize = 0;
3876 int intSplitsFound = 0;
3877 int intSplitSeek = 0;
3878 int intPropertyLen = PropertySeg2.Len();
3880 SplitPoints.clear();
3881 SplitLength.clear();
3884 for (int i = 0; i <= intPropertyLen; i++){
3886 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3894 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3896 if (AfterFirstToken == TRUE){
3898 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3899 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3903 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3904 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3905 AfterFirstToken = TRUE;
3917 if (SplitPoints.size() > 0){
3919 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3920 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3924 if (SplitPoints.size() == 0){
3926 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3928 if (!PropertyTokens.IsEmpty()){
3930 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3936 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3937 intiter != SplitPoints.end(); ++intiter){
3939 SLiter = SplitLength.find(intiter->first);
3941 intPrevValue = intiter->second;
3943 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3945 // Add the data to the General/Home/Work address variables.
3947 // Trim any whitespace from the start and end.
3949 PropertyData = PropertyData.Trim(FALSE);
3950 PropertyData = PropertyData.Trim(TRUE);
3952 CaptureString(&PropertyData, FALSE);
3954 if (FirstCategoryProcessed == TRUE){
3956 FirstCategoryProcessed = FALSE;
3958 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3960 if (!PropertyTokens.IsEmpty()){
3962 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3972 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3974 if (!PropertyTokens.IsEmpty()){
3976 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3982 // Copy the properties to each of the categories (if it exists).
3984 if (!PropertyTokens.IsEmpty()){
3986 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3990 // Check if ALTID was used.
3992 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3994 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3998 // Check if PID was used.
4000 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4002 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4006 // Check if PREF was used.
4008 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4010 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4014 // Check if LANGUAGE was used.
4016 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4018 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4022 // Check if TYPE was used.
4028 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4031 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4039 void SplitValues(wxString *PropertyLine,
4040 std::map<int,int> *SplitPoints,
4041 std::map<int,int> *SplitLength,
4044 size_t intPropertyLen = PropertyLine->Len();
4045 int intSplitsFound = 0;
4046 int intSplitSize = 0;
4047 int intSplitSeek = 0;
4049 for (int i = intSize; i <= intPropertyLen; i++){
4053 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4054 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4056 if (intSplitsFound == 0){
4058 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4062 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4066 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4076 if (intSplitsFound == 0){
4078 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4079 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4083 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4084 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4090 void CheckType(wxString *PropertySeg1,
4091 std::map<int,int> *SplitPoints,
4092 std::map<int,int> *SplitLength,
4094 PropertyType *PropType){
4096 wxString PropertyData;
4097 wxString PropertyName;
4098 wxString PropertyValue;
4099 std::map<int,int>::iterator SLiter;
4101 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
4102 intiter != SplitPoints->end(); ++intiter){
4104 SLiter = SplitLength->find(intiter->first);
4106 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4108 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4109 PropertyName = PropertyElement.GetNextToken();
4110 PropertyValue = PropertyElement.GetNextToken();
4112 *intPrevValue = intiter->second;
4114 if (PropertyName == wxT("TYPE")){
4116 if (PropertyValue == wxT("work")){
4118 *PropType = PROPERTY_WORK;
4120 } else if (PropertyValue == wxT("home")){
4122 *PropType = PROPERTY_HOME;
4126 *PropType = PROPERTY_NONE;