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;
101 wxString ContactLine;
102 wxString PropertyLine;
103 wxString PropertySeg1;
104 wxString PropertySeg2;
105 wxString PropertyNextLine;
108 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
109 iter != ContactFileLines.end(); ++iter){
111 ExtraLineSeek = TRUE;
117 PropertyLine.Clear();
118 PropertySeg1.Clear();
119 PropertySeg2.Clear();
122 ContactLine = iter->second;
124 while (ExtraLineSeek == TRUE){
126 // Check if there is extra data on the next line
127 // (indicated by space or tab at the start) and add data.
131 if (iter == ContactFileLines.end()){
138 PropertyNextLine = iter->second;
140 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
142 PropertyNextLine.Remove(0, 1);
143 ContactLine.Append(PropertyNextLine);
148 ExtraLineSeek = FALSE;
154 ContactLineLen = ContactLine.Len();
156 // Make sure we are not in quotation mode.
157 // Make sure colon does not have \ or \\ before it.
159 for (int i = 0; i <= ContactLineLen; i++){
161 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
163 PropertyFind = FALSE;
165 } else if (PropertyFind == TRUE){
167 Property.Append(ContactLine.Mid(i, 1));
171 if (ContactLine.Mid(i, 1) == wxT("\"")){
173 if (QuoteMode == TRUE){
185 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
194 // Split that line at the point into two variables (ignore the colon).
196 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
197 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
199 if (Property == wxT("KIND") && KindProcessed == FALSE){
201 ProcessKind(PropertySeg2);
203 } else if (Property == wxT("MEMBER")){
205 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
208 } else if (Property == wxT("FN")){
210 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
213 } else if (Property == wxT("N") && NameProcessed == FALSE){
215 ProcessN(PropertySeg1, PropertySeg2);
216 NameProcessed = TRUE;
218 } else if (Property == wxT("NICKNAME")){
220 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
223 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
225 ProcessGender(PropertySeg1, PropertySeg2);
226 GenderProcessed = TRUE;
228 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
230 ProcessBirthday(PropertySeg1, PropertySeg2);
231 BirthdayProcessed = TRUE;
233 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
235 ProcessAnniversary(PropertySeg1, PropertySeg2);
236 AnniversaryProcessed = TRUE;
238 } else if (Property == wxT("TZ")){
240 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
243 } else if (Property == wxT("ADR")){
245 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
248 } else if (Property == wxT("EMAIL")){
250 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
253 } else if (Property == wxT("IMPP")){
255 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
258 } else if (Property == wxT("TEL")){
260 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
263 } else if (Property == wxT("LANG")){
265 // See frmContactEditor-LoadLanguage.cpp
267 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
270 } else if (Property == wxT("GEO")){
272 // See frmContactEditor-LoadGeo.cpp
274 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
277 } else if (Property == wxT("RELATED")){
279 // See fromContactEditor-LoadRelated.cpp
281 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
284 } else if (Property == wxT("URL")){
286 // See frmContactEditor-LoadURL.cpp
288 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
291 } else if (Property == wxT("TITLE")) {
293 // See frmContactEditor-LoadTitle.cpp
295 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
298 } else if (Property == wxT("ROLE")) {
300 // See frmContactEditor-LoadTitle.cpp
302 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
305 } else if (Property == wxT("ORG")) {
307 // See frmContactEditor-LoadOrg.cpp
309 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
312 } else if (Property == wxT("NOTE")) {
314 // See frmContactEditor-LoadNote.cpp
316 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
319 } else if (Property == wxT("CATEGORIES")) {
321 // See frmContactEditor-LoadCategory.cpp
323 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
326 } else if (Property == wxT("PHOTO")) {
328 // See frmContactEditor-LoadPhoto.cpp
330 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
337 return CONTACTLOAD_OK;
341 void ContactDataObject::ProcessKind(wxString KindType){
343 if (KindType == wxT("individual")){
345 ContactKind = CONTACTKIND_INDIVIDUAL;
347 } else if (KindType == wxT("group")){
349 ContactKind = CONTACTKIND_GROUP;
351 } else if (KindType == wxT("org")){
353 ContactKind = CONTACTKIND_ORGANISATION;
355 } else if (KindType == wxT("location")){
357 ContactKind = CONTACTKIND_LOCATION;
361 ContactKind = CONTACTKIND_NONE;
366 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
368 std::map<int, int> SplitPoints;
369 std::map<int, int> SplitLength;
371 int intPrevValue = 8;
375 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
379 wxString PropertyName;
380 wxString PropertyValue;
381 wxString PropertyData;
382 wxString PropertyTokens;
383 std::map<int,int>::iterator SLiter;
384 bool FirstToken = TRUE;
386 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
387 intiter != SplitPoints.end(); ++intiter){
389 SLiter = SplitLength.find(intiter->first);
391 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
393 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
394 PropertyName = PropertyElement.GetNextToken();
395 PropertyValue = PropertyElement.GetNextToken();
397 intPrevValue = intiter->second;
399 CaptureString(&PropertyValue, FALSE);
401 if (PropertyName == wxT("ALTID")){
403 GroupsListAltID.erase(*GroupCount);
404 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
406 } else if (PropertyName == wxT("PID")){
408 GroupsListPID.erase(*GroupCount);
409 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
411 } else if (PropertyName == wxT("PREF")){
413 int PriorityNumber = 0;
414 bool ValidNumber = TRUE;
417 PriorityNumber = std::stoi(PropertyValue.ToStdString());
420 catch(std::invalid_argument &e){
424 if (ValidNumber == TRUE){
426 GroupsListPref.erase(*GroupCount);
427 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
431 } else if (PropertyName == wxT("MEDIATYPE")){
433 GroupsListMediaType.erase(*GroupCount);
434 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
436 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
438 if (FirstToken == TRUE){
440 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
445 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
453 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
455 if (!PropertyTokens.IsEmpty()){
457 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
464 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
466 std::map<int, int> SplitPoints;
467 std::map<int, int> SplitLength;
469 int intPrevValue = 4;
473 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
477 wxString PropertyName;
478 wxString PropertyValue;
479 wxString PropertyData;
480 wxString PropertyTokens;
481 std::map<int,int>::iterator SLiter;
482 bool FirstToken = TRUE;
484 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
485 intiter != SplitPoints.end(); ++intiter){
487 SLiter = SplitLength.find(intiter->first);
489 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
491 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
492 PropertyName = PropertyElement.GetNextToken();
493 PropertyValue = PropertyElement.GetNextToken();
495 intPrevValue = intiter->second;
497 CaptureString(&PropertyValue, FALSE);
499 if (PropertyName == wxT("TYPE")){
501 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
502 PropertyValue == wxT("work") ){
504 FullNamesListType.erase(*FNCount);
505 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
509 } else if (PropertyName == wxT("LANGUAGE")){
511 FullNamesListLanguage.erase(*FNCount);
512 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
514 } else if (PropertyName == wxT("ALTID")){
516 FullNamesListAltID.erase(*FNCount);
517 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
519 } else if (PropertyName == wxT("PID")){
521 FullNamesListPID.erase(*FNCount);
522 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
524 } else if (PropertyName == wxT("PREF")){
526 int PriorityNumber = 0;
527 bool ValidNumber = TRUE;
530 PriorityNumber = std::stoi(PropertyValue.ToStdString());
533 catch(std::invalid_argument &e){
537 if (ValidNumber == TRUE){
539 FullNamesListPref.erase(*FNCount);
540 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
544 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
546 if (FirstToken == TRUE){
548 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
553 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
561 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
563 if (!PropertyTokens.IsEmpty()){
565 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
571 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
573 std::map<int, int> SplitPoints;
574 std::map<int, int> SplitLength;
576 int intPrevValue = 3;
580 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
584 wxString PropertyName;
585 wxString PropertyValue;
586 wxString PropertyData;
587 wxString PropertyTokens;
588 std::map<int,int>::iterator SLiter;
589 bool FirstToken = TRUE;
591 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
592 intiter != SplitPoints.end(); ++intiter){
594 SLiter = SplitLength.find(intiter->first);
596 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
598 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
599 PropertyName = PropertyElement.GetNextToken();
600 PropertyValue = PropertyElement.GetNextToken();
602 intPrevValue = intiter->second;
604 CaptureString(&PropertyValue, FALSE);
606 if (PropertyName == wxT("ALTID")){
608 NameAltID = PropertyValue;
610 } else if (PropertyName == wxT("LANGUAGE")){
612 NameLanguage = PropertyValue;
614 } else if (PropertyName == wxT("SORT-AS")){
616 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
617 PropertyValue.Len() >= 3){
618 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
621 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
623 if (FirstToken == TRUE){
625 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
630 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
638 // Split the name data.
640 int intSplitSeek = 0;
641 int intSplitsFound = 0;
642 int intSplitSize = 0;
643 int intPropertyLen = PropertySeg2.Len();
645 std::map<int,wxString> NameValues;
648 for (int i = 0; i <= intPropertyLen; i++){
650 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
652 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
657 if (intSplitsFound == 4){
659 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
673 // Split the data into several parts.
675 for (std::map<int, wxString>::iterator iter = NameValues.begin();
676 iter != NameValues.end(); ++iter){
678 if (iter->first == 1){
680 // Deal with family name.
682 NameSurname = iter->second;
684 } else if (iter->first == 2){
686 // Deal with given names.
688 NameForename = iter->second;
690 } else if (iter->first == 3){
692 // Deal with additional names.
694 NameOtherNames = iter->second;
696 } else if (iter->first == 4){
698 // Deal with honorifix prefixes and suffixes.
700 NameTitle = iter->second;
704 if (iter == NameValues.end()){
710 NameSuffix = iter->second;
716 // Add the name token data.
718 if (!PropertyTokens.IsEmpty()){
720 NameTokens = PropertyTokens;
726 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
728 std::map<int, int> SplitPoints;
729 std::map<int, int> SplitLength;
731 int intPrevValue = 10;
734 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
738 PropertyType PropType = PROPERTY_NONE;
740 // Look for type before continuing.
742 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
746 std::map<int, wxString> *NicknamesList = NULL;
747 std::map<int, wxString> *NicknamesListType = NULL;
748 std::map<int, wxString> *NicknamesListLanguage = NULL;
749 std::map<int, wxString> *NicknamesListAltID = NULL;
750 std::map<int, wxString> *NicknamesListPID = NULL;
751 std::map<int, wxString> *NicknamesListTokens = NULL;
752 std::map<int, int> *NicknamesListPref = NULL;
756 NicknamesList = &GeneralNicknamesList;
757 NicknamesListType = &GeneralNicknamesListType;
758 NicknamesListLanguage = &GeneralNicknamesListLanguage;
759 NicknamesListAltID = &GeneralNicknamesListAltID;
760 NicknamesListPID = &GeneralNicknamesListPID;
761 NicknamesListTokens = &GeneralNicknamesListTokens;
762 NicknamesListPref = &GeneralNicknamesListPref;
765 NicknamesList = &HomeNicknamesList;
766 NicknamesListType = &HomeNicknamesListType;
767 NicknamesListLanguage = &HomeNicknamesListLanguage;
768 NicknamesListAltID = &HomeNicknamesListAltID;
769 NicknamesListPID = &HomeNicknamesListPID;
770 NicknamesListTokens = &HomeNicknamesListTokens;
771 NicknamesListPref = &HomeNicknamesListPref;
774 NicknamesList = &BusinessNicknamesList;
775 NicknamesListType = &BusinessNicknamesListType;
776 NicknamesListLanguage = &BusinessNicknamesListLanguage;
777 NicknamesListAltID = &BusinessNicknamesListAltID;
778 NicknamesListPID = &BusinessNicknamesListPID;
779 NicknamesListTokens = &BusinessNicknamesListTokens;
780 NicknamesListPref = &BusinessNicknamesListPref;
784 std::map<int, int>::iterator SLiter;
785 wxString PropertyData;
786 wxString PropertyName;
787 wxString PropertyValue;
788 wxString PropertyTokens;
789 bool FirstToken = TRUE;
791 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
792 intiter != SplitPoints.end(); ++intiter){
794 SLiter = SplitLength.find(intiter->first);
796 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
798 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
799 PropertyName = PropertyElement.GetNextToken();
800 PropertyValue = PropertyElement.GetNextToken();
802 intPrevValue = intiter->second;
804 CaptureString(&PropertyValue, FALSE);
806 if (PropertyName == wxT("ALTID")){
808 NicknamesListAltID->erase(*NicknameCount);
809 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
811 } else if (PropertyName == wxT("PID")){
813 NicknamesListPID->erase(*NicknameCount);
814 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
816 } else if (PropertyName == wxT("PREF")){
818 int PriorityNumber = 0;
819 bool ValidNumber = TRUE;
822 PriorityNumber = std::stoi(PropertyValue.ToStdString());
825 catch(std::invalid_argument &e){
829 if (ValidNumber == TRUE){
831 NicknamesListPref->erase(*NicknameCount);
832 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
836 } else if (PropertyName == wxT("LANGUAGE")){
838 NicknamesListLanguage->erase(*NicknameCount);
839 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
843 // Something else we don't know about so append
844 // to the tokens variable.
846 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
848 if (FirstToken == TRUE){
850 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
855 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
865 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
867 // Add the name token data.
869 if (!PropertyTokens.IsEmpty()){
871 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
877 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
879 std::map<int, int> SplitPoints;
880 std::map<int, int> SplitLength;
881 std::map<int, int>::iterator SLiter;
882 wxString PropertyData;
883 wxString PropertyName;
884 wxString PropertyValue;
885 wxString PropertyTokens;
886 bool FirstToken = TRUE;
887 int intPrevValue = 8;
889 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
893 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
894 intiter != SplitPoints.end(); ++intiter){
896 SLiter = SplitLength.find(intiter->first);
898 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
900 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
901 PropertyName = PropertyElement.GetNextToken();
902 PropertyValue = PropertyElement.GetNextToken();
904 intPrevValue = intiter->second;
906 // Process properties.
908 size_t intPropertyValueLen = PropertyValue.Len();
910 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
912 PropertyValue.Trim();
913 PropertyValue.RemoveLast();
917 if (PropertyValue.Mid(0, 1) == wxT("\"")){
919 PropertyValue.Remove(0, 1);
923 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
925 if (FirstToken == TRUE){
927 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
932 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
940 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
942 wxString GenderComponent;
944 if (GenderData.CountTokens() >= 2){
946 Gender = GenderData.GetNextToken();
947 GenderDetails = GenderData.GetString();
949 CaptureString(&GenderDetails, FALSE);
953 Gender = GenderData.GetNextToken();
957 if (!PropertyTokens.IsEmpty()){
959 GenderTokens = PropertyTokens;
965 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
967 // Process date. Preserve the remainder in the string.
969 std::map<int, int> SplitPoints;
970 std::map<int, int> SplitLength;
971 std::map<int, int>::iterator SLiter;
972 wxString PropertyData;
973 wxString PropertyName;
974 wxString PropertyValue;
975 wxString PropertyTokens;
976 bool BirthdayText = FALSE;
977 int intPrevValue = 6;
979 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
983 // Look for type before continuing.
985 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
986 intiter != SplitPoints.end(); ++intiter){
988 SLiter = SplitLength.find(intiter->first);
990 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
992 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
993 PropertyName = PropertyElement.GetNextToken();
994 PropertyValue = PropertyElement.GetNextToken();
996 intPrevValue = intiter->second;
998 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1000 CaptureString(&PropertySeg2, FALSE);
1001 Birthday = PropertySeg2;
1002 BirthdayText = TRUE;
1008 // Setup blank lines for later on.
1011 bool FirstToken = TRUE;
1013 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1014 intiter != SplitPoints.end(); ++intiter){
1016 SLiter = SplitLength.find(intiter->first);
1018 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1020 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1021 PropertyName = PropertyElement.GetNextToken();
1022 PropertyValue = PropertyElement.GetNextToken();
1024 intPrevValue = intiter->second;
1026 // Process properties.
1028 CaptureString(&PropertyValue, FALSE);
1030 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1032 PropertyValue.Trim();
1033 PropertyValue.RemoveLast();
1037 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1039 PropertyValue.Remove(0, 1);
1043 if (PropertyName == wxT("ALTID")){
1045 BirthdayAltID = PropertyValue;
1047 } else if (PropertyName == wxT("CALSCALE")){
1049 BirthdayCalScale = PropertyValue;
1051 } else if (PropertyName != wxT("VALUE")) {
1053 // Something else we don't know about so append
1054 // to the tokens variable.
1056 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1058 if (FirstToken == TRUE){
1060 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1065 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1075 // Add the data to the variables and form.
1077 if (BirthdayText == FALSE){
1079 Birthday = PropertySeg2;
1083 if (!PropertyTokens.IsEmpty()){
1085 BirthdayTokens = PropertyTokens;
1091 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1093 // Process date. Preserve the remainder in the string.
1095 std::map<int, int> SplitPoints;
1096 std::map<int, int> SplitLength;
1097 std::map<int, int>::iterator SLiter;
1098 wxString PropertyData;
1099 wxString PropertyName;
1100 wxString PropertyValue;
1101 wxString PropertyTokens;
1102 bool AnniversaryText = FALSE;
1103 int intPrevValue = 13;
1105 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1109 // Look for type before continuing.
1111 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1112 intiter != SplitPoints.end(); ++intiter){
1114 SLiter = SplitLength.find(intiter->first);
1116 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1118 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1119 PropertyName = PropertyElement.GetNextToken();
1120 PropertyValue = PropertyElement.GetNextToken();
1122 intPrevValue = intiter->second;
1124 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1126 CaptureString(&PropertySeg2, FALSE);
1127 Anniversary = PropertySeg2;
1128 AnniversaryText = TRUE;
1134 // Setup blank lines for later on.
1137 bool FirstToken = TRUE;
1139 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1140 intiter != SplitPoints.end(); ++intiter){
1142 SLiter = SplitLength.find(intiter->first);
1144 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1146 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1147 PropertyName = PropertyElement.GetNextToken();
1148 PropertyValue = PropertyElement.GetNextToken();
1150 intPrevValue = intiter->second;
1152 // Process properties.
1154 CaptureString(&PropertyValue, FALSE);
1156 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1158 PropertyValue.Trim();
1159 PropertyValue.RemoveLast();
1163 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1165 PropertyValue.Remove(0, 1);
1169 if (PropertyName == wxT("ALTID")){
1171 AnniversaryAltID = PropertyValue;
1173 } else if (PropertyName == wxT("CALSCALE")){
1175 AnniversaryCalScale = PropertyValue;
1177 } else if (PropertyName != wxT("VALUE")) {
1179 // Something else we don't know about so append
1180 // to the tokens variable.
1182 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1184 if (FirstToken == TRUE){
1186 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1191 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1201 // Add the data to the variables and form.
1203 if (AnniversaryText == FALSE){
1205 Anniversary = PropertySeg2;
1209 if (!PropertyTokens.IsEmpty()){
1211 AnniversaryTokens = PropertyTokens;
1217 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1219 std::map<int, int> SplitPoints;
1220 std::map<int, int> SplitLength;
1222 int intPrevValue = 4;
1225 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1229 PropertyType PropType = PROPERTY_NONE;
1231 // Look for type before continuing.
1233 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1237 std::map<int, wxString> *TZList = NULL;
1238 std::map<int, wxString> *TZListType = NULL;
1239 std::map<int, wxString> *TZListMediatype = NULL;
1240 std::map<int, wxString> *TZListAltID = NULL;
1241 std::map<int, wxString> *TZListPID = NULL;
1242 std::map<int, wxString> *TZListTokens = NULL;
1243 std::map<int, int> *TZListPref = NULL;
1247 TZList = &GeneralTZList;
1248 TZListType = &GeneralTZListType;
1249 TZListMediatype = &GeneralTZListMediatype;
1250 TZListAltID = &GeneralTZListAltID;
1251 TZListPID = &GeneralTZListPID;
1252 TZListTokens = &GeneralTZListTokens;
1253 TZListPref = &GeneralTZListPref;
1256 TZList = &HomeTZList;
1257 TZListType = &HomeTZListType;
1258 TZListMediatype = &HomeTZListMediatype;
1259 TZListAltID = &HomeTZListAltID;
1260 TZListPID = &HomeTZListPID;
1261 TZListTokens = &HomeTZListTokens;
1262 TZListPref = &HomeTZListPref;
1265 TZList = &BusinessTZList;
1266 TZListType = &BusinessTZListType;
1267 TZListMediatype = &BusinessTZListMediatype;
1268 TZListAltID = &BusinessTZListAltID;
1269 TZListPID = &BusinessTZListPID;
1270 TZListTokens = &BusinessTZListTokens;
1271 TZListPref = &BusinessTZListPref;
1275 std::map<int, int>::iterator SLiter;
1276 wxString PropertyData;
1277 wxString PropertyName;
1278 wxString PropertyValue;
1279 wxString PropertyTokens;
1280 bool FirstToken = TRUE;
1282 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1283 intiter != SplitPoints.end(); ++intiter){
1285 SLiter = SplitLength.find(intiter->first);
1287 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1289 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1290 PropertyName = PropertyElement.GetNextToken();
1291 PropertyValue = PropertyElement.GetNextToken();
1293 intPrevValue = intiter->second;
1295 CaptureString(&PropertyValue, FALSE);
1297 if (PropertyName == wxT("ALTID")){
1299 TZListAltID->erase(*TimeZoneCount);
1300 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1302 } else if (PropertyName == wxT("PID")){
1304 TZListPID->erase(*TimeZoneCount);
1305 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1307 } else if (PropertyName == wxT("PREF")){
1309 int PriorityNumber = 0;
1310 bool ValidNumber = TRUE;
1313 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1316 catch(std::invalid_argument &e){
1317 ValidNumber = FALSE;
1320 if (ValidNumber == TRUE){
1322 TZListPref->erase(*TimeZoneCount);
1323 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1327 } else if (PropertyName == wxT("MEDIATYPE")){
1329 TZListMediatype->erase(*TimeZoneCount);
1330 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1334 // Something else we don't know about so append
1335 // to the tokens variable.
1337 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1339 if (FirstToken == TRUE){
1341 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1346 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1356 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1358 // Add the name token data.
1360 if (!PropertyTokens.IsEmpty()){
1362 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1369 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1371 size_t intPropertyLen = PropertySeg1.Len();
1372 std::map<int, int> SplitPoints;
1373 std::map<int, int> SplitLength;
1374 std::map<int, int>::iterator SLiter;
1375 wxString PropertyData;
1376 wxString PropertyName;
1377 wxString PropertyValue;
1378 wxString PropertyTokens;
1379 wxString AddressLabel;
1380 wxString AddressLang;
1381 wxString AddressAltID;
1382 wxString AddressPID;
1383 wxString AddressTokens;
1384 wxString AddressGeo;
1385 wxString AddressTimezone;
1386 wxString AddressType;
1387 wxString AddressMediatype;
1388 wxString AddressPOBox;
1389 wxString AddressExtended;
1390 wxString AddressStreet;
1391 wxString AddressLocality;
1392 wxString AddressCity;
1393 wxString AddressRegion;
1394 wxString AddressPostalCode;
1395 wxString AddressCountry;
1396 bool FirstToken = TRUE;
1397 int intSplitsFound = 0;
1398 int intSplitSize = 0;
1399 int intPrevValue = 5;
1404 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1408 PropertyType PropType = PROPERTY_NONE;
1410 // Look for type before continuing.
1412 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1416 std::map<int, wxString> *AddressList = NULL;
1417 std::map<int, wxString> *AddressListTown = NULL;
1418 std::map<int, wxString> *AddressListCounty = NULL;
1419 std::map<int, wxString> *AddressListPostCode = NULL;
1420 std::map<int, wxString> *AddressListCountry = NULL;
1421 std::map<int, wxString> *AddressListLabel = NULL;
1422 std::map<int, wxString> *AddressListLang = NULL;
1423 std::map<int, wxString> *AddressListAltID = NULL;
1424 std::map<int, wxString> *AddressListPID = NULL;
1425 std::map<int, wxString> *AddressListTokens = NULL;
1426 std::map<int, wxString> *AddressListGeo = NULL;
1427 std::map<int, wxString> *AddressListTimezone = NULL;
1428 std::map<int, wxString> *AddressListType = NULL;
1429 std::map<int, wxString> *AddressListMediatype = NULL;
1430 std::map<int, int> *AddressListPref = NULL;
1434 AddressList = &GeneralAddressList;
1435 AddressListTown = &GeneralAddressListTown;
1436 AddressListCounty = &GeneralAddressListCounty;
1437 AddressListPostCode = &GeneralAddressListPostCode;
1438 AddressListCountry = &GeneralAddressListCountry;
1439 AddressListLabel = &GeneralAddressListLabel;
1440 AddressListLang = &GeneralAddressListLang;
1441 AddressListAltID = &GeneralAddressListAltID;
1442 AddressListPID = &GeneralAddressListPID;
1443 AddressListTokens = &GeneralAddressListTokens;
1444 AddressListGeo = &GeneralAddressListGeo;
1445 AddressListTimezone = &GeneralAddressListTimezone;
1446 AddressListType = &GeneralAddressListType;
1447 AddressListMediatype = &GeneralAddressListMediatype;
1448 AddressListPref = &GeneralAddressListPref;
1451 AddressList = &HomeAddressList;
1452 AddressListTown = &HomeAddressListTown;
1453 AddressListCounty = &HomeAddressListCounty;
1454 AddressListPostCode = &HomeAddressListPostCode;
1455 AddressListCountry = &HomeAddressListCountry;
1456 AddressListLabel = &HomeAddressListLabel;
1457 AddressListLang = &HomeAddressListLang;
1458 AddressListAltID = &HomeAddressListAltID;
1459 AddressListPID = &HomeAddressListPID;
1460 AddressListTokens = &HomeAddressListTokens;
1461 AddressListGeo = &HomeAddressListGeo;
1462 AddressListTimezone = &HomeAddressListTimezone;
1463 AddressListType = &HomeAddressListType;
1464 AddressListMediatype = &HomeAddressListMediatype;
1465 AddressListPref = &HomeAddressListPref;
1468 AddressList = &BusinessAddressList;
1469 AddressListTown = &BusinessAddressListTown;
1470 AddressListCounty = &BusinessAddressListCounty;
1471 AddressListPostCode = &BusinessAddressListPostCode;
1472 AddressListCountry = &BusinessAddressListCountry;
1473 AddressListLabel = &BusinessAddressListLabel;
1474 AddressListLang = &BusinessAddressListLang;
1475 AddressListAltID = &BusinessAddressListAltID;
1476 AddressListPID = &BusinessAddressListPID;
1477 AddressListTokens = &BusinessAddressListTokens;
1478 AddressListGeo = &BusinessAddressListGeo;
1479 AddressListTimezone = &BusinessAddressListTimezone;
1480 AddressListType = &BusinessAddressListType;
1481 AddressListMediatype = &BusinessAddressListMediatype;
1482 AddressListPref = &BusinessAddressListPref;
1488 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1489 intiter != SplitPoints.end(); ++intiter){
1491 SLiter = SplitLength.find(intiter->first);
1493 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1495 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1496 PropertyName = PropertyElement.GetNextToken();
1497 PropertyValue = PropertyElement.GetNextToken();
1499 intPrevValue = intiter->second;
1501 CaptureString(&PropertyValue, FALSE);
1503 // Process properties.
1505 if (PropertyName == wxT("LABEL")){
1507 AddressListLabel->erase(*AddressCount);
1508 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1510 } else if (PropertyName == wxT("LANGUAGE")){
1512 AddressListLang->erase(*AddressCount);
1513 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1515 } else if (PropertyName == wxT("ALTID")){
1517 AddressListAltID->erase(*AddressCount);
1518 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1520 } else if (PropertyName == wxT("PID")){
1522 AddressListPID->erase(*AddressCount);
1523 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1525 } else if (PropertyName == wxT("GEO")){
1527 AddressListGeo->erase(*AddressCount);
1528 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1530 } else if (PropertyName == wxT("TZ")){
1532 AddressListTimezone->erase(*AddressCount);
1533 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1535 } else if (PropertyName == wxT("MEDIATYPE")){
1537 AddressListMediatype->erase(*AddressCount);
1538 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1540 } else if (PropertyName == wxT("PREF")){
1542 int PriorityNumber = 0;
1543 bool ValidNumber = TRUE;
1546 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1549 catch(std::invalid_argument &e){
1550 ValidNumber = FALSE;
1553 if (ValidNumber == TRUE){
1555 AddressListPref->erase(*AddressCount);
1556 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1562 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1564 if (FirstToken == TRUE){
1566 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1571 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1581 // Split the address.
1583 //std::map<int, int>::iterator SLiter;
1584 intPropertyLen = PropertySeg2.Len();
1585 SplitPoints.clear();
1586 SplitLength.clear();
1591 for (int i = 0; i <= intPropertyLen; i++){
1595 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1598 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1600 if (intSplitsFound == 6){
1602 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1607 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1617 // Split the data into several parts.
1619 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1620 intiter != SplitPoints.end(); ++intiter){
1622 if (intiter->first == 1){
1624 // Deal with PO Box.
1626 SLiter = SplitLength.find(1);
1628 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1629 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1630 intPrevValue = intiter->second;
1632 } else if (intiter->first == 2){
1634 // Deal with extended address.
1636 SLiter = SplitLength.find(2);
1638 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1639 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1640 intPrevValue = intiter->second;
1642 } else if (intiter->first == 3){
1644 // Deal with street address.
1646 SLiter = SplitLength.find(3);
1648 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1649 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1650 intPrevValue = intiter->second;
1652 } else if (intiter->first == 4){
1654 // Deal with locality
1656 SLiter = SplitLength.find(4);
1658 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1659 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1660 intPrevValue = intiter->second;
1662 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1664 } else if (intiter->first == 5){
1666 // Deal with region.
1668 SLiter = SplitLength.find(5);
1670 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1671 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1672 intPrevValue = intiter->second;
1674 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1676 } else if (intiter->first == 6){
1678 // Deal with post code.
1680 SLiter = SplitLength.find(6);
1682 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1683 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1684 intPrevValue = intiter->second;
1686 // Deal with country.
1688 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1689 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1697 // Add the data to the General/Home/Work address variables.
1699 CaptureString(&AddressStreet, FALSE);
1700 CaptureString(&AddressLocality, FALSE);
1701 CaptureString(&AddressRegion, FALSE);
1702 CaptureString(&AddressPostalCode, FALSE);
1703 CaptureString(&AddressCountry, FALSE);
1705 if (!PropertyTokens.IsEmpty()){
1707 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1711 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1712 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1713 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1714 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1715 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1719 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1722 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1725 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1729 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1733 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1735 std::map<int, int> SplitPoints;
1736 std::map<int, int> SplitLength;
1738 int intPrevValue = 7;
1741 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1745 PropertyType PropType = PROPERTY_NONE;
1747 // Look for type before continuing.
1749 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1751 std::map<int, wxString> *EmailList = NULL;
1752 std::map<int, wxString> *EmailListType = NULL;
1753 std::map<int, wxString> *EmailListAltID = NULL;
1754 std::map<int, wxString> *EmailListPID = NULL;
1755 std::map<int, wxString> *EmailListTokens = NULL;
1756 std::map<int, int> *EmailListPref = NULL;
1760 EmailList = &GeneralEmailList;
1761 EmailListType = &GeneralEmailListType;
1762 EmailListAltID = &GeneralEmailListAltID;
1763 EmailListPID = &GeneralEmailListPID;
1764 EmailListTokens = &GeneralEmailListTokens;
1765 EmailListPref = &GeneralEmailListPref;
1768 EmailList = &HomeEmailList;
1769 EmailListType = &HomeEmailListType;
1770 EmailListAltID = &HomeEmailListAltID;
1771 EmailListPID = &HomeEmailListPID;
1772 EmailListTokens = &HomeEmailListTokens;
1773 EmailListPref = &HomeEmailListPref;
1776 EmailList = &BusinessEmailList;
1777 EmailListType = &BusinessEmailListType;
1778 EmailListAltID = &BusinessEmailListAltID;
1779 EmailListPID = &BusinessEmailListPID;
1780 EmailListTokens = &BusinessEmailListTokens;
1781 EmailListPref = &BusinessEmailListPref;
1787 std::map<int,int>::iterator SLiter;
1788 wxString PropertyData;
1789 wxString PropertyName;
1790 wxString PropertyValue;
1791 wxString PropertyTokens;
1792 bool FirstToken = TRUE;
1794 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1795 intiter != SplitPoints.end(); ++intiter){
1797 SLiter = SplitLength.find(intiter->first);
1799 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1801 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1802 PropertyName = PropertyElement.GetNextToken();
1803 PropertyValue = PropertyElement.GetNextToken();
1805 intPrevValue = intiter->second;
1807 CaptureString(&PropertyValue, FALSE);
1809 // Process properties.
1811 if (PropertyName == wxT("ALTID")){
1813 EmailListAltID->erase(*EmailCount);
1814 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1816 } else if (PropertyName == wxT("PID")){
1818 EmailListPID->erase(*EmailCount);
1819 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1821 } else if (PropertyName == wxT("PREF")){
1823 int PriorityNumber = 0;
1824 bool ValidNumber = TRUE;
1827 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1830 catch(std::invalid_argument &e){
1831 ValidNumber = FALSE;
1834 if (ValidNumber == TRUE){
1836 EmailListPref->erase(*EmailCount);
1837 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1843 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1845 if (FirstToken == TRUE){
1847 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1852 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1862 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1864 // Add the name token data.
1866 if (!PropertyTokens.IsEmpty()){
1868 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1875 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1877 std::map<int, int> SplitPoints;
1878 std::map<int, int> SplitLength;
1880 int intPrevValue = 6;
1883 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1887 PropertyType PropType = PROPERTY_NONE;
1889 // Look for type before continuing.
1891 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1893 std::map<int, wxString> *IMList = NULL;
1894 std::map<int, wxString> *IMListType = NULL;
1895 std::map<int, wxString> *IMListAltID = NULL;
1896 std::map<int, wxString> *IMListPID = NULL;
1897 std::map<int, wxString> *IMListTokens = NULL;
1898 std::map<int, wxString> *IMListMediatype = NULL;
1899 std::map<int, int> *IMListPref = NULL;
1903 IMList = &GeneralIMList;
1904 IMListType = &GeneralIMListType;
1905 IMListAltID = &GeneralIMListAltID;
1906 IMListPID = &GeneralIMListPID;
1907 IMListTokens = &GeneralIMListTokens;
1908 IMListMediatype = &GeneralIMListMediatype;
1909 IMListPref = &GeneralIMListPref;
1912 IMList = &HomeIMList;
1913 IMListType = &HomeIMListType;
1914 IMListAltID = &HomeIMListAltID;
1915 IMListPID = &HomeIMListPID;
1916 IMListTokens = &HomeIMListTokens;
1917 IMListMediatype = &HomeIMListMediatype;
1918 IMListPref = &HomeIMListPref;
1921 IMList = &BusinessIMList;
1922 IMListType = &BusinessIMListType;
1923 IMListAltID = &BusinessIMListAltID;
1924 IMListPID = &BusinessIMListPID;
1925 IMListTokens = &BusinessIMListTokens;
1926 IMListMediatype = &BusinessIMListMediatype;
1927 IMListPref = &BusinessIMListPref;
1933 std::map<int,int>::iterator SLiter;
1934 wxString PropertyData;
1935 wxString PropertyName;
1936 wxString PropertyValue;
1937 wxString PropertyTokens;
1938 bool FirstToken = TRUE;
1940 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1941 intiter != SplitPoints.end(); ++intiter){
1943 SLiter = SplitLength.find(intiter->first);
1945 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1947 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1948 PropertyName = PropertyElement.GetNextToken();
1949 PropertyValue = PropertyElement.GetNextToken();
1951 intPrevValue = intiter->second;
1953 CaptureString(&PropertyValue, FALSE);
1955 // Process properties.
1957 if (PropertyName == wxT("ALTID")){
1959 IMListAltID->erase(*IMCount);
1960 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1962 } else if (PropertyName == wxT("PID")){
1964 IMListPID->erase(*IMCount);
1965 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1967 } else if (PropertyName == wxT("MEDIATYPE")){
1969 IMListMediatype->erase(*IMCount);
1970 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1972 } else if (PropertyName == wxT("PREF")){
1974 int PriorityNumber = 0;
1975 bool ValidNumber = TRUE;
1978 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1981 catch(std::invalid_argument &e){
1982 ValidNumber = FALSE;
1985 if (ValidNumber == TRUE){
1987 IMListPref->erase(*IMCount);
1988 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1994 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1996 if (FirstToken == TRUE){
1998 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2003 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2013 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2015 // Add the name token data.
2017 if (!PropertyTokens.IsEmpty()){
2019 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2025 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2027 std::map<int, int> SplitPoints;
2028 std::map<int, int> SplitLength;
2029 std::map<int, int>::iterator SLiter;
2033 PropertyType PropType = PROPERTY_NONE;
2035 // Look for type before continuing.
2038 wxString TelTypeDetail;
2039 wxString PropertyData;
2040 wxString PropertyName;
2041 wxString PropertyValue;
2042 wxString PropertyTokens;
2044 std::map<int,int> TypeSplitPoints;
2045 std::map<int,int> TypeSplitLength;
2046 std::map<int,int>::iterator TSLiter;
2048 int intSplitSize = 0;
2049 int intSplitsFound = 0;
2050 int intSplitPoint = 0;
2052 int intPrevValue = 5;
2054 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2058 // Look for type before continuing.
2060 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2061 intiter != SplitPoints.end(); ++intiter){
2063 SLiter = SplitLength.find(intiter->first);
2065 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2067 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2068 PropertyName = PropertyElement.GetNextToken();
2069 PropertyValue = PropertyElement.GetNextToken();
2071 intPrevValue = intiter->second;
2073 if (PropertyName == wxT("TYPE")){
2075 // Process each value in type and translate each
2078 // Strip out the quotes if they are there.
2080 size_t intPropertyValueLen = PropertyValue.Len();
2082 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2084 PropertyValue.Trim();
2085 PropertyValue.RemoveLast();
2089 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2091 PropertyValue.Remove(0, 1);
2095 TelTypeDetail = PropertyValue;
2101 for (int i = 0; i <= intPropertyValueLen; i++){
2105 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2107 if (intSplitsFound == 0){
2109 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2110 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2114 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2115 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2128 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2129 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2131 int intTypeSeek = 0;
2133 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2134 typeiter != TypeSplitPoints.end(); ++typeiter){
2136 wxString TypePropertyName;
2138 TSLiter = TypeSplitLength.find(typeiter->first);
2140 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2142 if (intTypeSeek == 0){
2147 TelTypeUI.Append(wxT(","));
2151 if (TypePropertyName == wxT("home")){
2153 PropType = PROPERTY_HOME;
2155 } else if (TypePropertyName == wxT("work")){
2157 PropType = PROPERTY_WORK;
2162 if (TypePropertyName == wxT("text")){
2164 TelTypeUI.Append(_("text"));
2167 } else if (TypePropertyName == wxT("voice")){
2169 TelTypeUI.Append(_("voice"));
2172 } else if (TypePropertyName == wxT("fax")){
2174 TelTypeUI.Append(_("fax"));
2177 } else if (TypePropertyName == wxT("cell")){
2179 TelTypeUI.Append(_("mobile"));
2182 } else if (TypePropertyName == wxT("video")){
2184 TelTypeUI.Append(_("video"));
2187 } else if (TypePropertyName == wxT("pager")){
2189 TelTypeUI.Append(_("pager"));
2192 } else if (TypePropertyName == wxT("textphone")){
2194 TelTypeUI.Append(_("textphone"));
2205 std::map<int, wxString> *TelephoneList = NULL;
2206 std::map<int, wxString> *TelephoneListType = NULL;
2207 std::map<int, wxString> *TelephoneListAltID = NULL;
2208 std::map<int, wxString> *TelephoneListPID = NULL;
2209 std::map<int, wxString> *TelephoneListTokens = NULL;
2210 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2211 std::map<int, int> *TelephoneListPref = NULL;
2215 TelephoneList = &GeneralTelephoneList;
2216 TelephoneListType = &GeneralTelephoneListType;
2217 TelephoneListAltID = &GeneralTelephoneListAltID;
2218 TelephoneListPID = &GeneralTelephoneListPID;
2219 TelephoneListTokens = &GeneralTelephoneListTokens;
2220 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2221 TelephoneListPref = &GeneralTelephoneListPref;
2224 TelephoneList = &HomeTelephoneList;
2225 TelephoneListType = &HomeTelephoneListType;
2226 TelephoneListAltID = &HomeTelephoneListAltID;
2227 TelephoneListPID = &HomeTelephoneListPID;
2228 TelephoneListTokens = &HomeTelephoneListTokens;
2229 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2230 TelephoneListPref = &HomeTelephoneListPref;
2233 TelephoneList = &BusinessTelephoneList;
2234 TelephoneListType = &BusinessTelephoneListType;
2235 TelephoneListAltID = &BusinessTelephoneListAltID;
2236 TelephoneListPID = &BusinessTelephoneListPID;
2237 TelephoneListTokens = &BusinessTelephoneListTokens;
2238 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2239 TelephoneListPref = &BusinessTelephoneListPref;
2243 // Process the properties.
2245 bool FirstToken = TRUE;
2248 SplitPoints.clear();
2249 SplitLength.clear();
2251 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2255 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2256 intiter != SplitPoints.end(); ++intiter){
2258 SLiter = SplitLength.find(intiter->first);
2260 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2262 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2263 PropertyName = PropertyElement.GetNextToken();
2264 PropertyValue = PropertyElement.GetNextToken();
2266 intPrevValue = intiter->second;
2268 CaptureString(&PropertyValue, FALSE);
2270 // Process properties.
2272 if (PropertyName == wxT("ALTID")){
2274 TelephoneListAltID->erase(*TelephoneCount);
2275 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2277 } else if (PropertyName == wxT("PID")){
2279 TelephoneListPID->erase(*TelephoneCount);
2280 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2282 } else if (PropertyName == wxT("PREF")){
2284 int PriorityNumber = 0;
2285 bool ValidNumber = TRUE;
2288 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2291 catch(std::invalid_argument &e){
2292 ValidNumber = FALSE;
2295 if (ValidNumber == TRUE){
2297 TelephoneListPref->erase(*TelephoneCount);
2298 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2304 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2306 if (FirstToken == TRUE){
2308 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2313 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2323 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2324 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2326 // Add the name token data.
2328 if (!PropertyTokens.IsEmpty()){
2330 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2336 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2338 std::map<int, int> SplitPoints;
2339 std::map<int, int> SplitLength;
2341 int intPrevValue = 6;
2344 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2348 PropertyType PropType = PROPERTY_NONE;
2350 // Look for type before continuing.
2352 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2354 std::map<int, wxString> *LanguageList = NULL;
2355 std::map<int, wxString> *LanguageListType = NULL;
2356 std::map<int, wxString> *LanguageListAltID = NULL;
2357 std::map<int, wxString> *LanguageListPID = NULL;
2358 std::map<int, wxString> *LanguageListTokens = NULL;
2359 std::map<int, int> *LanguageListPref = NULL;
2363 LanguageList = &GeneralLanguageList;
2364 LanguageListType = &GeneralLanguageListType;
2365 LanguageListAltID = &GeneralLanguageListAltID;
2366 LanguageListPID = &GeneralLanguageListPID;
2367 LanguageListTokens = &GeneralLanguageListTokens;
2368 LanguageListPref = &GeneralLanguageListPref;
2371 LanguageList = &HomeLanguageList;
2372 LanguageListType = &HomeLanguageListType;
2373 LanguageListAltID = &HomeLanguageListAltID;
2374 LanguageListPID = &HomeLanguageListPID;
2375 LanguageListTokens = &HomeLanguageListTokens;
2376 LanguageListPref = &HomeLanguageListPref;
2379 LanguageList = &BusinessLanguageList;
2380 LanguageListType = &BusinessLanguageListType;
2381 LanguageListAltID = &BusinessLanguageListAltID;
2382 LanguageListPID = &BusinessLanguageListPID;
2383 LanguageListTokens = &BusinessLanguageListTokens;
2384 LanguageListPref = &BusinessLanguageListPref;
2390 std::map<int,int>::iterator SLiter;
2391 wxString PropertyData;
2392 wxString PropertyName;
2393 wxString PropertyValue;
2394 wxString PropertyTokens;
2395 bool FirstToken = TRUE;
2397 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2398 intiter != SplitPoints.end(); ++intiter){
2400 SLiter = SplitLength.find(intiter->first);
2402 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2404 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2405 PropertyName = PropertyElement.GetNextToken();
2406 PropertyValue = PropertyElement.GetNextToken();
2408 intPrevValue = intiter->second;
2410 CaptureString(&PropertyValue, FALSE);
2412 // Process properties.
2414 if (PropertyName == wxT("ALTID")){
2416 LanguageListAltID->erase(*LanguageCount);
2417 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2419 } else if (PropertyName == wxT("PID")){
2421 LanguageListPID->erase(*LanguageCount);
2422 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2424 } else if (PropertyName == wxT("PREF")){
2426 int PriorityNumber = 0;
2427 bool ValidNumber = TRUE;
2430 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2433 catch(std::invalid_argument &e){
2434 ValidNumber = FALSE;
2437 if (ValidNumber == TRUE){
2439 LanguageListPref->erase(*LanguageCount);
2440 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2446 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2448 if (FirstToken == TRUE){
2450 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2455 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2465 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2467 // Add the name token data.
2469 if (!PropertyTokens.IsEmpty()){
2471 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2477 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2479 std::map<int, int> SplitPoints;
2480 std::map<int, int> SplitLength;
2482 int intPrevValue = 5;
2485 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2489 PropertyType PropType = PROPERTY_NONE;
2491 // Look for type before continuing.
2493 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2495 std::map<int, wxString> *GeopositionList = NULL;
2496 std::map<int, wxString> *GeopositionListType = NULL;
2497 std::map<int, wxString> *GeopositionListAltID = NULL;
2498 std::map<int, wxString> *GeopositionListPID = NULL;
2499 std::map<int, wxString> *GeopositionListTokens = NULL;
2500 std::map<int, wxString> *GeopositionListMediatype = NULL;
2501 std::map<int, int> *GeopositionListPref = NULL;
2505 GeopositionList = &GeneralGeographyList;
2506 GeopositionListType = &GeneralGeographyListType;
2507 GeopositionListAltID = &GeneralGeographyListAltID;
2508 GeopositionListPID = &GeneralGeographyListPID;
2509 GeopositionListTokens = &GeneralGeographyListTokens;
2510 GeopositionListMediatype = &GeneralGeographyListMediatype;
2511 GeopositionListPref = &GeneralGeographyListPref;
2514 GeopositionList = &HomeGeographyList;
2515 GeopositionListType = &HomeGeographyListType;
2516 GeopositionListAltID = &HomeGeographyListAltID;
2517 GeopositionListPID = &HomeGeographyListPID;
2518 GeopositionListTokens = &HomeGeographyListTokens;
2519 GeopositionListMediatype = &HomeGeographyListMediatype;
2520 GeopositionListPref = &HomeGeographyListPref;
2523 GeopositionList = &BusinessGeographyList;
2524 GeopositionListType = &BusinessGeographyListType;
2525 GeopositionListAltID = &BusinessGeographyListAltID;
2526 GeopositionListPID = &BusinessGeographyListPID;
2527 GeopositionListTokens = &BusinessGeographyListTokens;
2528 GeopositionListMediatype = &BusinessGeographyListMediatype;
2529 GeopositionListPref = &BusinessGeographyListPref;
2535 std::map<int,int>::iterator SLiter;
2536 wxString PropertyData;
2537 wxString PropertyName;
2538 wxString PropertyValue;
2539 wxString PropertyTokens;
2540 bool FirstToken = TRUE;
2542 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2543 intiter != SplitPoints.end(); ++intiter){
2545 SLiter = SplitLength.find(intiter->first);
2547 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2549 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2550 PropertyName = PropertyElement.GetNextToken();
2551 PropertyValue = PropertyElement.GetNextToken();
2553 intPrevValue = intiter->second;
2555 CaptureString(&PropertyValue, FALSE);
2557 // Process properties.
2559 if (PropertyName == wxT("ALTID")){
2561 GeopositionListAltID->erase(*GeographicCount);
2562 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2564 } else if (PropertyName == wxT("PID")){
2566 GeopositionListPID->erase(*GeographicCount);
2567 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2569 } else if (PropertyName == wxT("MEDIATYPE")){
2571 GeopositionListMediatype->erase(*GeographicCount);
2572 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2574 } else if (PropertyName == wxT("PREF")){
2576 int PriorityNumber = 0;
2577 bool ValidNumber = TRUE;
2580 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2583 catch(std::invalid_argument &e){
2584 ValidNumber = FALSE;
2587 if (ValidNumber == TRUE){
2589 GeopositionListPref->erase(*GeographicCount);
2590 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2596 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2598 if (FirstToken == TRUE){
2600 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2605 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2615 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2617 // Add the name token data.
2619 if (!PropertyTokens.IsEmpty()){
2621 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2627 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2629 size_t intPropertyLen = PropertySeg1.Len();
2630 std::map<int, int> SplitPoints;
2631 std::map<int, int> SplitLength;
2632 std::map<int, int>::iterator SLiter;
2633 wxString PropertyData;
2634 wxString PropertyName;
2635 wxString PropertyValue;
2636 wxString PropertyTokens;
2637 wxString RelatedType;
2638 wxString RelatedTypeOriginal;
2639 wxString RelatedName;
2640 bool FirstToken = TRUE;
2641 int intSplitsFound = 0;
2642 int intSplitSize = 0;
2643 int intPrevValue = 9;
2647 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2651 // Look for type before continuing.
2653 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2654 intiter != SplitPoints.end(); ++intiter){
2656 SLiter = SplitLength.find(intiter->first);
2658 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2660 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2661 PropertyName = PropertyElement.GetNextToken();
2662 PropertyValue = PropertyElement.GetNextToken();
2664 intPrevValue = intiter->second;
2668 RelatedTypeOriginal = PropertyValue;
2670 if (PropertyName == wxT("TYPE")){
2672 if (PropertyValue == wxT("contact")){
2674 RelatedType = _("Contact");
2676 } else if (PropertyValue == wxT("acquaintance")){
2678 RelatedType = _("Acquaintance");
2680 } else if (PropertyValue == wxT("friend")){
2682 RelatedType = _("Friend");
2684 } else if (PropertyValue == wxT("met")){
2686 RelatedType = _("Met");
2688 } else if (PropertyValue == wxT("co-worker")){
2690 RelatedType = _("Co-worker");
2692 } else if (PropertyValue == wxT("colleague")){
2694 RelatedType = _("Colleague");
2696 } else if (PropertyValue == wxT("co-resident")){
2698 RelatedType = _("Co-resident");
2700 } else if (PropertyValue == wxT("neighbor")){
2702 RelatedType = _("Neighbour");
2704 } else if (PropertyValue == wxT("child")){
2706 RelatedType = _("Child");
2708 } else if (PropertyValue == wxT("parent")){
2710 RelatedType = _("Parent");
2712 } else if (PropertyValue == wxT("sibling")){
2714 RelatedType = _("Sibling");
2716 } else if (PropertyValue == wxT("spouse")){
2718 RelatedType = _("Spouse");
2720 } else if (PropertyValue == wxT("kin")){
2722 RelatedType = _("Kin");
2724 } else if (PropertyValue == wxT("muse")){
2726 RelatedType = _("Muse");
2728 } else if (PropertyValue == wxT("crush")){
2730 RelatedType = _("Crush");
2732 } else if (PropertyValue == wxT("date")){
2734 RelatedType = _("Date");
2736 } else if (PropertyValue == wxT("sweetheart")){
2738 RelatedType = _("Sweetheart");
2740 } else if (PropertyValue == wxT("me")){
2742 RelatedType = _("Me");
2744 } else if (PropertyValue == wxT("agent")){
2746 RelatedType = _("Agent");
2748 } else if (PropertyValue == wxT("emergency")){
2750 RelatedType = _("Emergency");
2754 RelatedType = PropertyValue;
2764 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2765 intiter != SplitPoints.end(); ++intiter){
2767 SLiter = SplitLength.find(intiter->first);
2769 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2771 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2772 PropertyName = PropertyElement.GetNextToken();
2773 PropertyValue = PropertyElement.GetNextToken();
2775 intPrevValue = intiter->second;
2777 // Process properties.
2779 size_t intPropertyValueLen = PropertyValue.Len();
2781 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2783 PropertyValue.Trim();
2784 PropertyValue.RemoveLast();
2788 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2790 PropertyValue.Remove(0, 1);
2794 CaptureString(&PropertyValue, FALSE);
2796 if (PropertyName == wxT("ALTID")){
2798 GeneralRelatedListAltID.erase(*RelatedCount);
2799 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2801 } else if (PropertyName == wxT("PID")){
2803 GeneralRelatedListPID.erase(*RelatedCount);
2804 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2806 } else if (PropertyName == wxT("PREF")){
2808 int PriorityNumber = 0;
2809 bool ValidNumber = TRUE;
2812 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2815 catch(std::invalid_argument &e){
2816 ValidNumber = FALSE;
2819 if (ValidNumber == TRUE){
2821 GeneralRelatedListPref.erase(*RelatedCount);
2822 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2826 } else if (PropertyName == wxT("LANGUAGE")){
2828 GeneralRelatedListLanguage.erase(*RelatedCount);
2829 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2831 } else if (PropertyName != wxT("TYPE")) {
2833 // Something else we don't know about so append
2834 // to the tokens variable.
2836 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2838 if (FirstToken == TRUE){
2840 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2845 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2855 // Add the data to the General/Home/Work address variables.
2857 GeneralRelatedList.erase(*RelatedCount);
2858 GeneralRelatedListRelType.erase(*RelatedCount);
2859 GeneralRelatedListType.erase(*RelatedCount);
2860 GeneralRelatedListTokens.erase(*RelatedCount);
2861 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2862 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2863 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2864 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2868 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2870 std::map<int, int> SplitPoints;
2871 std::map<int, int> SplitLength;
2872 std::map<int, int>::iterator SLiter;
2873 wxString PropertyData;
2874 wxString PropertyName;
2875 wxString PropertyValue;
2876 wxString PropertyTokens;
2877 bool FirstToken = TRUE;
2878 int intPrevValue = 5;
2883 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2887 PropertyType PropType = PROPERTY_NONE;
2889 // Look for type before continuing.
2891 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2893 // Setup the pointers.
2895 std::map<int, wxString> *WebsiteList = NULL;
2896 std::map<int, wxString> *WebsiteListAltID = NULL;
2897 std::map<int, wxString> *WebsiteListPID = NULL;
2898 std::map<int, wxString> *WebsiteListType = NULL;
2899 std::map<int, wxString> *WebsiteListTokens = NULL;
2900 std::map<int, wxString> *WebsiteListMediatype = NULL;
2901 std::map<int, int> *WebsiteListPref = NULL;
2903 // Setup blank lines for later on.
2907 WebsiteList = &GeneralWebsiteList;
2908 WebsiteListType = &GeneralWebsiteListType;
2909 WebsiteListAltID = &GeneralWebsiteListAltID;
2910 WebsiteListPID = &GeneralWebsiteListPID;
2911 WebsiteListTokens = &GeneralWebsiteListTokens;
2912 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2913 WebsiteListPref = &GeneralWebsiteListPref;
2916 WebsiteList = &HomeWebsiteList;
2917 WebsiteListType = &HomeWebsiteListType;
2918 WebsiteListAltID = &HomeWebsiteListAltID;
2919 WebsiteListPID = &HomeWebsiteListPID;
2920 WebsiteListTokens = &HomeWebsiteListTokens;
2921 WebsiteListMediatype = &HomeWebsiteListMediatype;
2922 WebsiteListPref = &HomeWebsiteListPref;
2925 WebsiteList = &BusinessWebsiteList;
2926 WebsiteListType = &BusinessWebsiteListType;
2927 WebsiteListAltID = &BusinessWebsiteListAltID;
2928 WebsiteListPID = &BusinessWebsiteListPID;
2929 WebsiteListTokens = &BusinessWebsiteListTokens;
2930 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2931 WebsiteListPref = &BusinessWebsiteListPref;
2937 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2938 intiter != SplitPoints.end(); ++intiter){
2940 SLiter = SplitLength.find(intiter->first);
2942 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2944 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2945 PropertyName = PropertyElement.GetNextToken();
2946 PropertyValue = PropertyElement.GetNextToken();
2948 intPrevValue = intiter->second;
2950 // Process properties.
2952 size_t intPropertyValueLen = PropertyValue.Len();
2954 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2956 PropertyValue.Trim();
2957 PropertyValue.RemoveLast();
2961 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2963 PropertyValue.Remove(0, 1);
2967 CaptureString(&PropertyValue, FALSE);
2969 if (PropertyName == wxT("ALTID")){
2971 WebsiteListAltID->erase(*URLCount);
2972 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2974 } else if (PropertyName == wxT("PID")){
2976 WebsiteListPID->erase(*URLCount);
2977 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2979 } else if (PropertyName == wxT("PREF")){
2981 int PriorityNumber = 0;
2982 bool ValidNumber = TRUE;
2985 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2988 catch(std::invalid_argument &e){
2989 ValidNumber = FALSE;
2992 if (ValidNumber == TRUE){
2994 WebsiteListPref->erase(*URLCount);
2995 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2999 } else if (PropertyName == wxT("MEDIATYPE")){
3001 WebsiteListMediatype->erase(*URLCount);
3002 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3006 // Something else we don't know about so append
3007 // to the tokens variable.
3009 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3011 if (FirstToken == TRUE){
3013 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3018 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3028 // Add the data to the General/Home/Work address variables.
3030 CaptureString(&PropertySeg2, FALSE);
3032 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3034 if (!PropertyTokens.IsEmpty()){
3036 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3042 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3044 std::map<int, int> SplitPoints;
3045 std::map<int, int> SplitLength;
3046 std::map<int, int>::iterator SLiter;
3047 wxString PropertyData;
3048 wxString PropertyName;
3049 wxString PropertyValue;
3050 wxString PropertyTokens;
3051 bool FirstToken = TRUE;
3052 int intPrevValue = 7;
3057 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3061 PropertyType PropType = PROPERTY_NONE;
3063 // Look for type before continuing.
3065 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3067 // Setup the pointers.
3069 std::map<int, wxString> *TitleList = NULL;
3070 std::map<int, wxString> *TitleListAltID = NULL;
3071 std::map<int, wxString> *TitleListPID = NULL;
3072 std::map<int, wxString> *TitleListType = NULL;
3073 std::map<int, wxString> *TitleListTokens = NULL;
3074 std::map<int, wxString> *TitleListLanguage = NULL;
3075 std::map<int, int> *TitleListPref = NULL;
3077 // Setup blank lines for later on.
3081 TitleList = &GeneralTitleList;
3082 TitleListType = &GeneralTitleListType;
3083 TitleListAltID = &GeneralTitleListAltID;
3084 TitleListPID = &GeneralTitleListPID;
3085 TitleListTokens = &GeneralTitleListTokens;
3086 TitleListLanguage = &GeneralTitleListLanguage;
3087 TitleListPref = &GeneralTitleListPref;
3090 TitleList = &HomeTitleList;
3091 TitleListType = &HomeTitleListType;
3092 TitleListAltID = &HomeTitleListAltID;
3093 TitleListPID = &HomeTitleListPID;
3094 TitleListTokens = &HomeTitleListTokens;
3095 TitleListLanguage = &HomeTitleListLanguage;
3096 TitleListPref = &HomeTitleListPref;
3099 TitleList = &BusinessTitleList;
3100 TitleListType = &BusinessTitleListType;
3101 TitleListAltID = &BusinessTitleListAltID;
3102 TitleListPID = &BusinessTitleListPID;
3103 TitleListTokens = &BusinessTitleListTokens;
3104 TitleListLanguage = &BusinessTitleListLanguage;
3105 TitleListPref = &BusinessTitleListPref;
3111 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3112 intiter != SplitPoints.end(); ++intiter){
3114 SLiter = SplitLength.find(intiter->first);
3116 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3118 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3119 PropertyName = PropertyElement.GetNextToken();
3120 PropertyValue = PropertyElement.GetNextToken();
3122 intPrevValue = intiter->second;
3124 // Process properties.
3126 size_t intPropertyValueLen = PropertyValue.Len();
3128 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3130 PropertyValue.Trim();
3131 PropertyValue.RemoveLast();
3135 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3137 PropertyValue.Remove(0, 1);
3141 CaptureString(&PropertyValue, FALSE);
3143 if (PropertyName == wxT("ALTID")){
3145 TitleListAltID->erase(*TitleCount);
3146 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3148 } else if (PropertyName == wxT("PID")){
3150 TitleListPID->erase(*TitleCount);
3151 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3153 } else if (PropertyName == wxT("PREF")){
3155 int PriorityNumber = 0;
3156 bool ValidNumber = TRUE;
3159 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3162 catch(std::invalid_argument &e){
3163 ValidNumber = FALSE;
3166 if (ValidNumber == TRUE){
3168 TitleListPref->erase(*TitleCount);
3169 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3173 } else if (PropertyName == wxT("LANGUAGE")){
3175 TitleListLanguage->erase(*TitleCount);
3176 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3180 // Something else we don't know about so append
3181 // to the tokens variable.
3183 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3185 if (FirstToken == TRUE){
3187 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3192 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3202 // Add the data to the General/Home/Work address variables.
3204 CaptureString(&PropertySeg2, FALSE);
3206 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3208 if (!PropertyTokens.IsEmpty()){
3210 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3216 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3218 std::map<int, int> SplitPoints;
3219 std::map<int, int> SplitLength;
3220 std::map<int, int>::iterator SLiter;
3221 wxString PropertyData;
3222 wxString PropertyName;
3223 wxString PropertyValue;
3224 wxString PropertyTokens;
3225 bool FirstToken = TRUE;
3226 int intPrevValue = 6;
3231 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3235 PropertyType PropType = PROPERTY_NONE;
3237 // Look for type before continuing.
3239 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3241 // Setup the pointers.
3243 std::map<int, wxString> *RoleList = NULL;
3244 std::map<int, wxString> *RoleListAltID = NULL;
3245 std::map<int, wxString> *RoleListPID = NULL;
3246 std::map<int, wxString> *RoleListType = NULL;
3247 std::map<int, wxString> *RoleListTokens = NULL;
3248 std::map<int, wxString> *RoleListLanguage = NULL;
3249 std::map<int, int> *RoleListPref = NULL;
3251 // Setup blank lines for later on.
3255 RoleList = &GeneralRoleList;
3256 RoleListType = &GeneralRoleListType;
3257 RoleListAltID = &GeneralRoleListAltID;
3258 RoleListPID = &GeneralRoleListPID;
3259 RoleListTokens = &GeneralRoleListTokens;
3260 RoleListLanguage = &GeneralRoleListLanguage;
3261 RoleListPref = &GeneralRoleListPref;
3264 RoleList = &HomeRoleList;
3265 RoleListType = &HomeRoleListType;
3266 RoleListAltID = &HomeRoleListAltID;
3267 RoleListPID = &HomeRoleListPID;
3268 RoleListTokens = &HomeRoleListTokens;
3269 RoleListLanguage = &HomeRoleListLanguage;
3270 RoleListPref = &HomeRoleListPref;
3273 RoleList = &BusinessRoleList;
3274 RoleListType = &BusinessRoleListType;
3275 RoleListAltID = &BusinessRoleListAltID;
3276 RoleListPID = &BusinessRoleListPID;
3277 RoleListTokens = &BusinessRoleListTokens;
3278 RoleListLanguage = &BusinessRoleListLanguage;
3279 RoleListPref = &BusinessRoleListPref;
3285 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3286 intiter != SplitPoints.end(); ++intiter){
3288 SLiter = SplitLength.find(intiter->first);
3290 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3292 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3293 PropertyName = PropertyElement.GetNextToken();
3294 PropertyValue = PropertyElement.GetNextToken();
3296 intPrevValue = intiter->second;
3298 // Process properties.
3300 size_t intPropertyValueLen = PropertyValue.Len();
3302 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3304 PropertyValue.Trim();
3305 PropertyValue.RemoveLast();
3309 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3311 PropertyValue.Remove(0, 1);
3315 CaptureString(&PropertyValue, FALSE);
3317 if (PropertyName == wxT("ALTID")){
3319 RoleListAltID->erase(*RoleCount);
3320 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3322 } else if (PropertyName == wxT("PID")){
3324 RoleListPID->erase(*RoleCount);
3325 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3327 } else if (PropertyName == wxT("PREF")){
3329 int PriorityNumber = 0;
3330 bool ValidNumber = TRUE;
3333 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3336 catch(std::invalid_argument &e){
3337 ValidNumber = FALSE;
3340 if (ValidNumber == TRUE){
3342 RoleListPref->erase(*RoleCount);
3343 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3347 } else if (PropertyName == wxT("LANGUAGE")){
3349 RoleListLanguage->erase(*RoleCount);
3350 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3354 // Something else we don't know about so append
3355 // to the tokens variable.
3357 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3359 if (FirstToken == TRUE){
3361 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3366 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3376 // Add the data to the General/Home/Work address variables.
3378 CaptureString(&PropertySeg2, FALSE);
3380 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3382 if (!PropertyTokens.IsEmpty()){
3384 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3390 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3392 std::map<int, int> SplitPoints;
3393 std::map<int, int> SplitLength;
3394 std::map<int, int>::iterator SLiter;
3395 wxString PropertyData;
3396 wxString PropertyName;
3397 wxString PropertyValue;
3398 wxString PropertyTokens;
3399 bool FirstToken = TRUE;
3400 int intPrevValue = 5;
3405 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3409 PropertyType PropType = PROPERTY_NONE;
3411 // Look for type before continuing.
3413 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3415 // Setup the pointers.
3417 std::map<int, wxString> *OrganisationsList = NULL;
3418 std::map<int, wxString> *OrganisationsListAltID = NULL;
3419 std::map<int, wxString> *OrganisationsListPID = NULL;
3420 std::map<int, wxString> *OrganisationsListType = NULL;
3421 std::map<int, wxString> *OrganisationsListTokens = NULL;
3422 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3423 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3424 std::map<int, int> *OrganisationsListPref = NULL;
3426 // Setup blank lines for later on.
3430 OrganisationsList = &GeneralOrganisationsList;
3431 OrganisationsListType = &GeneralOrganisationsListType;
3432 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3433 OrganisationsListPID = &GeneralOrganisationsListPID;
3434 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3435 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3436 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3437 OrganisationsListPref = &GeneralOrganisationsListPref;
3440 OrganisationsList = &HomeOrganisationsList;
3441 OrganisationsListType = &HomeOrganisationsListType;
3442 OrganisationsListAltID = &HomeOrganisationsListAltID;
3443 OrganisationsListPID = &HomeOrganisationsListPID;
3444 OrganisationsListTokens = &HomeOrganisationsListTokens;
3445 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3446 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3447 OrganisationsListPref = &HomeOrganisationsListPref;
3450 OrganisationsList = &BusinessOrganisationsList;
3451 OrganisationsListType = &BusinessOrganisationsListType;
3452 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3453 OrganisationsListPID = &BusinessOrganisationsListPID;
3454 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3455 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3456 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3457 OrganisationsListPref = &BusinessOrganisationsListPref;
3463 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3464 intiter != SplitPoints.end(); ++intiter){
3466 SLiter = SplitLength.find(intiter->first);
3468 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3470 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3471 PropertyName = PropertyElement.GetNextToken();
3472 PropertyValue = PropertyElement.GetNextToken();
3474 intPrevValue = intiter->second;
3476 // Process properties.
3478 size_t intPropertyValueLen = PropertyValue.Len();
3480 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3482 PropertyValue.Trim();
3483 PropertyValue.RemoveLast();
3487 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3489 PropertyValue.Remove(0, 1);
3493 CaptureString(&PropertyValue, FALSE);
3495 if (PropertyName == wxT("ALTID")){
3497 OrganisationsListAltID->erase(*OrganisationCount);
3498 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3500 } else if (PropertyName == wxT("PID")){
3502 OrganisationsListPID->erase(*OrganisationCount);
3503 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3505 } else if (PropertyName == wxT("SORT-AS")){
3507 OrganisationsListSortAs->erase(*OrganisationCount);
3508 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3510 } else if (PropertyName == wxT("PREF")){
3512 int PriorityNumber = 0;
3513 bool ValidNumber = TRUE;
3516 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3519 catch(std::invalid_argument &e){
3520 ValidNumber = FALSE;
3523 if (ValidNumber == TRUE){
3525 OrganisationsListPref->erase(*OrganisationCount);
3526 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3530 } else if (PropertyName == wxT("LANGUAGE")){
3532 OrganisationsListLanguage->erase(*OrganisationCount);
3533 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3537 // Something else we don't know about so append
3538 // to the tokens variable.
3540 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3542 if (FirstToken == TRUE){
3544 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3549 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3559 // Add the data to the General/Home/Work address variables.
3561 CaptureString(&PropertySeg2, FALSE);
3563 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3565 if (!PropertyTokens.IsEmpty()){
3567 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3573 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3575 std::map<int, int> SplitPoints;
3576 std::map<int, int> SplitLength;
3577 std::map<int, int>::iterator SLiter;
3578 wxString PropertyData;
3579 wxString PropertyName;
3580 wxString PropertyValue;
3581 wxString PropertyTokens;
3582 bool FirstToken = TRUE;
3583 int intPrevValue = 6;
3588 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3592 PropertyType PropType = PROPERTY_NONE;
3594 // Look for type before continuing.
3596 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3598 // Setup the pointers.
3600 std::map<int, wxString> *NoteList = NULL;
3601 std::map<int, wxString> *NoteListAltID = NULL;
3602 std::map<int, wxString> *NoteListPID = NULL;
3603 std::map<int, wxString> *NoteListType = NULL;
3604 std::map<int, wxString> *NoteListTokens = NULL;
3605 std::map<int, wxString> *NoteListLanguage = NULL;
3606 std::map<int, int> *NoteListPref = NULL;
3608 // Setup blank lines for later on.
3612 NoteList = &GeneralNoteList;
3613 NoteListType = &GeneralNoteListType;
3614 NoteListAltID = &GeneralNoteListAltID;
3615 NoteListPID = &GeneralNoteListPID;
3616 NoteListTokens = &GeneralNoteListTokens;
3617 NoteListLanguage = &GeneralNoteListLanguage;
3618 NoteListPref = &GeneralNoteListPref;
3621 NoteList = &HomeNoteList;
3622 NoteListType = &HomeNoteListType;
3623 NoteListAltID = &HomeNoteListAltID;
3624 NoteListPID = &HomeNoteListPID;
3625 NoteListTokens = &HomeNoteListTokens;
3626 NoteListLanguage = &HomeNoteListLanguage;
3627 NoteListPref = &HomeNoteListPref;
3630 NoteList = &BusinessNoteList;
3631 NoteListType = &BusinessNoteListType;
3632 NoteListAltID = &BusinessNoteListAltID;
3633 NoteListPID = &BusinessNoteListPID;
3634 NoteListTokens = &BusinessNoteListTokens;
3635 NoteListLanguage = &BusinessNoteListLanguage;
3636 NoteListPref = &BusinessNoteListPref;
3642 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3643 intiter != SplitPoints.end(); ++intiter){
3645 SLiter = SplitLength.find(intiter->first);
3647 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3649 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3650 PropertyName = PropertyElement.GetNextToken();
3651 PropertyValue = PropertyElement.GetNextToken();
3653 intPrevValue = intiter->second;
3655 // Process properties.
3657 size_t intPropertyValueLen = PropertyValue.Len();
3659 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3661 PropertyValue.Trim();
3662 PropertyValue.RemoveLast();
3666 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3668 PropertyValue.Remove(0, 1);
3672 CaptureString(&PropertyValue, FALSE);
3674 if (PropertyName == wxT("ALTID")){
3676 NoteListAltID->erase(*NoteCount);
3677 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3679 } else if (PropertyName == wxT("PID")){
3681 NoteListPID->erase(*NoteCount);
3682 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3684 } else if (PropertyName == wxT("PREF")){
3686 int PriorityNumber = 0;
3687 bool ValidNumber = TRUE;
3690 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3693 catch(std::invalid_argument &e){
3694 ValidNumber = FALSE;
3697 if (ValidNumber == TRUE){
3699 NoteListPref->erase(*NoteCount);
3700 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3704 } else if (PropertyName == wxT("LANGUAGE")){
3706 NoteListLanguage->erase(*NoteCount);
3707 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3711 // Something else we don't know about so append
3712 // to the tokens variable.
3714 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3716 if (FirstToken == TRUE){
3718 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3723 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3733 // Add the data to the General/Home/Work address variables.
3735 CaptureString(&PropertySeg2, FALSE);
3737 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3739 if (!PropertyTokens.IsEmpty()){
3741 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3747 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3749 std::map<int, int> SplitPoints;
3750 std::map<int, int> SplitLength;
3751 std::map<int, int>::iterator SLiter;
3752 wxString PropertyData;
3753 wxString PropertyName;
3754 wxString PropertyValue;
3755 wxString PropertyTokens;
3756 bool FirstToken = TRUE;
3757 int intPrevValue = 12;
3762 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3766 PropertyType PropType = PROPERTY_NONE;
3768 // Look for type before continuing.
3770 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3772 // Setup blank lines for later on.
3778 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3781 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3787 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3788 intiter != SplitPoints.end(); ++intiter){
3790 SLiter = SplitLength.find(intiter->first);
3792 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3794 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3795 PropertyName = PropertyElement.GetNextToken();
3796 PropertyValue = PropertyElement.GetNextToken();
3798 intPrevValue = intiter->second;
3800 // Process properties.
3802 size_t intPropertyValueLen = PropertyValue.Len();
3804 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3806 PropertyValue.Trim();
3807 PropertyValue.RemoveLast();
3811 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3813 PropertyValue.Remove(0, 1);
3817 CaptureString(&PropertyValue, FALSE);
3819 if (PropertyName == wxT("ALTID")){
3821 CategoriesListAltID.erase(*CategoryCount);
3822 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3824 } else if (PropertyName == wxT("PID")){
3826 CategoriesListPID.erase(*CategoryCount);
3827 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3829 } else if (PropertyName == wxT("PREF")){
3831 int PriorityNumber = 0;
3832 bool ValidNumber = TRUE;
3835 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3838 catch(std::invalid_argument &e){
3839 ValidNumber = FALSE;
3842 if (ValidNumber == TRUE){
3844 CategoriesListPref.erase(*CategoryCount);
3845 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3849 } else if (PropertyName == wxT("LANGUAGE")){
3851 CategoriesListLanguage.erase(*CategoryCount);
3852 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3856 // Something else we don't know about so append
3857 // to the tokens variable.
3859 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3861 if (FirstToken == TRUE){
3863 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3868 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3878 // Deal with multiple categories.
3880 int intOrigCatCount = *CategoryCount;
3881 bool FirstCategoryProcessed = TRUE;
3882 bool AfterFirstToken = FALSE;
3883 int intSplitSize = 0;
3884 int intSplitsFound = 0;
3885 int intSplitSeek = 0;
3886 int intPropertyLen = PropertySeg2.Len();
3888 SplitPoints.clear();
3889 SplitLength.clear();
3892 for (int i = 0; i <= intPropertyLen; i++){
3894 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3902 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3904 if (AfterFirstToken == TRUE){
3906 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3907 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3911 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3912 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3913 AfterFirstToken = TRUE;
3925 if (SplitPoints.size() > 0){
3927 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3928 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3932 if (SplitPoints.size() == 0){
3934 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3936 if (!PropertyTokens.IsEmpty()){
3938 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3944 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3945 intiter != SplitPoints.end(); ++intiter){
3947 SLiter = SplitLength.find(intiter->first);
3949 intPrevValue = intiter->second;
3951 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3953 // Add the data to the General/Home/Work address variables.
3955 // Trim any whitespace from the start and end.
3957 PropertyData = PropertyData.Trim(FALSE);
3958 PropertyData = PropertyData.Trim(TRUE);
3960 CaptureString(&PropertyData, FALSE);
3962 if (FirstCategoryProcessed == TRUE){
3964 FirstCategoryProcessed = FALSE;
3966 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3968 if (!PropertyTokens.IsEmpty()){
3970 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3980 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3982 if (!PropertyTokens.IsEmpty()){
3984 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3990 // Copy the properties to each of the categories (if it exists).
3992 if (!PropertyTokens.IsEmpty()){
3994 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3998 // Check if ALTID was used.
4000 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4002 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4006 // Check if PID was used.
4008 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4010 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4014 // Check if PREF was used.
4016 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4018 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4022 // Check if LANGUAGE was used.
4024 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4026 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4030 // Check if TYPE was used.
4036 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4039 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4047 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4049 size_t intPropertyLen = PropertySeg1.Len();
4050 std::map<int, int> SplitPoints;
4051 std::map<int, int> SplitLength;
4052 std::map<int, int>::iterator SLiter;
4053 wxString PropertyData;
4054 wxString PropertyName;
4055 wxString PropertyValue;
4056 wxString PropertyTokens;
4057 bool FirstToken = TRUE;
4058 int intSplitsFound = 0;
4059 int intSplitSize = 0;
4060 int intPrevValue = 7;
4065 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4069 PropertyType PropType = PROPERTY_NONE;
4071 // Look for type before continuing.
4073 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4077 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4078 intiter != SplitPoints.end(); ++intiter){
4080 SLiter = SplitLength.find(intiter->first);
4082 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4084 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4085 PropertyName = PropertyElement.GetNextToken();
4086 PropertyValue = PropertyElement.GetNextToken();
4088 intPrevValue = intiter->second;
4090 // Process properties.
4092 size_t intPropertyValueLen = PropertyValue.Len();
4094 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4096 PropertyValue.Trim();
4097 PropertyValue.RemoveLast();
4101 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4103 PropertyValue.Remove(0, 1);
4107 CaptureString(&PropertyValue, FALSE);
4109 if (PropertyName == wxT("ALTID")){
4111 PicturesListAltID.erase(*PhotoCount);
4112 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4114 } else if (PropertyName == wxT("PID")){
4116 PicturesListPID.erase(*PhotoCount);
4117 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4119 } else if (PropertyName == wxT("PREF")){
4121 int PriorityNumber = 0;
4122 bool ValidNumber = TRUE;
4125 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4128 catch(std::invalid_argument &e){
4129 ValidNumber = FALSE;
4132 if (ValidNumber == TRUE){
4134 PicturesListPref.erase(*PhotoCount);
4135 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4139 } else if (PropertyName == wxT("MEDIATYPE")){
4141 PicturesListMediatype.erase(*PhotoCount);
4142 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4146 // Something else we don't know about so append
4147 // to the tokens variable.
4149 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4151 if (FirstToken == TRUE){
4153 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4158 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4168 intPropertyLen = PropertySeg2.Len();
4169 SplitPoints.clear();
4170 SplitLength.clear();
4175 CaptureString(&PropertySeg2, FALSE);
4177 for (int i = 0; i <= intPropertyLen; i++){
4181 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4184 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4186 if (intSplitsFound == 6){
4188 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4193 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4203 wxString wxSPhotoURI;
4204 wxString wxSPhotoMIME;
4205 wxString wxSPhotoEncoding;
4206 wxString wxSPhotoData;
4207 std::string base64enc;
4209 if (intSplitsFound == 0){
4213 std::map<int, int>::iterator striter;
4215 striter = SplitLength.find(1);
4217 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4219 while (wSTDataType.HasMoreTokens() == TRUE){
4221 wxSPhotoURI = wSTDataType.GetNextToken();
4222 wxSPhotoMIME = wSTDataType.GetNextToken();
4227 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4229 while (wSTDataInfo.HasMoreTokens() == TRUE){
4231 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4232 wxSPhotoData = wSTDataInfo.GetNextToken();
4233 base64enc = wxSPhotoData.mb_str();
4240 // Add the data to the General/Home/Work address variables.
4242 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4243 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4244 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4250 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4253 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4257 if (!PropertyTokens.IsEmpty()){
4259 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4265 void SplitValues(wxString *PropertyLine,
4266 std::map<int,int> *SplitPoints,
4267 std::map<int,int> *SplitLength,
4270 size_t intPropertyLen = PropertyLine->Len();
4271 int intSplitsFound = 0;
4272 int intSplitSize = 0;
4273 int intSplitSeek = 0;
4275 for (int i = intSize; i <= intPropertyLen; i++){
4279 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4280 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4282 if (intSplitsFound == 0){
4284 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4288 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4292 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4302 if (intSplitsFound == 0){
4304 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4305 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4309 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4310 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4316 void CheckType(wxString *PropertySeg1,
4317 std::map<int,int> *SplitPoints,
4318 std::map<int,int> *SplitLength,
4320 PropertyType *PropType){
4322 wxString PropertyData;
4323 wxString PropertyName;
4324 wxString PropertyValue;
4325 std::map<int,int>::iterator SLiter;
4327 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
4328 intiter != SplitPoints->end(); ++intiter){
4330 SLiter = SplitLength->find(intiter->first);
4332 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4334 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4335 PropertyName = PropertyElement.GetNextToken();
4336 PropertyValue = PropertyElement.GetNextToken();
4338 *intPrevValue = intiter->second;
4340 if (PropertyName == wxT("TYPE")){
4342 if (PropertyValue == wxT("work")){
4344 *PropType = PROPERTY_WORK;
4346 } else if (PropertyValue == wxT("home")){
4348 *PropType = PROPERTY_HOME;
4352 *PropType = PROPERTY_NONE;