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 wxString PropertyLine;
100 wxString PropertySeg1;
101 wxString PropertySeg2;
102 wxString PropertyNextLine;
105 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
106 iter != ContactFileLines.end(); ++iter){
108 ExtraLineSeek = TRUE;
114 PropertyLine.Clear();
115 PropertySeg1.Clear();
116 PropertySeg2.Clear();
119 ContactLine = iter->second;
121 while (ExtraLineSeek == TRUE){
123 // Check if there is extra data on the next line
124 // (indicated by space or tab at the start) and add data.
128 if (iter == ContactFileLines.end()){
135 PropertyNextLine = iter->second;
137 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
139 PropertyNextLine.Remove(0, 1);
140 ContactLine.Append(PropertyNextLine);
145 ExtraLineSeek = FALSE;
151 ContactLineLen = ContactLine.Len();
153 // Make sure we are not in quotation mode.
154 // Make sure colon does not have \ or \\ before it.
156 for (int i = 0; i <= ContactLineLen; i++){
158 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
160 PropertyFind = FALSE;
162 } else if (PropertyFind == TRUE){
164 Property.Append(ContactLine.Mid(i, 1));
168 if (ContactLine.Mid(i, 1) == wxT("\"")){
170 if (QuoteMode == TRUE){
182 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
191 // Split that line at the point into two variables (ignore the colon).
193 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
194 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
196 if (Property == wxT("KIND") && KindProcessed == FALSE){
198 ProcessKind(PropertySeg2);
200 } else if (Property == wxT("MEMBER")){
202 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
205 } else if (Property == wxT("FN")){
207 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
210 } else if (Property == wxT("N") && NameProcessed == FALSE){
212 ProcessN(PropertySeg1, PropertySeg2);
213 NameProcessed = TRUE;
215 } else if (Property == wxT("NICKNAME")){
217 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
220 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
222 ProcessGender(PropertySeg1, PropertySeg2);
223 GenderProcessed = TRUE;
225 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
227 ProcessBirthday(PropertySeg1, PropertySeg2);
228 BirthdayProcessed = TRUE;
230 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
232 ProcessAnniversary(PropertySeg1, PropertySeg2);
233 AnniversaryProcessed = TRUE;
235 } else if (Property == wxT("TZ")){
237 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
240 } else if (Property == wxT("ADR")){
242 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
245 } else if (Property == wxT("EMAIL")){
247 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
250 } else if (Property == wxT("IMPP")){
252 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
255 } else if (Property == wxT("TEL")){
257 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
260 } else if (Property == wxT("LANG")){
262 // See frmContactEditor-LoadLanguage.cpp
264 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
267 } else if (Property == wxT("GEO")){
269 // See frmContactEditor-LoadGeo.cpp
271 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
274 } else if (Property == wxT("RELATED")){
276 // See fromContactEditor-LoadRelated.cpp
278 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
281 } else if (Property == wxT("URL")){
283 // See frmContactEditor-LoadURL.cpp
285 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
288 } else if (Property == wxT("TITLE")) {
290 // See frmContactEditor-LoadTitle.cpp
292 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
295 } else if (Property == wxT("ROLE")) {
297 // See frmContactEditor-LoadTitle.cpp
299 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
302 } else if (Property == wxT("ORG")) {
304 // See frmContactEditor-LoadOrg.cpp
306 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
313 return CONTACTLOAD_OK;
317 void ContactDataObject::ProcessKind(wxString KindType){
319 if (KindType == wxT("individual")){
321 ContactKind = CONTACTKIND_INDIVIDUAL;
323 } else if (KindType == wxT("group")){
325 ContactKind = CONTACTKIND_GROUP;
327 } else if (KindType == wxT("org")){
329 ContactKind = CONTACTKIND_ORGANISATION;
331 } else if (KindType == wxT("location")){
333 ContactKind = CONTACTKIND_LOCATION;
337 ContactKind = CONTACTKIND_NONE;
342 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
344 std::map<int, int> SplitPoints;
345 std::map<int, int> SplitLength;
347 int intPrevValue = 8;
351 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
355 wxString PropertyName;
356 wxString PropertyValue;
357 wxString PropertyData;
358 wxString PropertyTokens;
359 std::map<int,int>::iterator SLiter;
360 bool FirstToken = TRUE;
362 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
363 intiter != SplitPoints.end(); ++intiter){
365 SLiter = SplitLength.find(intiter->first);
367 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
369 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
370 PropertyName = PropertyElement.GetNextToken();
371 PropertyValue = PropertyElement.GetNextToken();
373 intPrevValue = intiter->second;
375 CaptureString(&PropertyValue, FALSE);
377 if (PropertyName == wxT("ALTID")){
379 GroupsListAltID.erase(*GroupCount);
380 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
382 } else if (PropertyName == wxT("PID")){
384 GroupsListPID.erase(*GroupCount);
385 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
387 } else if (PropertyName == wxT("PREF")){
389 int PriorityNumber = 0;
390 bool ValidNumber = TRUE;
393 PriorityNumber = std::stoi(PropertyValue.ToStdString());
396 catch(std::invalid_argument &e){
400 if (ValidNumber == TRUE){
402 GroupsListPref.erase(*GroupCount);
403 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
407 } else if (PropertyName == wxT("MEDIATYPE")){
409 GroupsListMediaType.erase(*GroupCount);
410 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
412 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
414 if (FirstToken == TRUE){
416 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
421 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
429 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
431 if (!PropertyTokens.IsEmpty()){
433 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
440 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
442 std::map<int, int> SplitPoints;
443 std::map<int, int> SplitLength;
445 int intPrevValue = 4;
449 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
453 wxString PropertyName;
454 wxString PropertyValue;
455 wxString PropertyData;
456 wxString PropertyTokens;
457 std::map<int,int>::iterator SLiter;
458 bool FirstToken = TRUE;
460 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
461 intiter != SplitPoints.end(); ++intiter){
463 SLiter = SplitLength.find(intiter->first);
465 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
467 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
468 PropertyName = PropertyElement.GetNextToken();
469 PropertyValue = PropertyElement.GetNextToken();
471 intPrevValue = intiter->second;
473 CaptureString(&PropertyValue, FALSE);
475 if (PropertyName == wxT("TYPE")){
477 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
478 PropertyValue == wxT("work") ){
480 FullNamesListType.erase(*FNCount);
481 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
485 } else if (PropertyName == wxT("LANGUAGE")){
487 FullNamesListLanguage.erase(*FNCount);
488 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
490 } else if (PropertyName == wxT("ALTID")){
492 FullNamesListAltID.erase(*FNCount);
493 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
495 } else if (PropertyName == wxT("PID")){
497 FullNamesListPID.erase(*FNCount);
498 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
500 } else if (PropertyName == wxT("PREF")){
502 int PriorityNumber = 0;
503 bool ValidNumber = TRUE;
506 PriorityNumber = std::stoi(PropertyValue.ToStdString());
509 catch(std::invalid_argument &e){
513 if (ValidNumber == TRUE){
515 FullNamesListPref.erase(*FNCount);
516 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
520 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
522 if (FirstToken == TRUE){
524 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
529 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
537 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
539 if (!PropertyTokens.IsEmpty()){
541 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
547 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
549 std::map<int, int> SplitPoints;
550 std::map<int, int> SplitLength;
552 int intPrevValue = 3;
556 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
560 wxString PropertyName;
561 wxString PropertyValue;
562 wxString PropertyData;
563 wxString PropertyTokens;
564 std::map<int,int>::iterator SLiter;
565 bool FirstToken = TRUE;
567 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
568 intiter != SplitPoints.end(); ++intiter){
570 SLiter = SplitLength.find(intiter->first);
572 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
574 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
575 PropertyName = PropertyElement.GetNextToken();
576 PropertyValue = PropertyElement.GetNextToken();
578 intPrevValue = intiter->second;
580 CaptureString(&PropertyValue, FALSE);
582 if (PropertyName == wxT("ALTID")){
584 NameAltID = PropertyValue;
586 } else if (PropertyName == wxT("LANGUAGE")){
588 NameLanguage = PropertyValue;
590 } else if (PropertyName == wxT("SORT-AS")){
592 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
593 PropertyValue.Len() >= 3){
594 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
597 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
599 if (FirstToken == TRUE){
601 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
606 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
614 // Split the name data.
616 int intSplitSeek = 0;
617 int intSplitsFound = 0;
618 int intSplitSize = 0;
619 int intPropertyLen = PropertySeg2.Len();
621 std::map<int,wxString> NameValues;
624 for (int i = 0; i <= intPropertyLen; i++){
626 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
628 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
633 if (intSplitsFound == 4){
635 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
649 // Split the data into several parts.
651 for (std::map<int, wxString>::iterator iter = NameValues.begin();
652 iter != NameValues.end(); ++iter){
654 if (iter->first == 1){
656 // Deal with family name.
658 NameSurname = iter->second;
660 } else if (iter->first == 2){
662 // Deal with given names.
664 NameForename = iter->second;
666 } else if (iter->first == 3){
668 // Deal with additional names.
670 NameOtherNames = iter->second;
672 } else if (iter->first == 4){
674 // Deal with honorifix prefixes and suffixes.
676 NameTitle = iter->second;
680 if (iter == NameValues.end()){
686 NameSuffix = iter->second;
692 // Add the name token data.
694 if (!PropertyTokens.IsEmpty()){
696 NameTokens = PropertyTokens;
702 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
704 std::map<int, int> SplitPoints;
705 std::map<int, int> SplitLength;
707 int intPrevValue = 10;
710 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
714 PropertyType PropType = PROPERTY_NONE;
716 // Look for type before continuing.
718 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
722 std::map<int, wxString> *NicknamesList = NULL;
723 std::map<int, wxString> *NicknamesListType = NULL;
724 std::map<int, wxString> *NicknamesListLanguage = NULL;
725 std::map<int, wxString> *NicknamesListAltID = NULL;
726 std::map<int, wxString> *NicknamesListPID = NULL;
727 std::map<int, wxString> *NicknamesListTokens = NULL;
728 std::map<int, int> *NicknamesListPref = NULL;
732 NicknamesList = &GeneralNicknamesList;
733 NicknamesListType = &GeneralNicknamesListType;
734 NicknamesListLanguage = &GeneralNicknamesListLanguage;
735 NicknamesListAltID = &GeneralNicknamesListAltID;
736 NicknamesListPID = &GeneralNicknamesListPID;
737 NicknamesListTokens = &GeneralNicknamesListTokens;
738 NicknamesListPref = &GeneralNicknamesListPref;
741 NicknamesList = &HomeNicknamesList;
742 NicknamesListType = &HomeNicknamesListType;
743 NicknamesListLanguage = &HomeNicknamesListLanguage;
744 NicknamesListAltID = &HomeNicknamesListAltID;
745 NicknamesListPID = &HomeNicknamesListPID;
746 NicknamesListTokens = &HomeNicknamesListTokens;
747 NicknamesListPref = &HomeNicknamesListPref;
750 NicknamesList = &BusinessNicknamesList;
751 NicknamesListType = &BusinessNicknamesListType;
752 NicknamesListLanguage = &BusinessNicknamesListLanguage;
753 NicknamesListAltID = &BusinessNicknamesListAltID;
754 NicknamesListPID = &BusinessNicknamesListPID;
755 NicknamesListTokens = &BusinessNicknamesListTokens;
756 NicknamesListPref = &BusinessNicknamesListPref;
760 std::map<int, int>::iterator SLiter;
761 wxString PropertyData;
762 wxString PropertyName;
763 wxString PropertyValue;
764 wxString PropertyTokens;
765 bool FirstToken = TRUE;
767 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
768 intiter != SplitPoints.end(); ++intiter){
770 SLiter = SplitLength.find(intiter->first);
772 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
774 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
775 PropertyName = PropertyElement.GetNextToken();
776 PropertyValue = PropertyElement.GetNextToken();
778 intPrevValue = intiter->second;
780 CaptureString(&PropertyValue, FALSE);
782 if (PropertyName == wxT("ALTID")){
784 NicknamesListAltID->erase(*NicknameCount);
785 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
787 } else if (PropertyName == wxT("PID")){
789 NicknamesListPID->erase(*NicknameCount);
790 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
792 } else if (PropertyName == wxT("PREF")){
794 int PriorityNumber = 0;
795 bool ValidNumber = TRUE;
798 PriorityNumber = std::stoi(PropertyValue.ToStdString());
801 catch(std::invalid_argument &e){
805 if (ValidNumber == TRUE){
807 NicknamesListPref->erase(*NicknameCount);
808 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
812 } else if (PropertyName == wxT("LANGUAGE")){
814 NicknamesListLanguage->erase(*NicknameCount);
815 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
819 // Something else we don't know about so append
820 // to the tokens variable.
822 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
824 if (FirstToken == TRUE){
826 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
831 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
841 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
843 // Add the name token data.
845 if (!PropertyTokens.IsEmpty()){
847 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
853 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
855 std::map<int, int> SplitPoints;
856 std::map<int, int> SplitLength;
857 std::map<int, int>::iterator SLiter;
858 wxString PropertyData;
859 wxString PropertyName;
860 wxString PropertyValue;
861 wxString PropertyTokens;
862 bool FirstToken = TRUE;
863 int intPrevValue = 8;
865 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
869 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
870 intiter != SplitPoints.end(); ++intiter){
872 SLiter = SplitLength.find(intiter->first);
874 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
876 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
877 PropertyName = PropertyElement.GetNextToken();
878 PropertyValue = PropertyElement.GetNextToken();
880 intPrevValue = intiter->second;
882 // Process properties.
884 size_t intPropertyValueLen = PropertyValue.Len();
886 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
888 PropertyValue.Trim();
889 PropertyValue.RemoveLast();
893 if (PropertyValue.Mid(0, 1) == wxT("\"")){
895 PropertyValue.Remove(0, 1);
899 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
901 if (FirstToken == TRUE){
903 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
908 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
916 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
918 wxString GenderComponent;
920 if (GenderData.CountTokens() >= 2){
922 Gender = GenderData.GetNextToken();
923 GenderDetails = GenderData.GetString();
925 CaptureString(&GenderDetails, FALSE);
929 Gender = GenderData.GetNextToken();
933 if (!PropertyTokens.IsEmpty()){
935 GenderTokens = PropertyTokens;
941 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
943 // Process date. Preserve the remainder in the string.
945 std::map<int, int> SplitPoints;
946 std::map<int, int> SplitLength;
947 std::map<int, int>::iterator SLiter;
948 wxString PropertyData;
949 wxString PropertyName;
950 wxString PropertyValue;
951 wxString PropertyTokens;
952 bool BirthdayText = FALSE;
953 int intPrevValue = 6;
955 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
959 // Look for type before continuing.
961 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
962 intiter != SplitPoints.end(); ++intiter){
964 SLiter = SplitLength.find(intiter->first);
966 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
968 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
969 PropertyName = PropertyElement.GetNextToken();
970 PropertyValue = PropertyElement.GetNextToken();
972 intPrevValue = intiter->second;
974 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
976 CaptureString(&PropertySeg2, FALSE);
977 Birthday = PropertySeg2;
984 // Setup blank lines for later on.
987 bool FirstToken = TRUE;
989 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
990 intiter != SplitPoints.end(); ++intiter){
992 SLiter = SplitLength.find(intiter->first);
994 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
996 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
997 PropertyName = PropertyElement.GetNextToken();
998 PropertyValue = PropertyElement.GetNextToken();
1000 intPrevValue = intiter->second;
1002 // Process properties.
1004 CaptureString(&PropertyValue, FALSE);
1006 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1008 PropertyValue.Trim();
1009 PropertyValue.RemoveLast();
1013 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1015 PropertyValue.Remove(0, 1);
1019 if (PropertyName == wxT("ALTID")){
1021 BirthdayAltID = PropertyValue;
1023 } else if (PropertyName == wxT("CALSCALE")){
1025 BirthdayCalScale = PropertyValue;
1027 } else if (PropertyName != wxT("VALUE")) {
1029 // Something else we don't know about so append
1030 // to the tokens variable.
1032 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1034 if (FirstToken == TRUE){
1036 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1041 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1051 // Add the data to the variables and form.
1053 if (BirthdayText == FALSE){
1055 Birthday = PropertySeg2;
1059 if (!PropertyTokens.IsEmpty()){
1061 BirthdayTokens = PropertyTokens;
1067 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1069 // Process date. Preserve the remainder in the string.
1071 std::map<int, int> SplitPoints;
1072 std::map<int, int> SplitLength;
1073 std::map<int, int>::iterator SLiter;
1074 wxString PropertyData;
1075 wxString PropertyName;
1076 wxString PropertyValue;
1077 wxString PropertyTokens;
1078 bool AnniversaryText = FALSE;
1079 int intPrevValue = 13;
1081 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1085 // Look for type before continuing.
1087 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1088 intiter != SplitPoints.end(); ++intiter){
1090 SLiter = SplitLength.find(intiter->first);
1092 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1094 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1095 PropertyName = PropertyElement.GetNextToken();
1096 PropertyValue = PropertyElement.GetNextToken();
1098 intPrevValue = intiter->second;
1100 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1102 CaptureString(&PropertySeg2, FALSE);
1103 Anniversary = PropertySeg2;
1104 AnniversaryText = TRUE;
1110 // Setup blank lines for later on.
1113 bool FirstToken = TRUE;
1115 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1116 intiter != SplitPoints.end(); ++intiter){
1118 SLiter = SplitLength.find(intiter->first);
1120 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1122 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1123 PropertyName = PropertyElement.GetNextToken();
1124 PropertyValue = PropertyElement.GetNextToken();
1126 intPrevValue = intiter->second;
1128 // Process properties.
1130 CaptureString(&PropertyValue, FALSE);
1132 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1134 PropertyValue.Trim();
1135 PropertyValue.RemoveLast();
1139 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1141 PropertyValue.Remove(0, 1);
1145 if (PropertyName == wxT("ALTID")){
1147 AnniversaryAltID = PropertyValue;
1149 } else if (PropertyName == wxT("CALSCALE")){
1151 AnniversaryCalScale = PropertyValue;
1153 } else if (PropertyName != wxT("VALUE")) {
1155 // Something else we don't know about so append
1156 // to the tokens variable.
1158 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1160 if (FirstToken == TRUE){
1162 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1167 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1177 // Add the data to the variables and form.
1179 if (AnniversaryText == FALSE){
1181 Anniversary = PropertySeg2;
1185 if (!PropertyTokens.IsEmpty()){
1187 AnniversaryTokens = PropertyTokens;
1193 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1195 std::map<int, int> SplitPoints;
1196 std::map<int, int> SplitLength;
1198 int intPrevValue = 4;
1201 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1205 PropertyType PropType = PROPERTY_NONE;
1207 // Look for type before continuing.
1209 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1213 std::map<int, wxString> *TZList = NULL;
1214 std::map<int, wxString> *TZListType = NULL;
1215 std::map<int, wxString> *TZListMediatype = NULL;
1216 std::map<int, wxString> *TZListAltID = NULL;
1217 std::map<int, wxString> *TZListPID = NULL;
1218 std::map<int, wxString> *TZListTokens = NULL;
1219 std::map<int, int> *TZListPref = NULL;
1223 TZList = &GeneralTZList;
1224 TZListType = &GeneralTZListType;
1225 TZListMediatype = &GeneralTZListMediatype;
1226 TZListAltID = &GeneralTZListAltID;
1227 TZListPID = &GeneralTZListPID;
1228 TZListTokens = &GeneralTZListTokens;
1229 TZListPref = &GeneralTZListPref;
1232 TZList = &HomeTZList;
1233 TZListType = &HomeTZListType;
1234 TZListMediatype = &HomeTZListMediatype;
1235 TZListAltID = &HomeTZListAltID;
1236 TZListPID = &HomeTZListPID;
1237 TZListTokens = &HomeTZListTokens;
1238 TZListPref = &HomeTZListPref;
1241 TZList = &BusinessTZList;
1242 TZListType = &BusinessTZListType;
1243 TZListMediatype = &BusinessTZListMediatype;
1244 TZListAltID = &BusinessTZListAltID;
1245 TZListPID = &BusinessTZListPID;
1246 TZListTokens = &BusinessTZListTokens;
1247 TZListPref = &BusinessTZListPref;
1251 std::map<int, int>::iterator SLiter;
1252 wxString PropertyData;
1253 wxString PropertyName;
1254 wxString PropertyValue;
1255 wxString PropertyTokens;
1256 bool FirstToken = TRUE;
1258 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1259 intiter != SplitPoints.end(); ++intiter){
1261 SLiter = SplitLength.find(intiter->first);
1263 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1265 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1266 PropertyName = PropertyElement.GetNextToken();
1267 PropertyValue = PropertyElement.GetNextToken();
1269 intPrevValue = intiter->second;
1271 CaptureString(&PropertyValue, FALSE);
1273 if (PropertyName == wxT("ALTID")){
1275 TZListAltID->erase(*TimeZoneCount);
1276 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1278 } else if (PropertyName == wxT("PID")){
1280 TZListPID->erase(*TimeZoneCount);
1281 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1283 } else if (PropertyName == wxT("PREF")){
1285 int PriorityNumber = 0;
1286 bool ValidNumber = TRUE;
1289 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1292 catch(std::invalid_argument &e){
1293 ValidNumber = FALSE;
1296 if (ValidNumber == TRUE){
1298 TZListPref->erase(*TimeZoneCount);
1299 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1303 } else if (PropertyName == wxT("MEDIATYPE")){
1305 TZListMediatype->erase(*TimeZoneCount);
1306 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1310 // Something else we don't know about so append
1311 // to the tokens variable.
1313 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1315 if (FirstToken == TRUE){
1317 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1322 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1332 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1334 // Add the name token data.
1336 if (!PropertyTokens.IsEmpty()){
1338 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1345 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1347 size_t intPropertyLen = PropertySeg1.Len();
1348 std::map<int, int> SplitPoints;
1349 std::map<int, int> SplitLength;
1350 std::map<int, int>::iterator SLiter;
1351 wxString PropertyData;
1352 wxString PropertyName;
1353 wxString PropertyValue;
1354 wxString PropertyTokens;
1355 wxString AddressLabel;
1356 wxString AddressLang;
1357 wxString AddressAltID;
1358 wxString AddressPID;
1359 wxString AddressTokens;
1360 wxString AddressGeo;
1361 wxString AddressTimezone;
1362 wxString AddressType;
1363 wxString AddressMediatype;
1364 wxString AddressPOBox;
1365 wxString AddressExtended;
1366 wxString AddressStreet;
1367 wxString AddressLocality;
1368 wxString AddressCity;
1369 wxString AddressRegion;
1370 wxString AddressPostalCode;
1371 wxString AddressCountry;
1372 bool FirstToken = TRUE;
1373 int intSplitsFound = 0;
1374 int intSplitSize = 0;
1375 int intPrevValue = 5;
1380 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1384 PropertyType PropType = PROPERTY_NONE;
1386 // Look for type before continuing.
1388 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1392 std::map<int, wxString> *AddressList = NULL;
1393 std::map<int, wxString> *AddressListTown = NULL;
1394 std::map<int, wxString> *AddressListCounty = NULL;
1395 std::map<int, wxString> *AddressListPostCode = NULL;
1396 std::map<int, wxString> *AddressListCountry = NULL;
1397 std::map<int, wxString> *AddressListLabel = NULL;
1398 std::map<int, wxString> *AddressListLang = NULL;
1399 std::map<int, wxString> *AddressListAltID = NULL;
1400 std::map<int, wxString> *AddressListPID = NULL;
1401 std::map<int, wxString> *AddressListTokens = NULL;
1402 std::map<int, wxString> *AddressListGeo = NULL;
1403 std::map<int, wxString> *AddressListTimezone = NULL;
1404 std::map<int, wxString> *AddressListType = NULL;
1405 std::map<int, wxString> *AddressListMediatype = NULL;
1406 std::map<int, int> *AddressListPref = NULL;
1410 AddressList = &GeneralAddressList;
1411 AddressListTown = &GeneralAddressListTown;
1412 AddressListCounty = &GeneralAddressListCounty;
1413 AddressListPostCode = &GeneralAddressListPostCode;
1414 AddressListCountry = &GeneralAddressListCountry;
1415 AddressListLabel = &GeneralAddressListLabel;
1416 AddressListLang = &GeneralAddressListLang;
1417 AddressListAltID = &GeneralAddressListAltID;
1418 AddressListPID = &GeneralAddressListPID;
1419 AddressListTokens = &GeneralAddressListTokens;
1420 AddressListGeo = &GeneralAddressListGeo;
1421 AddressListTimezone = &GeneralAddressListTimezone;
1422 AddressListType = &GeneralAddressListType;
1423 AddressListMediatype = &GeneralAddressListMediatype;
1424 AddressListPref = &GeneralAddressListPref;
1427 AddressList = &HomeAddressList;
1428 AddressListTown = &HomeAddressListTown;
1429 AddressListCounty = &HomeAddressListCounty;
1430 AddressListPostCode = &HomeAddressListPostCode;
1431 AddressListCountry = &HomeAddressListCountry;
1432 AddressListLabel = &HomeAddressListLabel;
1433 AddressListLang = &HomeAddressListLang;
1434 AddressListAltID = &HomeAddressListAltID;
1435 AddressListPID = &HomeAddressListPID;
1436 AddressListTokens = &HomeAddressListTokens;
1437 AddressListGeo = &HomeAddressListGeo;
1438 AddressListTimezone = &HomeAddressListTimezone;
1439 AddressListType = &HomeAddressListType;
1440 AddressListMediatype = &HomeAddressListMediatype;
1441 AddressListPref = &HomeAddressListPref;
1444 AddressList = &BusinessAddressList;
1445 AddressListTown = &BusinessAddressListTown;
1446 AddressListCounty = &BusinessAddressListCounty;
1447 AddressListPostCode = &BusinessAddressListPostCode;
1448 AddressListCountry = &BusinessAddressListCountry;
1449 AddressListLabel = &BusinessAddressListLabel;
1450 AddressListLang = &BusinessAddressListLang;
1451 AddressListAltID = &BusinessAddressListAltID;
1452 AddressListPID = &BusinessAddressListPID;
1453 AddressListTokens = &BusinessAddressListTokens;
1454 AddressListGeo = &BusinessAddressListGeo;
1455 AddressListTimezone = &BusinessAddressListTimezone;
1456 AddressListType = &BusinessAddressListType;
1457 AddressListMediatype = &BusinessAddressListMediatype;
1458 AddressListPref = &BusinessAddressListPref;
1464 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1465 intiter != SplitPoints.end(); ++intiter){
1467 SLiter = SplitLength.find(intiter->first);
1469 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1471 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1472 PropertyName = PropertyElement.GetNextToken();
1473 PropertyValue = PropertyElement.GetNextToken();
1475 intPrevValue = intiter->second;
1477 CaptureString(&PropertyValue, FALSE);
1479 // Process properties.
1481 if (PropertyName == wxT("LABEL")){
1483 AddressListLabel->erase(*AddressCount);
1484 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1486 } else if (PropertyName == wxT("LANGUAGE")){
1488 AddressListLang->erase(*AddressCount);
1489 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1491 } else if (PropertyName == wxT("ALTID")){
1493 AddressListAltID->erase(*AddressCount);
1494 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1496 } else if (PropertyName == wxT("PID")){
1498 AddressListPID->erase(*AddressCount);
1499 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1501 } else if (PropertyName == wxT("GEO")){
1503 AddressListGeo->erase(*AddressCount);
1504 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1506 } else if (PropertyName == wxT("TZ")){
1508 AddressListTimezone->erase(*AddressCount);
1509 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1511 } else if (PropertyName == wxT("MEDIATYPE")){
1513 AddressListMediatype->erase(*AddressCount);
1514 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1516 } else if (PropertyName == wxT("PREF")){
1518 int PriorityNumber = 0;
1519 bool ValidNumber = TRUE;
1522 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1525 catch(std::invalid_argument &e){
1526 ValidNumber = FALSE;
1529 if (ValidNumber == TRUE){
1531 AddressListPref->erase(*AddressCount);
1532 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1538 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1540 if (FirstToken == TRUE){
1542 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1547 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1557 // Split the address.
1559 //std::map<int, int>::iterator SLiter;
1560 intPropertyLen = PropertySeg2.Len();
1561 SplitPoints.clear();
1562 SplitLength.clear();
1567 for (int i = 0; i <= intPropertyLen; i++){
1571 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1574 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1576 if (intSplitsFound == 6){
1578 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1583 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1593 // Split the data into several parts.
1595 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1596 intiter != SplitPoints.end(); ++intiter){
1598 if (intiter->first == 1){
1600 // Deal with PO Box.
1602 SLiter = SplitLength.find(1);
1604 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1605 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1606 intPrevValue = intiter->second;
1608 } else if (intiter->first == 2){
1610 // Deal with extended address.
1612 SLiter = SplitLength.find(2);
1614 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1615 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1616 intPrevValue = intiter->second;
1618 } else if (intiter->first == 3){
1620 // Deal with street address.
1622 SLiter = SplitLength.find(3);
1624 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1625 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1626 intPrevValue = intiter->second;
1628 } else if (intiter->first == 4){
1630 // Deal with locality
1632 SLiter = SplitLength.find(4);
1634 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1635 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1636 intPrevValue = intiter->second;
1638 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1640 } else if (intiter->first == 5){
1642 // Deal with region.
1644 SLiter = SplitLength.find(5);
1646 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1647 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1648 intPrevValue = intiter->second;
1650 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1652 } else if (intiter->first == 6){
1654 // Deal with post code.
1656 SLiter = SplitLength.find(6);
1658 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1659 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1660 intPrevValue = intiter->second;
1662 // Deal with country.
1664 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1665 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1673 // Add the data to the General/Home/Work address variables.
1675 CaptureString(&AddressStreet, FALSE);
1676 CaptureString(&AddressLocality, FALSE);
1677 CaptureString(&AddressRegion, FALSE);
1678 CaptureString(&AddressPostalCode, FALSE);
1679 CaptureString(&AddressCountry, FALSE);
1681 if (!PropertyTokens.IsEmpty()){
1683 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1687 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1688 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1689 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1690 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1691 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1695 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1698 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1701 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1705 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1709 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1711 std::map<int, int> SplitPoints;
1712 std::map<int, int> SplitLength;
1714 int intPrevValue = 7;
1717 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1721 PropertyType PropType = PROPERTY_NONE;
1723 // Look for type before continuing.
1725 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1727 std::map<int, wxString> *EmailList = NULL;
1728 std::map<int, wxString> *EmailListType = NULL;
1729 std::map<int, wxString> *EmailListAltID = NULL;
1730 std::map<int, wxString> *EmailListPID = NULL;
1731 std::map<int, wxString> *EmailListTokens = NULL;
1732 std::map<int, int> *EmailListPref = NULL;
1736 EmailList = &GeneralEmailList;
1737 EmailListType = &GeneralEmailListType;
1738 EmailListAltID = &GeneralEmailListAltID;
1739 EmailListPID = &GeneralEmailListPID;
1740 EmailListTokens = &GeneralEmailListTokens;
1741 EmailListPref = &GeneralEmailListPref;
1744 EmailList = &HomeEmailList;
1745 EmailListType = &HomeEmailListType;
1746 EmailListAltID = &HomeEmailListAltID;
1747 EmailListPID = &HomeEmailListPID;
1748 EmailListTokens = &HomeEmailListTokens;
1749 EmailListPref = &HomeEmailListPref;
1752 EmailList = &BusinessEmailList;
1753 EmailListType = &BusinessEmailListType;
1754 EmailListAltID = &BusinessEmailListAltID;
1755 EmailListPID = &BusinessEmailListPID;
1756 EmailListTokens = &BusinessEmailListTokens;
1757 EmailListPref = &BusinessEmailListPref;
1763 std::map<int,int>::iterator SLiter;
1764 wxString PropertyData;
1765 wxString PropertyName;
1766 wxString PropertyValue;
1767 wxString PropertyTokens;
1768 bool FirstToken = TRUE;
1770 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1771 intiter != SplitPoints.end(); ++intiter){
1773 SLiter = SplitLength.find(intiter->first);
1775 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1777 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1778 PropertyName = PropertyElement.GetNextToken();
1779 PropertyValue = PropertyElement.GetNextToken();
1781 intPrevValue = intiter->second;
1783 CaptureString(&PropertyValue, FALSE);
1785 // Process properties.
1787 if (PropertyName == wxT("ALTID")){
1789 EmailListAltID->erase(*EmailCount);
1790 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1792 } else if (PropertyName == wxT("PID")){
1794 EmailListPID->erase(*EmailCount);
1795 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1797 } else if (PropertyName == wxT("PREF")){
1799 int PriorityNumber = 0;
1800 bool ValidNumber = TRUE;
1803 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1806 catch(std::invalid_argument &e){
1807 ValidNumber = FALSE;
1810 if (ValidNumber == TRUE){
1812 EmailListPref->erase(*EmailCount);
1813 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1819 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1821 if (FirstToken == TRUE){
1823 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1828 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1838 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1840 // Add the name token data.
1842 if (!PropertyTokens.IsEmpty()){
1844 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1851 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1853 std::map<int, int> SplitPoints;
1854 std::map<int, int> SplitLength;
1856 int intPrevValue = 6;
1859 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1863 PropertyType PropType = PROPERTY_NONE;
1865 // Look for type before continuing.
1867 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1869 std::map<int, wxString> *IMList = NULL;
1870 std::map<int, wxString> *IMListType = NULL;
1871 std::map<int, wxString> *IMListAltID = NULL;
1872 std::map<int, wxString> *IMListPID = NULL;
1873 std::map<int, wxString> *IMListTokens = NULL;
1874 std::map<int, wxString> *IMListMediatype = NULL;
1875 std::map<int, int> *IMListPref = NULL;
1879 IMList = &GeneralIMList;
1880 IMListType = &GeneralIMListType;
1881 IMListAltID = &GeneralIMListAltID;
1882 IMListPID = &GeneralIMListPID;
1883 IMListTokens = &GeneralIMListTokens;
1884 IMListMediatype = &GeneralIMListMediatype;
1885 IMListPref = &GeneralIMListPref;
1888 IMList = &HomeIMList;
1889 IMListType = &HomeIMListType;
1890 IMListAltID = &HomeIMListAltID;
1891 IMListPID = &HomeIMListPID;
1892 IMListTokens = &HomeIMListTokens;
1893 IMListMediatype = &HomeIMListMediatype;
1894 IMListPref = &HomeIMListPref;
1897 IMList = &BusinessIMList;
1898 IMListType = &BusinessIMListType;
1899 IMListAltID = &BusinessIMListAltID;
1900 IMListPID = &BusinessIMListPID;
1901 IMListTokens = &BusinessIMListTokens;
1902 IMListMediatype = &BusinessIMListMediatype;
1903 IMListPref = &BusinessIMListPref;
1909 std::map<int,int>::iterator SLiter;
1910 wxString PropertyData;
1911 wxString PropertyName;
1912 wxString PropertyValue;
1913 wxString PropertyTokens;
1914 bool FirstToken = TRUE;
1916 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1917 intiter != SplitPoints.end(); ++intiter){
1919 SLiter = SplitLength.find(intiter->first);
1921 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1923 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1924 PropertyName = PropertyElement.GetNextToken();
1925 PropertyValue = PropertyElement.GetNextToken();
1927 intPrevValue = intiter->second;
1929 CaptureString(&PropertyValue, FALSE);
1931 // Process properties.
1933 if (PropertyName == wxT("ALTID")){
1935 IMListAltID->erase(*IMCount);
1936 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1938 } else if (PropertyName == wxT("PID")){
1940 IMListPID->erase(*IMCount);
1941 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1943 } else if (PropertyName == wxT("MEDIATYPE")){
1945 IMListMediatype->erase(*IMCount);
1946 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1948 } else if (PropertyName == wxT("PREF")){
1950 int PriorityNumber = 0;
1951 bool ValidNumber = TRUE;
1954 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1957 catch(std::invalid_argument &e){
1958 ValidNumber = FALSE;
1961 if (ValidNumber == TRUE){
1963 IMListPref->erase(*IMCount);
1964 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1970 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1972 if (FirstToken == TRUE){
1974 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1979 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1989 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1991 // Add the name token data.
1993 if (!PropertyTokens.IsEmpty()){
1995 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2001 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2003 std::map<int, int> SplitPoints;
2004 std::map<int, int> SplitLength;
2005 std::map<int, int>::iterator SLiter;
2009 PropertyType PropType = PROPERTY_NONE;
2011 // Look for type before continuing.
2014 wxString TelTypeDetail;
2015 wxString PropertyData;
2016 wxString PropertyName;
2017 wxString PropertyValue;
2018 wxString PropertyTokens;
2020 std::map<int,int> TypeSplitPoints;
2021 std::map<int,int> TypeSplitLength;
2022 std::map<int,int>::iterator TSLiter;
2024 int intSplitSize = 0;
2025 int intSplitsFound = 0;
2026 int intSplitPoint = 0;
2028 int intPrevValue = 5;
2030 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2034 // Look for type before continuing.
2036 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2037 intiter != SplitPoints.end(); ++intiter){
2039 SLiter = SplitLength.find(intiter->first);
2041 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2043 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2044 PropertyName = PropertyElement.GetNextToken();
2045 PropertyValue = PropertyElement.GetNextToken();
2047 intPrevValue = intiter->second;
2049 if (PropertyName == wxT("TYPE")){
2051 // Process each value in type and translate each
2054 // Strip out the quotes if they are there.
2056 size_t intPropertyValueLen = PropertyValue.Len();
2058 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2060 PropertyValue.Trim();
2061 PropertyValue.RemoveLast();
2065 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2067 PropertyValue.Remove(0, 1);
2071 TelTypeDetail = PropertyValue;
2077 for (int i = 0; i <= intPropertyValueLen; i++){
2081 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2083 if (intSplitsFound == 0){
2085 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2086 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2090 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2091 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2104 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2105 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2107 int intTypeSeek = 0;
2109 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2110 typeiter != TypeSplitPoints.end(); ++typeiter){
2112 wxString TypePropertyName;
2114 TSLiter = TypeSplitLength.find(typeiter->first);
2116 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2118 if (intTypeSeek == 0){
2123 TelTypeUI.Append(wxT(","));
2127 if (TypePropertyName == wxT("home")){
2129 PropType = PROPERTY_HOME;
2131 } else if (TypePropertyName == wxT("work")){
2133 PropType = PROPERTY_WORK;
2138 if (TypePropertyName == wxT("text")){
2140 TelTypeUI.Append(_("text"));
2143 } else if (TypePropertyName == wxT("voice")){
2145 TelTypeUI.Append(_("voice"));
2148 } else if (TypePropertyName == wxT("fax")){
2150 TelTypeUI.Append(_("fax"));
2153 } else if (TypePropertyName == wxT("cell")){
2155 TelTypeUI.Append(_("mobile"));
2158 } else if (TypePropertyName == wxT("video")){
2160 TelTypeUI.Append(_("video"));
2163 } else if (TypePropertyName == wxT("pager")){
2165 TelTypeUI.Append(_("pager"));
2168 } else if (TypePropertyName == wxT("textphone")){
2170 TelTypeUI.Append(_("textphone"));
2181 std::map<int, wxString> *TelephoneList = NULL;
2182 std::map<int, wxString> *TelephoneListType = NULL;
2183 std::map<int, wxString> *TelephoneListAltID = NULL;
2184 std::map<int, wxString> *TelephoneListPID = NULL;
2185 std::map<int, wxString> *TelephoneListTokens = NULL;
2186 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2187 std::map<int, int> *TelephoneListPref = NULL;
2191 TelephoneList = &GeneralTelephoneList;
2192 TelephoneListType = &GeneralTelephoneListType;
2193 TelephoneListAltID = &GeneralTelephoneListAltID;
2194 TelephoneListPID = &GeneralTelephoneListPID;
2195 TelephoneListTokens = &GeneralTelephoneListTokens;
2196 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2197 TelephoneListPref = &GeneralTelephoneListPref;
2200 TelephoneList = &HomeTelephoneList;
2201 TelephoneListType = &HomeTelephoneListType;
2202 TelephoneListAltID = &HomeTelephoneListAltID;
2203 TelephoneListPID = &HomeTelephoneListPID;
2204 TelephoneListTokens = &HomeTelephoneListTokens;
2205 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2206 TelephoneListPref = &HomeTelephoneListPref;
2209 TelephoneList = &BusinessTelephoneList;
2210 TelephoneListType = &BusinessTelephoneListType;
2211 TelephoneListAltID = &BusinessTelephoneListAltID;
2212 TelephoneListPID = &BusinessTelephoneListPID;
2213 TelephoneListTokens = &BusinessTelephoneListTokens;
2214 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2215 TelephoneListPref = &BusinessTelephoneListPref;
2219 // Process the properties.
2221 bool FirstToken = TRUE;
2224 SplitPoints.clear();
2225 SplitLength.clear();
2227 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2231 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2232 intiter != SplitPoints.end(); ++intiter){
2234 SLiter = SplitLength.find(intiter->first);
2236 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2238 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2239 PropertyName = PropertyElement.GetNextToken();
2240 PropertyValue = PropertyElement.GetNextToken();
2242 intPrevValue = intiter->second;
2244 CaptureString(&PropertyValue, FALSE);
2246 // Process properties.
2248 if (PropertyName == wxT("ALTID")){
2250 TelephoneListAltID->erase(*TelephoneCount);
2251 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2253 } else if (PropertyName == wxT("PID")){
2255 TelephoneListPID->erase(*TelephoneCount);
2256 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2258 } else if (PropertyName == wxT("PREF")){
2260 int PriorityNumber = 0;
2261 bool ValidNumber = TRUE;
2264 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2267 catch(std::invalid_argument &e){
2268 ValidNumber = FALSE;
2271 if (ValidNumber == TRUE){
2273 TelephoneListPref->erase(*TelephoneCount);
2274 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2280 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2282 if (FirstToken == TRUE){
2284 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2289 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2299 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2300 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2302 // Add the name token data.
2304 if (!PropertyTokens.IsEmpty()){
2306 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2312 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2314 std::map<int, int> SplitPoints;
2315 std::map<int, int> SplitLength;
2317 int intPrevValue = 6;
2320 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2324 PropertyType PropType = PROPERTY_NONE;
2326 // Look for type before continuing.
2328 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2330 std::map<int, wxString> *LanguageList = NULL;
2331 std::map<int, wxString> *LanguageListType = NULL;
2332 std::map<int, wxString> *LanguageListAltID = NULL;
2333 std::map<int, wxString> *LanguageListPID = NULL;
2334 std::map<int, wxString> *LanguageListTokens = NULL;
2335 std::map<int, int> *LanguageListPref = NULL;
2339 LanguageList = &GeneralLanguageList;
2340 LanguageListType = &GeneralLanguageListType;
2341 LanguageListAltID = &GeneralLanguageListAltID;
2342 LanguageListPID = &GeneralLanguageListPID;
2343 LanguageListTokens = &GeneralLanguageListTokens;
2344 LanguageListPref = &GeneralLanguageListPref;
2347 LanguageList = &HomeLanguageList;
2348 LanguageListType = &HomeLanguageListType;
2349 LanguageListAltID = &HomeLanguageListAltID;
2350 LanguageListPID = &HomeLanguageListPID;
2351 LanguageListTokens = &HomeLanguageListTokens;
2352 LanguageListPref = &HomeLanguageListPref;
2355 LanguageList = &BusinessLanguageList;
2356 LanguageListType = &BusinessLanguageListType;
2357 LanguageListAltID = &BusinessLanguageListAltID;
2358 LanguageListPID = &BusinessLanguageListPID;
2359 LanguageListTokens = &BusinessLanguageListTokens;
2360 LanguageListPref = &BusinessLanguageListPref;
2366 std::map<int,int>::iterator SLiter;
2367 wxString PropertyData;
2368 wxString PropertyName;
2369 wxString PropertyValue;
2370 wxString PropertyTokens;
2371 bool FirstToken = TRUE;
2373 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2374 intiter != SplitPoints.end(); ++intiter){
2376 SLiter = SplitLength.find(intiter->first);
2378 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2380 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2381 PropertyName = PropertyElement.GetNextToken();
2382 PropertyValue = PropertyElement.GetNextToken();
2384 intPrevValue = intiter->second;
2386 CaptureString(&PropertyValue, FALSE);
2388 // Process properties.
2390 if (PropertyName == wxT("ALTID")){
2392 LanguageListAltID->erase(*LanguageCount);
2393 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2395 } else if (PropertyName == wxT("PID")){
2397 LanguageListPID->erase(*LanguageCount);
2398 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2400 } else if (PropertyName == wxT("PREF")){
2402 int PriorityNumber = 0;
2403 bool ValidNumber = TRUE;
2406 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2409 catch(std::invalid_argument &e){
2410 ValidNumber = FALSE;
2413 if (ValidNumber == TRUE){
2415 LanguageListPref->erase(*LanguageCount);
2416 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2422 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2424 if (FirstToken == TRUE){
2426 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2431 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2441 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2443 // Add the name token data.
2445 if (!PropertyTokens.IsEmpty()){
2447 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2453 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2455 std::map<int, int> SplitPoints;
2456 std::map<int, int> SplitLength;
2458 int intPrevValue = 5;
2461 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2465 PropertyType PropType = PROPERTY_NONE;
2467 // Look for type before continuing.
2469 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2471 std::map<int, wxString> *GeopositionList = NULL;
2472 std::map<int, wxString> *GeopositionListType = NULL;
2473 std::map<int, wxString> *GeopositionListAltID = NULL;
2474 std::map<int, wxString> *GeopositionListPID = NULL;
2475 std::map<int, wxString> *GeopositionListTokens = NULL;
2476 std::map<int, wxString> *GeopositionListMediatype = NULL;
2477 std::map<int, int> *GeopositionListPref = NULL;
2481 GeopositionList = &GeneralGeographyList;
2482 GeopositionListType = &GeneralGeographyListType;
2483 GeopositionListAltID = &GeneralGeographyListAltID;
2484 GeopositionListPID = &GeneralGeographyListPID;
2485 GeopositionListTokens = &GeneralGeographyListTokens;
2486 GeopositionListMediatype = &GeneralGeographyListMediatype;
2487 GeopositionListPref = &GeneralGeographyListPref;
2490 GeopositionList = &HomeGeographyList;
2491 GeopositionListType = &HomeGeographyListType;
2492 GeopositionListAltID = &HomeGeographyListAltID;
2493 GeopositionListPID = &HomeGeographyListPID;
2494 GeopositionListTokens = &HomeGeographyListTokens;
2495 GeopositionListMediatype = &HomeGeographyListMediatype;
2496 GeopositionListPref = &HomeGeographyListPref;
2499 GeopositionList = &BusinessGeographyList;
2500 GeopositionListType = &BusinessGeographyListType;
2501 GeopositionListAltID = &BusinessGeographyListAltID;
2502 GeopositionListPID = &BusinessGeographyListPID;
2503 GeopositionListTokens = &BusinessGeographyListTokens;
2504 GeopositionListMediatype = &BusinessGeographyListMediatype;
2505 GeopositionListPref = &BusinessGeographyListPref;
2511 std::map<int,int>::iterator SLiter;
2512 wxString PropertyData;
2513 wxString PropertyName;
2514 wxString PropertyValue;
2515 wxString PropertyTokens;
2516 bool FirstToken = TRUE;
2518 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2519 intiter != SplitPoints.end(); ++intiter){
2521 SLiter = SplitLength.find(intiter->first);
2523 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2525 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2526 PropertyName = PropertyElement.GetNextToken();
2527 PropertyValue = PropertyElement.GetNextToken();
2529 intPrevValue = intiter->second;
2531 CaptureString(&PropertyValue, FALSE);
2533 // Process properties.
2535 if (PropertyName == wxT("ALTID")){
2537 GeopositionListAltID->erase(*GeographicCount);
2538 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2540 } else if (PropertyName == wxT("PID")){
2542 GeopositionListPID->erase(*GeographicCount);
2543 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2545 } else if (PropertyName == wxT("MEDIATYPE")){
2547 GeopositionListMediatype->erase(*GeographicCount);
2548 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2550 } else if (PropertyName == wxT("PREF")){
2552 int PriorityNumber = 0;
2553 bool ValidNumber = TRUE;
2556 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2559 catch(std::invalid_argument &e){
2560 ValidNumber = FALSE;
2563 if (ValidNumber == TRUE){
2565 GeopositionListPref->erase(*GeographicCount);
2566 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2572 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2574 if (FirstToken == TRUE){
2576 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2581 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2591 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2593 // Add the name token data.
2595 if (!PropertyTokens.IsEmpty()){
2597 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2603 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2605 size_t intPropertyLen = PropertySeg1.Len();
2606 std::map<int, int> SplitPoints;
2607 std::map<int, int> SplitLength;
2608 std::map<int, int>::iterator SLiter;
2609 wxString PropertyData;
2610 wxString PropertyName;
2611 wxString PropertyValue;
2612 wxString PropertyTokens;
2613 wxString RelatedType;
2614 wxString RelatedTypeOriginal;
2615 wxString RelatedName;
2616 bool FirstToken = TRUE;
2617 int intSplitsFound = 0;
2618 int intSplitSize = 0;
2619 int intPrevValue = 9;
2623 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2627 // Look for type before continuing.
2629 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2630 intiter != SplitPoints.end(); ++intiter){
2632 SLiter = SplitLength.find(intiter->first);
2634 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2636 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2637 PropertyName = PropertyElement.GetNextToken();
2638 PropertyValue = PropertyElement.GetNextToken();
2640 intPrevValue = intiter->second;
2644 RelatedTypeOriginal = PropertyValue;
2646 if (PropertyName == wxT("TYPE")){
2648 if (PropertyValue == wxT("contact")){
2650 RelatedType = _("Contact");
2652 } else if (PropertyValue == wxT("acquaintance")){
2654 RelatedType = _("Acquaintance");
2656 } else if (PropertyValue == wxT("friend")){
2658 RelatedType = _("Friend");
2660 } else if (PropertyValue == wxT("met")){
2662 RelatedType = _("Met");
2664 } else if (PropertyValue == wxT("co-worker")){
2666 RelatedType = _("Co-worker");
2668 } else if (PropertyValue == wxT("colleague")){
2670 RelatedType = _("Colleague");
2672 } else if (PropertyValue == wxT("co-resident")){
2674 RelatedType = _("Co-resident");
2676 } else if (PropertyValue == wxT("neighbor")){
2678 RelatedType = _("Neighbour");
2680 } else if (PropertyValue == wxT("child")){
2682 RelatedType = _("Child");
2684 } else if (PropertyValue == wxT("parent")){
2686 RelatedType = _("Parent");
2688 } else if (PropertyValue == wxT("sibling")){
2690 RelatedType = _("Sibling");
2692 } else if (PropertyValue == wxT("spouse")){
2694 RelatedType = _("Spouse");
2696 } else if (PropertyValue == wxT("kin")){
2698 RelatedType = _("Kin");
2700 } else if (PropertyValue == wxT("muse")){
2702 RelatedType = _("Muse");
2704 } else if (PropertyValue == wxT("crush")){
2706 RelatedType = _("Crush");
2708 } else if (PropertyValue == wxT("date")){
2710 RelatedType = _("Date");
2712 } else if (PropertyValue == wxT("sweetheart")){
2714 RelatedType = _("Sweetheart");
2716 } else if (PropertyValue == wxT("me")){
2718 RelatedType = _("Me");
2720 } else if (PropertyValue == wxT("agent")){
2722 RelatedType = _("Agent");
2724 } else if (PropertyValue == wxT("emergency")){
2726 RelatedType = _("Emergency");
2730 RelatedType = PropertyValue;
2740 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2741 intiter != SplitPoints.end(); ++intiter){
2743 SLiter = SplitLength.find(intiter->first);
2745 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2747 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2748 PropertyName = PropertyElement.GetNextToken();
2749 PropertyValue = PropertyElement.GetNextToken();
2751 intPrevValue = intiter->second;
2753 // Process properties.
2755 size_t intPropertyValueLen = PropertyValue.Len();
2757 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2759 PropertyValue.Trim();
2760 PropertyValue.RemoveLast();
2764 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2766 PropertyValue.Remove(0, 1);
2770 CaptureString(&PropertyValue, FALSE);
2772 if (PropertyName == wxT("ALTID")){
2774 GeneralRelatedListAltID.erase(*RelatedCount);
2775 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2777 } else if (PropertyName == wxT("PID")){
2779 GeneralRelatedListPID.erase(*RelatedCount);
2780 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2782 } else if (PropertyName == wxT("PREF")){
2784 int PriorityNumber = 0;
2785 bool ValidNumber = TRUE;
2788 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2791 catch(std::invalid_argument &e){
2792 ValidNumber = FALSE;
2795 if (ValidNumber == TRUE){
2797 GeneralRelatedListPref.erase(*RelatedCount);
2798 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2802 } else if (PropertyName == wxT("LANGUAGE")){
2804 GeneralRelatedListLanguage.erase(*RelatedCount);
2805 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2807 } else if (PropertyName != wxT("TYPE")) {
2809 // Something else we don't know about so append
2810 // to the tokens variable.
2812 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2814 if (FirstToken == TRUE){
2816 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2821 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2831 // Add the data to the General/Home/Work address variables.
2833 GeneralRelatedList.erase(*RelatedCount);
2834 GeneralRelatedListRelType.erase(*RelatedCount);
2835 GeneralRelatedListType.erase(*RelatedCount);
2836 GeneralRelatedListTokens.erase(*RelatedCount);
2837 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2838 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2839 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2840 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2844 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2846 std::map<int, int> SplitPoints;
2847 std::map<int, int> SplitLength;
2848 std::map<int, int>::iterator SLiter;
2849 wxString PropertyData;
2850 wxString PropertyName;
2851 wxString PropertyValue;
2852 wxString PropertyTokens;
2853 bool FirstToken = TRUE;
2854 int intPrevValue = 5;
2859 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2863 PropertyType PropType = PROPERTY_NONE;
2865 // Look for type before continuing.
2867 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2869 // Setup the pointers.
2871 std::map<int, wxString> *WebsiteList = NULL;
2872 std::map<int, wxString> *WebsiteListAltID = NULL;
2873 std::map<int, wxString> *WebsiteListPID = NULL;
2874 std::map<int, wxString> *WebsiteListType = NULL;
2875 std::map<int, wxString> *WebsiteListTokens = NULL;
2876 std::map<int, wxString> *WebsiteListMediatype = NULL;
2877 std::map<int, int> *WebsiteListPref = NULL;
2879 // Setup blank lines for later on.
2883 WebsiteList = &GeneralWebsiteList;
2884 WebsiteListType = &GeneralWebsiteListType;
2885 WebsiteListAltID = &GeneralWebsiteListAltID;
2886 WebsiteListPID = &GeneralWebsiteListPID;
2887 WebsiteListTokens = &GeneralWebsiteListTokens;
2888 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2889 WebsiteListPref = &GeneralWebsiteListPref;
2892 WebsiteList = &HomeWebsiteList;
2893 WebsiteListType = &HomeWebsiteListType;
2894 WebsiteListAltID = &HomeWebsiteListAltID;
2895 WebsiteListPID = &HomeWebsiteListPID;
2896 WebsiteListTokens = &HomeWebsiteListTokens;
2897 WebsiteListMediatype = &HomeWebsiteListMediatype;
2898 WebsiteListPref = &HomeWebsiteListPref;
2901 WebsiteList = &BusinessWebsiteList;
2902 WebsiteListType = &BusinessWebsiteListType;
2903 WebsiteListAltID = &BusinessWebsiteListAltID;
2904 WebsiteListPID = &BusinessWebsiteListPID;
2905 WebsiteListTokens = &BusinessWebsiteListTokens;
2906 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2907 WebsiteListPref = &BusinessWebsiteListPref;
2913 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2914 intiter != SplitPoints.end(); ++intiter){
2916 SLiter = SplitLength.find(intiter->first);
2918 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2920 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2921 PropertyName = PropertyElement.GetNextToken();
2922 PropertyValue = PropertyElement.GetNextToken();
2924 intPrevValue = intiter->second;
2926 // Process properties.
2928 size_t intPropertyValueLen = PropertyValue.Len();
2930 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2932 PropertyValue.Trim();
2933 PropertyValue.RemoveLast();
2937 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2939 PropertyValue.Remove(0, 1);
2943 CaptureString(&PropertyValue, FALSE);
2945 if (PropertyName == wxT("ALTID")){
2947 WebsiteListAltID->erase(*URLCount);
2948 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2950 } else if (PropertyName == wxT("PID")){
2952 WebsiteListPID->erase(*URLCount);
2953 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2955 } else if (PropertyName == wxT("PREF")){
2957 int PriorityNumber = 0;
2958 bool ValidNumber = TRUE;
2961 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2964 catch(std::invalid_argument &e){
2965 ValidNumber = FALSE;
2968 if (ValidNumber == TRUE){
2970 WebsiteListPref->erase(*URLCount);
2971 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2975 } else if (PropertyName == wxT("MEDIATYPE")){
2977 WebsiteListMediatype->erase(*URLCount);
2978 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2982 // Something else we don't know about so append
2983 // to the tokens variable.
2985 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2987 if (FirstToken == TRUE){
2989 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2994 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3004 // Add the data to the General/Home/Work address variables.
3006 CaptureString(&PropertySeg2, FALSE);
3008 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3010 if (!PropertyTokens.IsEmpty()){
3012 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3018 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3020 std::map<int, int> SplitPoints;
3021 std::map<int, int> SplitLength;
3022 std::map<int, int>::iterator SLiter;
3023 wxString PropertyData;
3024 wxString PropertyName;
3025 wxString PropertyValue;
3026 wxString PropertyTokens;
3027 bool FirstToken = TRUE;
3028 int intPrevValue = 7;
3033 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3037 PropertyType PropType = PROPERTY_NONE;
3039 // Look for type before continuing.
3041 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3043 // Setup the pointers.
3045 std::map<int, wxString> *TitleList = NULL;
3046 std::map<int, wxString> *TitleListAltID = NULL;
3047 std::map<int, wxString> *TitleListPID = NULL;
3048 std::map<int, wxString> *TitleListType = NULL;
3049 std::map<int, wxString> *TitleListTokens = NULL;
3050 std::map<int, wxString> *TitleListLanguage = NULL;
3051 std::map<int, int> *TitleListPref = NULL;
3053 // Setup blank lines for later on.
3057 TitleList = &GeneralTitleList;
3058 TitleListType = &GeneralTitleListType;
3059 TitleListAltID = &GeneralTitleListAltID;
3060 TitleListPID = &GeneralTitleListPID;
3061 TitleListTokens = &GeneralTitleListTokens;
3062 TitleListLanguage = &GeneralTitleListLanguage;
3063 TitleListPref = &GeneralTitleListPref;
3066 TitleList = &HomeTitleList;
3067 TitleListType = &HomeTitleListType;
3068 TitleListAltID = &HomeTitleListAltID;
3069 TitleListPID = &HomeTitleListPID;
3070 TitleListTokens = &HomeTitleListTokens;
3071 TitleListLanguage = &HomeTitleListLanguage;
3072 TitleListPref = &HomeTitleListPref;
3075 TitleList = &BusinessTitleList;
3076 TitleListType = &BusinessTitleListType;
3077 TitleListAltID = &BusinessTitleListAltID;
3078 TitleListPID = &BusinessTitleListPID;
3079 TitleListTokens = &BusinessTitleListTokens;
3080 TitleListLanguage = &BusinessTitleListLanguage;
3081 TitleListPref = &BusinessTitleListPref;
3087 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3088 intiter != SplitPoints.end(); ++intiter){
3090 SLiter = SplitLength.find(intiter->first);
3092 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3094 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3095 PropertyName = PropertyElement.GetNextToken();
3096 PropertyValue = PropertyElement.GetNextToken();
3098 intPrevValue = intiter->second;
3100 // Process properties.
3102 size_t intPropertyValueLen = PropertyValue.Len();
3104 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3106 PropertyValue.Trim();
3107 PropertyValue.RemoveLast();
3111 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3113 PropertyValue.Remove(0, 1);
3117 CaptureString(&PropertyValue, FALSE);
3119 if (PropertyName == wxT("ALTID")){
3121 TitleListAltID->erase(*TitleCount);
3122 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3124 } else if (PropertyName == wxT("PID")){
3126 TitleListPID->erase(*TitleCount);
3127 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3129 } else if (PropertyName == wxT("PREF")){
3131 int PriorityNumber = 0;
3132 bool ValidNumber = TRUE;
3135 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3138 catch(std::invalid_argument &e){
3139 ValidNumber = FALSE;
3142 if (ValidNumber == TRUE){
3144 TitleListPref->erase(*TitleCount);
3145 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3149 } else if (PropertyName == wxT("LANGUAGE")){
3151 TitleListLanguage->erase(*TitleCount);
3152 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3156 // Something else we don't know about so append
3157 // to the tokens variable.
3159 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3161 if (FirstToken == TRUE){
3163 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3168 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3178 // Add the data to the General/Home/Work address variables.
3180 CaptureString(&PropertySeg2, FALSE);
3182 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3184 if (!PropertyTokens.IsEmpty()){
3186 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3192 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3194 std::map<int, int> SplitPoints;
3195 std::map<int, int> SplitLength;
3196 std::map<int, int>::iterator SLiter;
3197 wxString PropertyData;
3198 wxString PropertyName;
3199 wxString PropertyValue;
3200 wxString PropertyTokens;
3201 bool FirstToken = TRUE;
3202 int intPrevValue = 6;
3207 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3211 PropertyType PropType = PROPERTY_NONE;
3213 // Look for type before continuing.
3215 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3217 // Setup the pointers.
3219 std::map<int, wxString> *RoleList = NULL;
3220 std::map<int, wxString> *RoleListAltID = NULL;
3221 std::map<int, wxString> *RoleListPID = NULL;
3222 std::map<int, wxString> *RoleListType = NULL;
3223 std::map<int, wxString> *RoleListTokens = NULL;
3224 std::map<int, wxString> *RoleListLanguage = NULL;
3225 std::map<int, int> *RoleListPref = NULL;
3227 // Setup blank lines for later on.
3231 RoleList = &GeneralRoleList;
3232 RoleListType = &GeneralRoleListType;
3233 RoleListAltID = &GeneralRoleListAltID;
3234 RoleListPID = &GeneralRoleListPID;
3235 RoleListTokens = &GeneralRoleListTokens;
3236 RoleListLanguage = &GeneralRoleListLanguage;
3237 RoleListPref = &GeneralRoleListPref;
3240 RoleList = &HomeRoleList;
3241 RoleListType = &HomeRoleListType;
3242 RoleListAltID = &HomeRoleListAltID;
3243 RoleListPID = &HomeRoleListPID;
3244 RoleListTokens = &HomeRoleListTokens;
3245 RoleListLanguage = &HomeRoleListLanguage;
3246 RoleListPref = &HomeRoleListPref;
3249 RoleList = &BusinessRoleList;
3250 RoleListType = &BusinessRoleListType;
3251 RoleListAltID = &BusinessRoleListAltID;
3252 RoleListPID = &BusinessRoleListPID;
3253 RoleListTokens = &BusinessRoleListTokens;
3254 RoleListLanguage = &BusinessRoleListLanguage;
3255 RoleListPref = &BusinessRoleListPref;
3261 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3262 intiter != SplitPoints.end(); ++intiter){
3264 SLiter = SplitLength.find(intiter->first);
3266 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3268 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3269 PropertyName = PropertyElement.GetNextToken();
3270 PropertyValue = PropertyElement.GetNextToken();
3272 intPrevValue = intiter->second;
3274 // Process properties.
3276 size_t intPropertyValueLen = PropertyValue.Len();
3278 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3280 PropertyValue.Trim();
3281 PropertyValue.RemoveLast();
3285 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3287 PropertyValue.Remove(0, 1);
3291 CaptureString(&PropertyValue, FALSE);
3293 if (PropertyName == wxT("ALTID")){
3295 RoleListAltID->erase(*RoleCount);
3296 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3298 } else if (PropertyName == wxT("PID")){
3300 RoleListPID->erase(*RoleCount);
3301 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3303 } else if (PropertyName == wxT("PREF")){
3305 int PriorityNumber = 0;
3306 bool ValidNumber = TRUE;
3309 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3312 catch(std::invalid_argument &e){
3313 ValidNumber = FALSE;
3316 if (ValidNumber == TRUE){
3318 RoleListPref->erase(*RoleCount);
3319 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3323 } else if (PropertyName == wxT("LANGUAGE")){
3325 RoleListLanguage->erase(*RoleCount);
3326 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3330 // Something else we don't know about so append
3331 // to the tokens variable.
3333 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3335 if (FirstToken == TRUE){
3337 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3342 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3352 // Add the data to the General/Home/Work address variables.
3354 CaptureString(&PropertySeg2, FALSE);
3356 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3358 if (!PropertyTokens.IsEmpty()){
3360 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3366 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3368 std::map<int, int> SplitPoints;
3369 std::map<int, int> SplitLength;
3370 std::map<int, int>::iterator SLiter;
3371 wxString PropertyData;
3372 wxString PropertyName;
3373 wxString PropertyValue;
3374 wxString PropertyTokens;
3375 bool FirstToken = TRUE;
3376 int intPrevValue = 5;
3381 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3385 PropertyType PropType = PROPERTY_NONE;
3387 // Look for type before continuing.
3389 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3391 // Setup the pointers.
3393 std::map<int, wxString> *OrganisationsList = NULL;
3394 std::map<int, wxString> *OrganisationsListAltID = NULL;
3395 std::map<int, wxString> *OrganisationsListPID = NULL;
3396 std::map<int, wxString> *OrganisationsListType = NULL;
3397 std::map<int, wxString> *OrganisationsListTokens = NULL;
3398 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3399 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3400 std::map<int, int> *OrganisationsListPref = NULL;
3402 // Setup blank lines for later on.
3406 OrganisationsList = &GeneralOrganisationsList;
3407 OrganisationsListType = &GeneralOrganisationsListType;
3408 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3409 OrganisationsListPID = &GeneralOrganisationsListPID;
3410 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3411 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3412 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3413 OrganisationsListPref = &GeneralOrganisationsListPref;
3416 OrganisationsList = &HomeOrganisationsList;
3417 OrganisationsListType = &HomeOrganisationsListType;
3418 OrganisationsListAltID = &HomeOrganisationsListAltID;
3419 OrganisationsListPID = &HomeOrganisationsListPID;
3420 OrganisationsListTokens = &HomeOrganisationsListTokens;
3421 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3422 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3423 OrganisationsListPref = &HomeOrganisationsListPref;
3426 OrganisationsList = &BusinessOrganisationsList;
3427 OrganisationsListType = &BusinessOrganisationsListType;
3428 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3429 OrganisationsListPID = &BusinessOrganisationsListPID;
3430 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3431 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3432 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3433 OrganisationsListPref = &BusinessOrganisationsListPref;
3439 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3440 intiter != SplitPoints.end(); ++intiter){
3442 SLiter = SplitLength.find(intiter->first);
3444 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3446 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3447 PropertyName = PropertyElement.GetNextToken();
3448 PropertyValue = PropertyElement.GetNextToken();
3450 intPrevValue = intiter->second;
3452 // Process properties.
3454 size_t intPropertyValueLen = PropertyValue.Len();
3456 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3458 PropertyValue.Trim();
3459 PropertyValue.RemoveLast();
3463 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3465 PropertyValue.Remove(0, 1);
3469 CaptureString(&PropertyValue, FALSE);
3471 if (PropertyName == wxT("ALTID")){
3473 OrganisationsListAltID->erase(*OrganisationCount);
3474 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3476 } else if (PropertyName == wxT("PID")){
3478 OrganisationsListPID->erase(*OrganisationCount);
3479 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3481 } else if (PropertyName == wxT("SORT-AS")){
3483 OrganisationsListSortAs->erase(*OrganisationCount);
3484 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3486 } else if (PropertyName == wxT("PREF")){
3488 int PriorityNumber = 0;
3489 bool ValidNumber = TRUE;
3492 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3495 catch(std::invalid_argument &e){
3496 ValidNumber = FALSE;
3499 if (ValidNumber == TRUE){
3501 OrganisationsListPref->erase(*OrganisationCount);
3502 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3506 } else if (PropertyName == wxT("LANGUAGE")){
3508 OrganisationsListLanguage->erase(*OrganisationCount);
3509 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3513 // Something else we don't know about so append
3514 // to the tokens variable.
3516 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3518 if (FirstToken == TRUE){
3520 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3525 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3535 // Add the data to the General/Home/Work address variables.
3537 CaptureString(&PropertySeg2, FALSE);
3539 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3541 if (!PropertyTokens.IsEmpty()){
3543 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3549 void SplitValues(wxString *PropertyLine,
3550 std::map<int,int> *SplitPoints,
3551 std::map<int,int> *SplitLength,
3554 size_t intPropertyLen = PropertyLine->Len();
3555 int intSplitsFound = 0;
3556 int intSplitSize = 0;
3557 int intSplitSeek = 0;
3559 for (int i = intSize; i <= intPropertyLen; i++){
3563 if (PropertyLine->Mid(i, 1) == wxT(";") &&
3564 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
3566 if (intSplitsFound == 0){
3568 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
3572 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3576 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
3586 if (intSplitsFound == 0){
3588 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
3589 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3593 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3594 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3600 void CheckType(wxString *PropertySeg1,
3601 std::map<int,int> *SplitPoints,
3602 std::map<int,int> *SplitLength,
3604 PropertyType *PropType){
3606 wxString PropertyData;
3607 wxString PropertyName;
3608 wxString PropertyValue;
3609 std::map<int,int>::iterator SLiter;
3611 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
3612 intiter != SplitPoints->end(); ++intiter){
3614 SLiter = SplitLength->find(intiter->first);
3616 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
3618 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3619 PropertyName = PropertyElement.GetNextToken();
3620 PropertyValue = PropertyElement.GetNextToken();
3622 *intPrevValue = intiter->second;
3624 if (PropertyName == wxT("TYPE")){
3626 if (PropertyValue == wxT("work")){
3628 *PropType = PROPERTY_WORK;
3630 } else if (PropertyValue == wxT("home")){
3632 *PropType = PROPERTY_HOME;
3636 *PropType = PROPERTY_NONE;