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;
103 wxString ContactLine;
104 wxString PropertyLine;
105 wxString PropertySeg1;
106 wxString PropertySeg2;
107 wxString PropertyNextLine;
110 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
111 iter != ContactFileLines.end(); ++iter){
113 ExtraLineSeek = TRUE;
119 PropertyLine.Clear();
120 PropertySeg1.Clear();
121 PropertySeg2.Clear();
124 ContactLine = iter->second;
126 while (ExtraLineSeek == TRUE){
128 // Check if there is extra data on the next line
129 // (indicated by space or tab at the start) and add data.
133 if (iter == ContactFileLines.end()){
140 PropertyNextLine = iter->second;
142 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
144 PropertyNextLine.Remove(0, 1);
145 ContactLine.Append(PropertyNextLine);
150 ExtraLineSeek = FALSE;
156 ContactLineLen = ContactLine.Len();
158 // Make sure we are not in quotation mode.
159 // Make sure colon does not have \ or \\ before it.
161 for (int i = 0; i <= ContactLineLen; i++){
163 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
165 PropertyFind = FALSE;
167 } else if (PropertyFind == TRUE){
169 Property.Append(ContactLine.Mid(i, 1));
173 if (ContactLine.Mid(i, 1) == wxT("\"")){
175 if (QuoteMode == TRUE){
187 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
196 // Split that line at the point into two variables (ignore the colon).
198 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
199 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
201 if (Property == wxT("KIND") && KindProcessed == FALSE){
203 ProcessKind(PropertySeg2);
205 } else if (Property == wxT("MEMBER")){
207 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
210 } else if (Property == wxT("FN")){
212 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
215 } else if (Property == wxT("N") && NameProcessed == FALSE){
217 ProcessN(PropertySeg1, PropertySeg2);
218 NameProcessed = TRUE;
220 } else if (Property == wxT("NICKNAME")){
222 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
225 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
227 ProcessGender(PropertySeg1, PropertySeg2);
228 GenderProcessed = TRUE;
230 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
232 ProcessBirthday(PropertySeg1, PropertySeg2);
233 BirthdayProcessed = TRUE;
235 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
237 ProcessAnniversary(PropertySeg1, PropertySeg2);
238 AnniversaryProcessed = TRUE;
240 } else if (Property == wxT("TZ")){
242 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
245 } else if (Property == wxT("ADR")){
247 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
250 } else if (Property == wxT("EMAIL")){
252 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
255 } else if (Property == wxT("IMPP")){
257 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
260 } else if (Property == wxT("TEL")){
262 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
265 } else if (Property == wxT("LANG")){
267 // See frmContactEditor-LoadLanguage.cpp
269 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
272 } else if (Property == wxT("GEO")){
274 // See frmContactEditor-LoadGeo.cpp
276 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
279 } else if (Property == wxT("RELATED")){
281 // See fromContactEditor-LoadRelated.cpp
283 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
286 } else if (Property == wxT("URL")){
288 // See frmContactEditor-LoadURL.cpp
290 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
293 } else if (Property == wxT("TITLE")) {
295 // See frmContactEditor-LoadTitle.cpp
297 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
300 } else if (Property == wxT("ROLE")) {
302 // See frmContactEditor-LoadTitle.cpp
304 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
307 } else if (Property == wxT("ORG")) {
309 // See frmContactEditor-LoadOrg.cpp
311 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
314 } else if (Property == wxT("NOTE")) {
316 // See frmContactEditor-LoadNote.cpp
318 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
321 } else if (Property == wxT("CATEGORIES")) {
323 // See frmContactEditor-LoadCategory.cpp
325 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
328 } else if (Property == wxT("PHOTO")) {
330 // See frmContactEditor-LoadPhoto.cpp
332 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
335 } else if (Property == wxT("LOGO")) {
337 // See frmContactEditor-LoadPhoto.cpp
339 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
342 } else if (Property == wxT("LOGO")) {
344 // See frmContactEditor-LoadPhoto.cpp
346 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
349 } else if (Property == wxT("SOUND")) {
351 // See frmContactEditor-LoadSound.cpp
353 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
360 return CONTACTLOAD_OK;
364 void ContactDataObject::ProcessKind(wxString KindType){
366 if (KindType == wxT("individual")){
368 ContactKind = CONTACTKIND_INDIVIDUAL;
370 } else if (KindType == wxT("group")){
372 ContactKind = CONTACTKIND_GROUP;
374 } else if (KindType == wxT("org")){
376 ContactKind = CONTACTKIND_ORGANISATION;
378 } else if (KindType == wxT("location")){
380 ContactKind = CONTACTKIND_LOCATION;
384 ContactKind = CONTACTKIND_NONE;
389 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
391 std::map<int, int> SplitPoints;
392 std::map<int, int> SplitLength;
394 int intPrevValue = 8;
398 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
402 wxString PropertyName;
403 wxString PropertyValue;
404 wxString PropertyData;
405 wxString PropertyTokens;
406 std::map<int,int>::iterator SLiter;
407 bool FirstToken = TRUE;
409 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
410 intiter != SplitPoints.end(); ++intiter){
412 SLiter = SplitLength.find(intiter->first);
414 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
416 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
417 PropertyName = PropertyElement.GetNextToken();
418 PropertyValue = PropertyElement.GetNextToken();
420 intPrevValue = intiter->second;
422 CaptureString(&PropertyValue, FALSE);
424 if (PropertyName == wxT("ALTID")){
426 GroupsListAltID.erase(*GroupCount);
427 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
429 } else if (PropertyName == wxT("PID")){
431 GroupsListPID.erase(*GroupCount);
432 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
434 } else if (PropertyName == wxT("PREF")){
436 int PriorityNumber = 0;
437 bool ValidNumber = TRUE;
440 PriorityNumber = std::stoi(PropertyValue.ToStdString());
443 catch(std::invalid_argument &e){
447 if (ValidNumber == TRUE){
449 GroupsListPref.erase(*GroupCount);
450 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
454 } else if (PropertyName == wxT("MEDIATYPE")){
456 GroupsListMediaType.erase(*GroupCount);
457 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
459 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
461 if (FirstToken == TRUE){
463 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
468 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
476 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
478 if (!PropertyTokens.IsEmpty()){
480 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
487 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
489 std::map<int, int> SplitPoints;
490 std::map<int, int> SplitLength;
492 int intPrevValue = 4;
496 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
500 wxString PropertyName;
501 wxString PropertyValue;
502 wxString PropertyData;
503 wxString PropertyTokens;
504 std::map<int,int>::iterator SLiter;
505 bool FirstToken = TRUE;
507 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
508 intiter != SplitPoints.end(); ++intiter){
510 SLiter = SplitLength.find(intiter->first);
512 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
514 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
515 PropertyName = PropertyElement.GetNextToken();
516 PropertyValue = PropertyElement.GetNextToken();
518 intPrevValue = intiter->second;
520 CaptureString(&PropertyValue, FALSE);
522 if (PropertyName == wxT("TYPE")){
524 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
525 PropertyValue == wxT("work") ){
527 FullNamesListType.erase(*FNCount);
528 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
532 } else if (PropertyName == wxT("LANGUAGE")){
534 FullNamesListLanguage.erase(*FNCount);
535 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
537 } else if (PropertyName == wxT("ALTID")){
539 FullNamesListAltID.erase(*FNCount);
540 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
542 } else if (PropertyName == wxT("PID")){
544 FullNamesListPID.erase(*FNCount);
545 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
547 } else if (PropertyName == wxT("PREF")){
549 int PriorityNumber = 0;
550 bool ValidNumber = TRUE;
553 PriorityNumber = std::stoi(PropertyValue.ToStdString());
556 catch(std::invalid_argument &e){
560 if (ValidNumber == TRUE){
562 FullNamesListPref.erase(*FNCount);
563 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
567 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
569 if (FirstToken == TRUE){
571 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
576 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
584 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
586 if (!PropertyTokens.IsEmpty()){
588 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
594 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
596 std::map<int, int> SplitPoints;
597 std::map<int, int> SplitLength;
599 int intPrevValue = 3;
603 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
607 wxString PropertyName;
608 wxString PropertyValue;
609 wxString PropertyData;
610 wxString PropertyTokens;
611 std::map<int,int>::iterator SLiter;
612 bool FirstToken = TRUE;
614 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
615 intiter != SplitPoints.end(); ++intiter){
617 SLiter = SplitLength.find(intiter->first);
619 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
621 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
622 PropertyName = PropertyElement.GetNextToken();
623 PropertyValue = PropertyElement.GetNextToken();
625 intPrevValue = intiter->second;
627 CaptureString(&PropertyValue, FALSE);
629 if (PropertyName == wxT("ALTID")){
631 NameAltID = PropertyValue;
633 } else if (PropertyName == wxT("LANGUAGE")){
635 NameLanguage = PropertyValue;
637 } else if (PropertyName == wxT("SORT-AS")){
639 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
640 PropertyValue.Len() >= 3){
641 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
644 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
646 if (FirstToken == TRUE){
648 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
653 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
661 // Split the name data.
663 int intSplitSeek = 0;
664 int intSplitsFound = 0;
665 int intSplitSize = 0;
666 int intPropertyLen = PropertySeg2.Len();
668 std::map<int,wxString> NameValues;
671 for (int i = 0; i <= intPropertyLen; i++){
673 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
675 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
680 if (intSplitsFound == 4){
682 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
696 // Split the data into several parts.
698 for (std::map<int, wxString>::iterator iter = NameValues.begin();
699 iter != NameValues.end(); ++iter){
701 if (iter->first == 1){
703 // Deal with family name.
705 NameSurname = iter->second;
707 } else if (iter->first == 2){
709 // Deal with given names.
711 NameForename = iter->second;
713 } else if (iter->first == 3){
715 // Deal with additional names.
717 NameOtherNames = iter->second;
719 } else if (iter->first == 4){
721 // Deal with honorifix prefixes and suffixes.
723 NameTitle = iter->second;
727 if (iter == NameValues.end()){
733 NameSuffix = iter->second;
739 // Add the name token data.
741 if (!PropertyTokens.IsEmpty()){
743 NameTokens = PropertyTokens;
749 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
751 std::map<int, int> SplitPoints;
752 std::map<int, int> SplitLength;
754 int intPrevValue = 10;
757 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
761 PropertyType PropType = PROPERTY_NONE;
763 // Look for type before continuing.
765 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
769 std::map<int, wxString> *NicknamesList = NULL;
770 std::map<int, wxString> *NicknamesListType = NULL;
771 std::map<int, wxString> *NicknamesListLanguage = NULL;
772 std::map<int, wxString> *NicknamesListAltID = NULL;
773 std::map<int, wxString> *NicknamesListPID = NULL;
774 std::map<int, wxString> *NicknamesListTokens = NULL;
775 std::map<int, int> *NicknamesListPref = NULL;
779 NicknamesList = &GeneralNicknamesList;
780 NicknamesListType = &GeneralNicknamesListType;
781 NicknamesListLanguage = &GeneralNicknamesListLanguage;
782 NicknamesListAltID = &GeneralNicknamesListAltID;
783 NicknamesListPID = &GeneralNicknamesListPID;
784 NicknamesListTokens = &GeneralNicknamesListTokens;
785 NicknamesListPref = &GeneralNicknamesListPref;
788 NicknamesList = &HomeNicknamesList;
789 NicknamesListType = &HomeNicknamesListType;
790 NicknamesListLanguage = &HomeNicknamesListLanguage;
791 NicknamesListAltID = &HomeNicknamesListAltID;
792 NicknamesListPID = &HomeNicknamesListPID;
793 NicknamesListTokens = &HomeNicknamesListTokens;
794 NicknamesListPref = &HomeNicknamesListPref;
797 NicknamesList = &BusinessNicknamesList;
798 NicknamesListType = &BusinessNicknamesListType;
799 NicknamesListLanguage = &BusinessNicknamesListLanguage;
800 NicknamesListAltID = &BusinessNicknamesListAltID;
801 NicknamesListPID = &BusinessNicknamesListPID;
802 NicknamesListTokens = &BusinessNicknamesListTokens;
803 NicknamesListPref = &BusinessNicknamesListPref;
807 std::map<int, int>::iterator SLiter;
808 wxString PropertyData;
809 wxString PropertyName;
810 wxString PropertyValue;
811 wxString PropertyTokens;
812 bool FirstToken = TRUE;
814 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
815 intiter != SplitPoints.end(); ++intiter){
817 SLiter = SplitLength.find(intiter->first);
819 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
821 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
822 PropertyName = PropertyElement.GetNextToken();
823 PropertyValue = PropertyElement.GetNextToken();
825 intPrevValue = intiter->second;
827 CaptureString(&PropertyValue, FALSE);
829 if (PropertyName == wxT("ALTID")){
831 NicknamesListAltID->erase(*NicknameCount);
832 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
834 } else if (PropertyName == wxT("PID")){
836 NicknamesListPID->erase(*NicknameCount);
837 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
839 } else if (PropertyName == wxT("PREF")){
841 int PriorityNumber = 0;
842 bool ValidNumber = TRUE;
845 PriorityNumber = std::stoi(PropertyValue.ToStdString());
848 catch(std::invalid_argument &e){
852 if (ValidNumber == TRUE){
854 NicknamesListPref->erase(*NicknameCount);
855 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
859 } else if (PropertyName == wxT("LANGUAGE")){
861 NicknamesListLanguage->erase(*NicknameCount);
862 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
866 // Something else we don't know about so append
867 // to the tokens variable.
869 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
871 if (FirstToken == TRUE){
873 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
878 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
888 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
890 // Add the name token data.
892 if (!PropertyTokens.IsEmpty()){
894 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
900 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
902 std::map<int, int> SplitPoints;
903 std::map<int, int> SplitLength;
904 std::map<int, int>::iterator SLiter;
905 wxString PropertyData;
906 wxString PropertyName;
907 wxString PropertyValue;
908 wxString PropertyTokens;
909 bool FirstToken = TRUE;
910 int intPrevValue = 8;
912 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
916 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
917 intiter != SplitPoints.end(); ++intiter){
919 SLiter = SplitLength.find(intiter->first);
921 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
923 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
924 PropertyName = PropertyElement.GetNextToken();
925 PropertyValue = PropertyElement.GetNextToken();
927 intPrevValue = intiter->second;
929 // Process properties.
931 size_t intPropertyValueLen = PropertyValue.Len();
933 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
935 PropertyValue.Trim();
936 PropertyValue.RemoveLast();
940 if (PropertyValue.Mid(0, 1) == wxT("\"")){
942 PropertyValue.Remove(0, 1);
946 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
948 if (FirstToken == TRUE){
950 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
955 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
963 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
965 wxString GenderComponent;
967 if (GenderData.CountTokens() >= 2){
969 Gender = GenderData.GetNextToken();
970 GenderDetails = GenderData.GetString();
972 CaptureString(&GenderDetails, FALSE);
976 Gender = GenderData.GetNextToken();
980 if (!PropertyTokens.IsEmpty()){
982 GenderTokens = PropertyTokens;
988 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
990 // Process date. Preserve the remainder in the string.
992 std::map<int, int> SplitPoints;
993 std::map<int, int> SplitLength;
994 std::map<int, int>::iterator SLiter;
995 wxString PropertyData;
996 wxString PropertyName;
997 wxString PropertyValue;
998 wxString PropertyTokens;
999 bool BirthdayText = FALSE;
1000 int intPrevValue = 6;
1002 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1006 // Look for type before continuing.
1008 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1009 intiter != SplitPoints.end(); ++intiter){
1011 SLiter = SplitLength.find(intiter->first);
1013 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1015 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1016 PropertyName = PropertyElement.GetNextToken();
1017 PropertyValue = PropertyElement.GetNextToken();
1019 intPrevValue = intiter->second;
1021 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1023 CaptureString(&PropertySeg2, FALSE);
1024 Birthday = PropertySeg2;
1025 BirthdayText = TRUE;
1031 // Setup blank lines for later on.
1034 bool FirstToken = TRUE;
1036 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1037 intiter != SplitPoints.end(); ++intiter){
1039 SLiter = SplitLength.find(intiter->first);
1041 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1043 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1044 PropertyName = PropertyElement.GetNextToken();
1045 PropertyValue = PropertyElement.GetNextToken();
1047 intPrevValue = intiter->second;
1049 // Process properties.
1051 CaptureString(&PropertyValue, FALSE);
1053 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1055 PropertyValue.Trim();
1056 PropertyValue.RemoveLast();
1060 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1062 PropertyValue.Remove(0, 1);
1066 if (PropertyName == wxT("ALTID")){
1068 BirthdayAltID = PropertyValue;
1070 } else if (PropertyName == wxT("CALSCALE")){
1072 BirthdayCalScale = PropertyValue;
1074 } else if (PropertyName != wxT("VALUE")) {
1076 // Something else we don't know about so append
1077 // to the tokens variable.
1079 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1081 if (FirstToken == TRUE){
1083 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1088 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1098 // Add the data to the variables and form.
1100 if (BirthdayText == FALSE){
1102 Birthday = PropertySeg2;
1106 if (!PropertyTokens.IsEmpty()){
1108 BirthdayTokens = PropertyTokens;
1114 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1116 // Process date. Preserve the remainder in the string.
1118 std::map<int, int> SplitPoints;
1119 std::map<int, int> SplitLength;
1120 std::map<int, int>::iterator SLiter;
1121 wxString PropertyData;
1122 wxString PropertyName;
1123 wxString PropertyValue;
1124 wxString PropertyTokens;
1125 bool AnniversaryText = FALSE;
1126 int intPrevValue = 13;
1128 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1132 // Look for type before continuing.
1134 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1135 intiter != SplitPoints.end(); ++intiter){
1137 SLiter = SplitLength.find(intiter->first);
1139 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1141 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1142 PropertyName = PropertyElement.GetNextToken();
1143 PropertyValue = PropertyElement.GetNextToken();
1145 intPrevValue = intiter->second;
1147 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1149 CaptureString(&PropertySeg2, FALSE);
1150 Anniversary = PropertySeg2;
1151 AnniversaryText = TRUE;
1157 // Setup blank lines for later on.
1160 bool FirstToken = TRUE;
1162 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1163 intiter != SplitPoints.end(); ++intiter){
1165 SLiter = SplitLength.find(intiter->first);
1167 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1169 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1170 PropertyName = PropertyElement.GetNextToken();
1171 PropertyValue = PropertyElement.GetNextToken();
1173 intPrevValue = intiter->second;
1175 // Process properties.
1177 CaptureString(&PropertyValue, FALSE);
1179 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1181 PropertyValue.Trim();
1182 PropertyValue.RemoveLast();
1186 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1188 PropertyValue.Remove(0, 1);
1192 if (PropertyName == wxT("ALTID")){
1194 AnniversaryAltID = PropertyValue;
1196 } else if (PropertyName == wxT("CALSCALE")){
1198 AnniversaryCalScale = PropertyValue;
1200 } else if (PropertyName != wxT("VALUE")) {
1202 // Something else we don't know about so append
1203 // to the tokens variable.
1205 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1207 if (FirstToken == TRUE){
1209 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1214 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1224 // Add the data to the variables and form.
1226 if (AnniversaryText == FALSE){
1228 Anniversary = PropertySeg2;
1232 if (!PropertyTokens.IsEmpty()){
1234 AnniversaryTokens = PropertyTokens;
1240 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1242 std::map<int, int> SplitPoints;
1243 std::map<int, int> SplitLength;
1245 int intPrevValue = 4;
1248 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1252 PropertyType PropType = PROPERTY_NONE;
1254 // Look for type before continuing.
1256 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1260 std::map<int, wxString> *TZList = NULL;
1261 std::map<int, wxString> *TZListType = NULL;
1262 std::map<int, wxString> *TZListMediatype = NULL;
1263 std::map<int, wxString> *TZListAltID = NULL;
1264 std::map<int, wxString> *TZListPID = NULL;
1265 std::map<int, wxString> *TZListTokens = NULL;
1266 std::map<int, int> *TZListPref = NULL;
1270 TZList = &GeneralTZList;
1271 TZListType = &GeneralTZListType;
1272 TZListMediatype = &GeneralTZListMediatype;
1273 TZListAltID = &GeneralTZListAltID;
1274 TZListPID = &GeneralTZListPID;
1275 TZListTokens = &GeneralTZListTokens;
1276 TZListPref = &GeneralTZListPref;
1279 TZList = &HomeTZList;
1280 TZListType = &HomeTZListType;
1281 TZListMediatype = &HomeTZListMediatype;
1282 TZListAltID = &HomeTZListAltID;
1283 TZListPID = &HomeTZListPID;
1284 TZListTokens = &HomeTZListTokens;
1285 TZListPref = &HomeTZListPref;
1288 TZList = &BusinessTZList;
1289 TZListType = &BusinessTZListType;
1290 TZListMediatype = &BusinessTZListMediatype;
1291 TZListAltID = &BusinessTZListAltID;
1292 TZListPID = &BusinessTZListPID;
1293 TZListTokens = &BusinessTZListTokens;
1294 TZListPref = &BusinessTZListPref;
1298 std::map<int, int>::iterator SLiter;
1299 wxString PropertyData;
1300 wxString PropertyName;
1301 wxString PropertyValue;
1302 wxString PropertyTokens;
1303 bool FirstToken = TRUE;
1305 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1306 intiter != SplitPoints.end(); ++intiter){
1308 SLiter = SplitLength.find(intiter->first);
1310 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1312 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1313 PropertyName = PropertyElement.GetNextToken();
1314 PropertyValue = PropertyElement.GetNextToken();
1316 intPrevValue = intiter->second;
1318 CaptureString(&PropertyValue, FALSE);
1320 if (PropertyName == wxT("ALTID")){
1322 TZListAltID->erase(*TimeZoneCount);
1323 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1325 } else if (PropertyName == wxT("PID")){
1327 TZListPID->erase(*TimeZoneCount);
1328 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1330 } else if (PropertyName == wxT("PREF")){
1332 int PriorityNumber = 0;
1333 bool ValidNumber = TRUE;
1336 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1339 catch(std::invalid_argument &e){
1340 ValidNumber = FALSE;
1343 if (ValidNumber == TRUE){
1345 TZListPref->erase(*TimeZoneCount);
1346 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1350 } else if (PropertyName == wxT("MEDIATYPE")){
1352 TZListMediatype->erase(*TimeZoneCount);
1353 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1357 // Something else we don't know about so append
1358 // to the tokens variable.
1360 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1362 if (FirstToken == TRUE){
1364 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1369 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1379 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1381 // Add the name token data.
1383 if (!PropertyTokens.IsEmpty()){
1385 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1392 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1394 size_t intPropertyLen = PropertySeg1.Len();
1395 std::map<int, int> SplitPoints;
1396 std::map<int, int> SplitLength;
1397 std::map<int, int>::iterator SLiter;
1398 wxString PropertyData;
1399 wxString PropertyName;
1400 wxString PropertyValue;
1401 wxString PropertyTokens;
1402 wxString AddressLabel;
1403 wxString AddressLang;
1404 wxString AddressAltID;
1405 wxString AddressPID;
1406 wxString AddressTokens;
1407 wxString AddressGeo;
1408 wxString AddressTimezone;
1409 wxString AddressType;
1410 wxString AddressMediatype;
1411 wxString AddressPOBox;
1412 wxString AddressExtended;
1413 wxString AddressStreet;
1414 wxString AddressLocality;
1415 wxString AddressCity;
1416 wxString AddressRegion;
1417 wxString AddressPostalCode;
1418 wxString AddressCountry;
1419 bool FirstToken = TRUE;
1420 int intSplitsFound = 0;
1421 int intSplitSize = 0;
1422 int intPrevValue = 5;
1427 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1431 PropertyType PropType = PROPERTY_NONE;
1433 // Look for type before continuing.
1435 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1439 std::map<int, wxString> *AddressList = NULL;
1440 std::map<int, wxString> *AddressListTown = NULL;
1441 std::map<int, wxString> *AddressListCounty = NULL;
1442 std::map<int, wxString> *AddressListPostCode = NULL;
1443 std::map<int, wxString> *AddressListCountry = NULL;
1444 std::map<int, wxString> *AddressListLabel = NULL;
1445 std::map<int, wxString> *AddressListLang = NULL;
1446 std::map<int, wxString> *AddressListAltID = NULL;
1447 std::map<int, wxString> *AddressListPID = NULL;
1448 std::map<int, wxString> *AddressListTokens = NULL;
1449 std::map<int, wxString> *AddressListGeo = NULL;
1450 std::map<int, wxString> *AddressListTimezone = NULL;
1451 std::map<int, wxString> *AddressListType = NULL;
1452 std::map<int, wxString> *AddressListMediatype = NULL;
1453 std::map<int, int> *AddressListPref = NULL;
1457 AddressList = &GeneralAddressList;
1458 AddressListTown = &GeneralAddressListTown;
1459 AddressListCounty = &GeneralAddressListCounty;
1460 AddressListPostCode = &GeneralAddressListPostCode;
1461 AddressListCountry = &GeneralAddressListCountry;
1462 AddressListLabel = &GeneralAddressListLabel;
1463 AddressListLang = &GeneralAddressListLang;
1464 AddressListAltID = &GeneralAddressListAltID;
1465 AddressListPID = &GeneralAddressListPID;
1466 AddressListTokens = &GeneralAddressListTokens;
1467 AddressListGeo = &GeneralAddressListGeo;
1468 AddressListTimezone = &GeneralAddressListTimezone;
1469 AddressListType = &GeneralAddressListType;
1470 AddressListMediatype = &GeneralAddressListMediatype;
1471 AddressListPref = &GeneralAddressListPref;
1474 AddressList = &HomeAddressList;
1475 AddressListTown = &HomeAddressListTown;
1476 AddressListCounty = &HomeAddressListCounty;
1477 AddressListPostCode = &HomeAddressListPostCode;
1478 AddressListCountry = &HomeAddressListCountry;
1479 AddressListLabel = &HomeAddressListLabel;
1480 AddressListLang = &HomeAddressListLang;
1481 AddressListAltID = &HomeAddressListAltID;
1482 AddressListPID = &HomeAddressListPID;
1483 AddressListTokens = &HomeAddressListTokens;
1484 AddressListGeo = &HomeAddressListGeo;
1485 AddressListTimezone = &HomeAddressListTimezone;
1486 AddressListType = &HomeAddressListType;
1487 AddressListMediatype = &HomeAddressListMediatype;
1488 AddressListPref = &HomeAddressListPref;
1491 AddressList = &BusinessAddressList;
1492 AddressListTown = &BusinessAddressListTown;
1493 AddressListCounty = &BusinessAddressListCounty;
1494 AddressListPostCode = &BusinessAddressListPostCode;
1495 AddressListCountry = &BusinessAddressListCountry;
1496 AddressListLabel = &BusinessAddressListLabel;
1497 AddressListLang = &BusinessAddressListLang;
1498 AddressListAltID = &BusinessAddressListAltID;
1499 AddressListPID = &BusinessAddressListPID;
1500 AddressListTokens = &BusinessAddressListTokens;
1501 AddressListGeo = &BusinessAddressListGeo;
1502 AddressListTimezone = &BusinessAddressListTimezone;
1503 AddressListType = &BusinessAddressListType;
1504 AddressListMediatype = &BusinessAddressListMediatype;
1505 AddressListPref = &BusinessAddressListPref;
1511 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1512 intiter != SplitPoints.end(); ++intiter){
1514 SLiter = SplitLength.find(intiter->first);
1516 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1518 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1519 PropertyName = PropertyElement.GetNextToken();
1520 PropertyValue = PropertyElement.GetNextToken();
1522 intPrevValue = intiter->second;
1524 CaptureString(&PropertyValue, FALSE);
1526 // Process properties.
1528 if (PropertyName == wxT("LABEL")){
1530 AddressListLabel->erase(*AddressCount);
1531 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1533 } else if (PropertyName == wxT("LANGUAGE")){
1535 AddressListLang->erase(*AddressCount);
1536 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1538 } else if (PropertyName == wxT("ALTID")){
1540 AddressListAltID->erase(*AddressCount);
1541 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1543 } else if (PropertyName == wxT("PID")){
1545 AddressListPID->erase(*AddressCount);
1546 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1548 } else if (PropertyName == wxT("GEO")){
1550 AddressListGeo->erase(*AddressCount);
1551 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1553 } else if (PropertyName == wxT("TZ")){
1555 AddressListTimezone->erase(*AddressCount);
1556 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1558 } else if (PropertyName == wxT("MEDIATYPE")){
1560 AddressListMediatype->erase(*AddressCount);
1561 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1563 } else if (PropertyName == wxT("PREF")){
1565 int PriorityNumber = 0;
1566 bool ValidNumber = TRUE;
1569 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1572 catch(std::invalid_argument &e){
1573 ValidNumber = FALSE;
1576 if (ValidNumber == TRUE){
1578 AddressListPref->erase(*AddressCount);
1579 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1585 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1587 if (FirstToken == TRUE){
1589 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1594 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1604 // Split the address.
1606 //std::map<int, int>::iterator SLiter;
1607 intPropertyLen = PropertySeg2.Len();
1608 SplitPoints.clear();
1609 SplitLength.clear();
1614 for (int i = 0; i <= intPropertyLen; i++){
1618 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1621 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1623 if (intSplitsFound == 6){
1625 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1630 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1640 // Split the data into several parts.
1642 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1643 intiter != SplitPoints.end(); ++intiter){
1645 if (intiter->first == 1){
1647 // Deal with PO Box.
1649 SLiter = SplitLength.find(1);
1651 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1652 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1653 intPrevValue = intiter->second;
1655 } else if (intiter->first == 2){
1657 // Deal with extended address.
1659 SLiter = SplitLength.find(2);
1661 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1662 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1663 intPrevValue = intiter->second;
1665 } else if (intiter->first == 3){
1667 // Deal with street address.
1669 SLiter = SplitLength.find(3);
1671 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1672 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1673 intPrevValue = intiter->second;
1675 } else if (intiter->first == 4){
1677 // Deal with locality
1679 SLiter = SplitLength.find(4);
1681 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1682 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1683 intPrevValue = intiter->second;
1685 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1687 } else if (intiter->first == 5){
1689 // Deal with region.
1691 SLiter = SplitLength.find(5);
1693 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1694 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1695 intPrevValue = intiter->second;
1697 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1699 } else if (intiter->first == 6){
1701 // Deal with post code.
1703 SLiter = SplitLength.find(6);
1705 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1706 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1707 intPrevValue = intiter->second;
1709 // Deal with country.
1711 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1712 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1720 // Add the data to the General/Home/Work address variables.
1722 CaptureString(&AddressStreet, FALSE);
1723 CaptureString(&AddressLocality, FALSE);
1724 CaptureString(&AddressRegion, FALSE);
1725 CaptureString(&AddressPostalCode, FALSE);
1726 CaptureString(&AddressCountry, FALSE);
1728 if (!PropertyTokens.IsEmpty()){
1730 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1734 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1735 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1736 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1737 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1738 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1742 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1745 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1748 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1752 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1756 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1758 std::map<int, int> SplitPoints;
1759 std::map<int, int> SplitLength;
1761 int intPrevValue = 7;
1764 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1768 PropertyType PropType = PROPERTY_NONE;
1770 // Look for type before continuing.
1772 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1774 std::map<int, wxString> *EmailList = NULL;
1775 std::map<int, wxString> *EmailListType = NULL;
1776 std::map<int, wxString> *EmailListAltID = NULL;
1777 std::map<int, wxString> *EmailListPID = NULL;
1778 std::map<int, wxString> *EmailListTokens = NULL;
1779 std::map<int, int> *EmailListPref = NULL;
1783 EmailList = &GeneralEmailList;
1784 EmailListType = &GeneralEmailListType;
1785 EmailListAltID = &GeneralEmailListAltID;
1786 EmailListPID = &GeneralEmailListPID;
1787 EmailListTokens = &GeneralEmailListTokens;
1788 EmailListPref = &GeneralEmailListPref;
1791 EmailList = &HomeEmailList;
1792 EmailListType = &HomeEmailListType;
1793 EmailListAltID = &HomeEmailListAltID;
1794 EmailListPID = &HomeEmailListPID;
1795 EmailListTokens = &HomeEmailListTokens;
1796 EmailListPref = &HomeEmailListPref;
1799 EmailList = &BusinessEmailList;
1800 EmailListType = &BusinessEmailListType;
1801 EmailListAltID = &BusinessEmailListAltID;
1802 EmailListPID = &BusinessEmailListPID;
1803 EmailListTokens = &BusinessEmailListTokens;
1804 EmailListPref = &BusinessEmailListPref;
1810 std::map<int,int>::iterator SLiter;
1811 wxString PropertyData;
1812 wxString PropertyName;
1813 wxString PropertyValue;
1814 wxString PropertyTokens;
1815 bool FirstToken = TRUE;
1817 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1818 intiter != SplitPoints.end(); ++intiter){
1820 SLiter = SplitLength.find(intiter->first);
1822 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1824 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1825 PropertyName = PropertyElement.GetNextToken();
1826 PropertyValue = PropertyElement.GetNextToken();
1828 intPrevValue = intiter->second;
1830 CaptureString(&PropertyValue, FALSE);
1832 // Process properties.
1834 if (PropertyName == wxT("ALTID")){
1836 EmailListAltID->erase(*EmailCount);
1837 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1839 } else if (PropertyName == wxT("PID")){
1841 EmailListPID->erase(*EmailCount);
1842 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1844 } else if (PropertyName == wxT("PREF")){
1846 int PriorityNumber = 0;
1847 bool ValidNumber = TRUE;
1850 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1853 catch(std::invalid_argument &e){
1854 ValidNumber = FALSE;
1857 if (ValidNumber == TRUE){
1859 EmailListPref->erase(*EmailCount);
1860 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1866 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1868 if (FirstToken == TRUE){
1870 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1875 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1885 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1887 // Add the name token data.
1889 if (!PropertyTokens.IsEmpty()){
1891 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1898 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1900 std::map<int, int> SplitPoints;
1901 std::map<int, int> SplitLength;
1903 int intPrevValue = 6;
1906 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1910 PropertyType PropType = PROPERTY_NONE;
1912 // Look for type before continuing.
1914 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1916 std::map<int, wxString> *IMList = NULL;
1917 std::map<int, wxString> *IMListType = NULL;
1918 std::map<int, wxString> *IMListAltID = NULL;
1919 std::map<int, wxString> *IMListPID = NULL;
1920 std::map<int, wxString> *IMListTokens = NULL;
1921 std::map<int, wxString> *IMListMediatype = NULL;
1922 std::map<int, int> *IMListPref = NULL;
1926 IMList = &GeneralIMList;
1927 IMListType = &GeneralIMListType;
1928 IMListAltID = &GeneralIMListAltID;
1929 IMListPID = &GeneralIMListPID;
1930 IMListTokens = &GeneralIMListTokens;
1931 IMListMediatype = &GeneralIMListMediatype;
1932 IMListPref = &GeneralIMListPref;
1935 IMList = &HomeIMList;
1936 IMListType = &HomeIMListType;
1937 IMListAltID = &HomeIMListAltID;
1938 IMListPID = &HomeIMListPID;
1939 IMListTokens = &HomeIMListTokens;
1940 IMListMediatype = &HomeIMListMediatype;
1941 IMListPref = &HomeIMListPref;
1944 IMList = &BusinessIMList;
1945 IMListType = &BusinessIMListType;
1946 IMListAltID = &BusinessIMListAltID;
1947 IMListPID = &BusinessIMListPID;
1948 IMListTokens = &BusinessIMListTokens;
1949 IMListMediatype = &BusinessIMListMediatype;
1950 IMListPref = &BusinessIMListPref;
1956 std::map<int,int>::iterator SLiter;
1957 wxString PropertyData;
1958 wxString PropertyName;
1959 wxString PropertyValue;
1960 wxString PropertyTokens;
1961 bool FirstToken = TRUE;
1963 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1964 intiter != SplitPoints.end(); ++intiter){
1966 SLiter = SplitLength.find(intiter->first);
1968 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1970 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1971 PropertyName = PropertyElement.GetNextToken();
1972 PropertyValue = PropertyElement.GetNextToken();
1974 intPrevValue = intiter->second;
1976 CaptureString(&PropertyValue, FALSE);
1978 // Process properties.
1980 if (PropertyName == wxT("ALTID")){
1982 IMListAltID->erase(*IMCount);
1983 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1985 } else if (PropertyName == wxT("PID")){
1987 IMListPID->erase(*IMCount);
1988 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1990 } else if (PropertyName == wxT("MEDIATYPE")){
1992 IMListMediatype->erase(*IMCount);
1993 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1995 } else if (PropertyName == wxT("PREF")){
1997 int PriorityNumber = 0;
1998 bool ValidNumber = TRUE;
2001 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2004 catch(std::invalid_argument &e){
2005 ValidNumber = FALSE;
2008 if (ValidNumber == TRUE){
2010 IMListPref->erase(*IMCount);
2011 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2017 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2019 if (FirstToken == TRUE){
2021 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2026 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2036 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2038 // Add the name token data.
2040 if (!PropertyTokens.IsEmpty()){
2042 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2048 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2050 std::map<int, int> SplitPoints;
2051 std::map<int, int> SplitLength;
2052 std::map<int, int>::iterator SLiter;
2056 PropertyType PropType = PROPERTY_NONE;
2058 // Look for type before continuing.
2061 wxString TelTypeDetail;
2062 wxString PropertyData;
2063 wxString PropertyName;
2064 wxString PropertyValue;
2065 wxString PropertyTokens;
2067 std::map<int,int> TypeSplitPoints;
2068 std::map<int,int> TypeSplitLength;
2069 std::map<int,int>::iterator TSLiter;
2071 int intSplitSize = 0;
2072 int intSplitsFound = 0;
2073 int intSplitPoint = 0;
2075 int intPrevValue = 5;
2077 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2081 // Look for type before continuing.
2083 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2084 intiter != SplitPoints.end(); ++intiter){
2086 SLiter = SplitLength.find(intiter->first);
2088 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2090 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2091 PropertyName = PropertyElement.GetNextToken();
2092 PropertyValue = PropertyElement.GetNextToken();
2094 intPrevValue = intiter->second;
2096 if (PropertyName == wxT("TYPE")){
2098 // Process each value in type and translate each
2101 // Strip out the quotes if they are there.
2103 size_t intPropertyValueLen = PropertyValue.Len();
2105 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2107 PropertyValue.Trim();
2108 PropertyValue.RemoveLast();
2112 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2114 PropertyValue.Remove(0, 1);
2118 TelTypeDetail = PropertyValue;
2124 for (int i = 0; i <= intPropertyValueLen; i++){
2128 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2130 if (intSplitsFound == 0){
2132 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2133 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2137 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2138 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2151 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2152 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2154 int intTypeSeek = 0;
2156 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2157 typeiter != TypeSplitPoints.end(); ++typeiter){
2159 wxString TypePropertyName;
2161 TSLiter = TypeSplitLength.find(typeiter->first);
2163 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2165 if (intTypeSeek == 0){
2170 TelTypeUI.Append(wxT(","));
2174 if (TypePropertyName == wxT("home")){
2176 PropType = PROPERTY_HOME;
2178 } else if (TypePropertyName == wxT("work")){
2180 PropType = PROPERTY_WORK;
2185 if (TypePropertyName == wxT("text")){
2187 TelTypeUI.Append(_("text"));
2190 } else if (TypePropertyName == wxT("voice")){
2192 TelTypeUI.Append(_("voice"));
2195 } else if (TypePropertyName == wxT("fax")){
2197 TelTypeUI.Append(_("fax"));
2200 } else if (TypePropertyName == wxT("cell")){
2202 TelTypeUI.Append(_("mobile"));
2205 } else if (TypePropertyName == wxT("video")){
2207 TelTypeUI.Append(_("video"));
2210 } else if (TypePropertyName == wxT("pager")){
2212 TelTypeUI.Append(_("pager"));
2215 } else if (TypePropertyName == wxT("textphone")){
2217 TelTypeUI.Append(_("textphone"));
2228 std::map<int, wxString> *TelephoneList = NULL;
2229 std::map<int, wxString> *TelephoneListType = NULL;
2230 std::map<int, wxString> *TelephoneListAltID = NULL;
2231 std::map<int, wxString> *TelephoneListPID = NULL;
2232 std::map<int, wxString> *TelephoneListTokens = NULL;
2233 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2234 std::map<int, int> *TelephoneListPref = NULL;
2238 TelephoneList = &GeneralTelephoneList;
2239 TelephoneListType = &GeneralTelephoneListType;
2240 TelephoneListAltID = &GeneralTelephoneListAltID;
2241 TelephoneListPID = &GeneralTelephoneListPID;
2242 TelephoneListTokens = &GeneralTelephoneListTokens;
2243 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2244 TelephoneListPref = &GeneralTelephoneListPref;
2247 TelephoneList = &HomeTelephoneList;
2248 TelephoneListType = &HomeTelephoneListType;
2249 TelephoneListAltID = &HomeTelephoneListAltID;
2250 TelephoneListPID = &HomeTelephoneListPID;
2251 TelephoneListTokens = &HomeTelephoneListTokens;
2252 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2253 TelephoneListPref = &HomeTelephoneListPref;
2256 TelephoneList = &BusinessTelephoneList;
2257 TelephoneListType = &BusinessTelephoneListType;
2258 TelephoneListAltID = &BusinessTelephoneListAltID;
2259 TelephoneListPID = &BusinessTelephoneListPID;
2260 TelephoneListTokens = &BusinessTelephoneListTokens;
2261 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2262 TelephoneListPref = &BusinessTelephoneListPref;
2266 // Process the properties.
2268 bool FirstToken = TRUE;
2271 SplitPoints.clear();
2272 SplitLength.clear();
2274 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2278 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2279 intiter != SplitPoints.end(); ++intiter){
2281 SLiter = SplitLength.find(intiter->first);
2283 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2285 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2286 PropertyName = PropertyElement.GetNextToken();
2287 PropertyValue = PropertyElement.GetNextToken();
2289 intPrevValue = intiter->second;
2291 CaptureString(&PropertyValue, FALSE);
2293 // Process properties.
2295 if (PropertyName == wxT("ALTID")){
2297 TelephoneListAltID->erase(*TelephoneCount);
2298 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2300 } else if (PropertyName == wxT("PID")){
2302 TelephoneListPID->erase(*TelephoneCount);
2303 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2305 } else if (PropertyName == wxT("PREF")){
2307 int PriorityNumber = 0;
2308 bool ValidNumber = TRUE;
2311 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2314 catch(std::invalid_argument &e){
2315 ValidNumber = FALSE;
2318 if (ValidNumber == TRUE){
2320 TelephoneListPref->erase(*TelephoneCount);
2321 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2327 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2329 if (FirstToken == TRUE){
2331 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2336 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2346 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2347 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2349 // Add the name token data.
2351 if (!PropertyTokens.IsEmpty()){
2353 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2359 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2361 std::map<int, int> SplitPoints;
2362 std::map<int, int> SplitLength;
2364 int intPrevValue = 6;
2367 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2371 PropertyType PropType = PROPERTY_NONE;
2373 // Look for type before continuing.
2375 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2377 std::map<int, wxString> *LanguageList = NULL;
2378 std::map<int, wxString> *LanguageListType = NULL;
2379 std::map<int, wxString> *LanguageListAltID = NULL;
2380 std::map<int, wxString> *LanguageListPID = NULL;
2381 std::map<int, wxString> *LanguageListTokens = NULL;
2382 std::map<int, int> *LanguageListPref = NULL;
2386 LanguageList = &GeneralLanguageList;
2387 LanguageListType = &GeneralLanguageListType;
2388 LanguageListAltID = &GeneralLanguageListAltID;
2389 LanguageListPID = &GeneralLanguageListPID;
2390 LanguageListTokens = &GeneralLanguageListTokens;
2391 LanguageListPref = &GeneralLanguageListPref;
2394 LanguageList = &HomeLanguageList;
2395 LanguageListType = &HomeLanguageListType;
2396 LanguageListAltID = &HomeLanguageListAltID;
2397 LanguageListPID = &HomeLanguageListPID;
2398 LanguageListTokens = &HomeLanguageListTokens;
2399 LanguageListPref = &HomeLanguageListPref;
2402 LanguageList = &BusinessLanguageList;
2403 LanguageListType = &BusinessLanguageListType;
2404 LanguageListAltID = &BusinessLanguageListAltID;
2405 LanguageListPID = &BusinessLanguageListPID;
2406 LanguageListTokens = &BusinessLanguageListTokens;
2407 LanguageListPref = &BusinessLanguageListPref;
2413 std::map<int,int>::iterator SLiter;
2414 wxString PropertyData;
2415 wxString PropertyName;
2416 wxString PropertyValue;
2417 wxString PropertyTokens;
2418 bool FirstToken = TRUE;
2420 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2421 intiter != SplitPoints.end(); ++intiter){
2423 SLiter = SplitLength.find(intiter->first);
2425 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2427 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2428 PropertyName = PropertyElement.GetNextToken();
2429 PropertyValue = PropertyElement.GetNextToken();
2431 intPrevValue = intiter->second;
2433 CaptureString(&PropertyValue, FALSE);
2435 // Process properties.
2437 if (PropertyName == wxT("ALTID")){
2439 LanguageListAltID->erase(*LanguageCount);
2440 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2442 } else if (PropertyName == wxT("PID")){
2444 LanguageListPID->erase(*LanguageCount);
2445 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2447 } else if (PropertyName == wxT("PREF")){
2449 int PriorityNumber = 0;
2450 bool ValidNumber = TRUE;
2453 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2456 catch(std::invalid_argument &e){
2457 ValidNumber = FALSE;
2460 if (ValidNumber == TRUE){
2462 LanguageListPref->erase(*LanguageCount);
2463 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2469 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2471 if (FirstToken == TRUE){
2473 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2478 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2488 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2490 // Add the name token data.
2492 if (!PropertyTokens.IsEmpty()){
2494 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2500 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2502 std::map<int, int> SplitPoints;
2503 std::map<int, int> SplitLength;
2505 int intPrevValue = 5;
2508 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2512 PropertyType PropType = PROPERTY_NONE;
2514 // Look for type before continuing.
2516 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2518 std::map<int, wxString> *GeopositionList = NULL;
2519 std::map<int, wxString> *GeopositionListType = NULL;
2520 std::map<int, wxString> *GeopositionListAltID = NULL;
2521 std::map<int, wxString> *GeopositionListPID = NULL;
2522 std::map<int, wxString> *GeopositionListTokens = NULL;
2523 std::map<int, wxString> *GeopositionListMediatype = NULL;
2524 std::map<int, int> *GeopositionListPref = NULL;
2528 GeopositionList = &GeneralGeographyList;
2529 GeopositionListType = &GeneralGeographyListType;
2530 GeopositionListAltID = &GeneralGeographyListAltID;
2531 GeopositionListPID = &GeneralGeographyListPID;
2532 GeopositionListTokens = &GeneralGeographyListTokens;
2533 GeopositionListMediatype = &GeneralGeographyListMediatype;
2534 GeopositionListPref = &GeneralGeographyListPref;
2537 GeopositionList = &HomeGeographyList;
2538 GeopositionListType = &HomeGeographyListType;
2539 GeopositionListAltID = &HomeGeographyListAltID;
2540 GeopositionListPID = &HomeGeographyListPID;
2541 GeopositionListTokens = &HomeGeographyListTokens;
2542 GeopositionListMediatype = &HomeGeographyListMediatype;
2543 GeopositionListPref = &HomeGeographyListPref;
2546 GeopositionList = &BusinessGeographyList;
2547 GeopositionListType = &BusinessGeographyListType;
2548 GeopositionListAltID = &BusinessGeographyListAltID;
2549 GeopositionListPID = &BusinessGeographyListPID;
2550 GeopositionListTokens = &BusinessGeographyListTokens;
2551 GeopositionListMediatype = &BusinessGeographyListMediatype;
2552 GeopositionListPref = &BusinessGeographyListPref;
2558 std::map<int,int>::iterator SLiter;
2559 wxString PropertyData;
2560 wxString PropertyName;
2561 wxString PropertyValue;
2562 wxString PropertyTokens;
2563 bool FirstToken = TRUE;
2565 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2566 intiter != SplitPoints.end(); ++intiter){
2568 SLiter = SplitLength.find(intiter->first);
2570 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2572 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2573 PropertyName = PropertyElement.GetNextToken();
2574 PropertyValue = PropertyElement.GetNextToken();
2576 intPrevValue = intiter->second;
2578 CaptureString(&PropertyValue, FALSE);
2580 // Process properties.
2582 if (PropertyName == wxT("ALTID")){
2584 GeopositionListAltID->erase(*GeographicCount);
2585 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2587 } else if (PropertyName == wxT("PID")){
2589 GeopositionListPID->erase(*GeographicCount);
2590 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2592 } else if (PropertyName == wxT("MEDIATYPE")){
2594 GeopositionListMediatype->erase(*GeographicCount);
2595 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2597 } else if (PropertyName == wxT("PREF")){
2599 int PriorityNumber = 0;
2600 bool ValidNumber = TRUE;
2603 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2606 catch(std::invalid_argument &e){
2607 ValidNumber = FALSE;
2610 if (ValidNumber == TRUE){
2612 GeopositionListPref->erase(*GeographicCount);
2613 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2619 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2621 if (FirstToken == TRUE){
2623 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2628 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2638 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2640 // Add the name token data.
2642 if (!PropertyTokens.IsEmpty()){
2644 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2650 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2652 size_t intPropertyLen = PropertySeg1.Len();
2653 std::map<int, int> SplitPoints;
2654 std::map<int, int> SplitLength;
2655 std::map<int, int>::iterator SLiter;
2656 wxString PropertyData;
2657 wxString PropertyName;
2658 wxString PropertyValue;
2659 wxString PropertyTokens;
2660 wxString RelatedType;
2661 wxString RelatedTypeOriginal;
2662 wxString RelatedName;
2663 bool FirstToken = TRUE;
2664 int intSplitsFound = 0;
2665 int intSplitSize = 0;
2666 int intPrevValue = 9;
2670 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2674 // Look for type before continuing.
2676 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2677 intiter != SplitPoints.end(); ++intiter){
2679 SLiter = SplitLength.find(intiter->first);
2681 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2683 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2684 PropertyName = PropertyElement.GetNextToken();
2685 PropertyValue = PropertyElement.GetNextToken();
2687 intPrevValue = intiter->second;
2691 RelatedTypeOriginal = PropertyValue;
2693 if (PropertyName == wxT("TYPE")){
2695 if (PropertyValue == wxT("contact")){
2697 RelatedType = _("Contact");
2699 } else if (PropertyValue == wxT("acquaintance")){
2701 RelatedType = _("Acquaintance");
2703 } else if (PropertyValue == wxT("friend")){
2705 RelatedType = _("Friend");
2707 } else if (PropertyValue == wxT("met")){
2709 RelatedType = _("Met");
2711 } else if (PropertyValue == wxT("co-worker")){
2713 RelatedType = _("Co-worker");
2715 } else if (PropertyValue == wxT("colleague")){
2717 RelatedType = _("Colleague");
2719 } else if (PropertyValue == wxT("co-resident")){
2721 RelatedType = _("Co-resident");
2723 } else if (PropertyValue == wxT("neighbor")){
2725 RelatedType = _("Neighbour");
2727 } else if (PropertyValue == wxT("child")){
2729 RelatedType = _("Child");
2731 } else if (PropertyValue == wxT("parent")){
2733 RelatedType = _("Parent");
2735 } else if (PropertyValue == wxT("sibling")){
2737 RelatedType = _("Sibling");
2739 } else if (PropertyValue == wxT("spouse")){
2741 RelatedType = _("Spouse");
2743 } else if (PropertyValue == wxT("kin")){
2745 RelatedType = _("Kin");
2747 } else if (PropertyValue == wxT("muse")){
2749 RelatedType = _("Muse");
2751 } else if (PropertyValue == wxT("crush")){
2753 RelatedType = _("Crush");
2755 } else if (PropertyValue == wxT("date")){
2757 RelatedType = _("Date");
2759 } else if (PropertyValue == wxT("sweetheart")){
2761 RelatedType = _("Sweetheart");
2763 } else if (PropertyValue == wxT("me")){
2765 RelatedType = _("Me");
2767 } else if (PropertyValue == wxT("agent")){
2769 RelatedType = _("Agent");
2771 } else if (PropertyValue == wxT("emergency")){
2773 RelatedType = _("Emergency");
2777 RelatedType = PropertyValue;
2787 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2788 intiter != SplitPoints.end(); ++intiter){
2790 SLiter = SplitLength.find(intiter->first);
2792 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2794 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2795 PropertyName = PropertyElement.GetNextToken();
2796 PropertyValue = PropertyElement.GetNextToken();
2798 intPrevValue = intiter->second;
2800 // Process properties.
2802 size_t intPropertyValueLen = PropertyValue.Len();
2804 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2806 PropertyValue.Trim();
2807 PropertyValue.RemoveLast();
2811 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2813 PropertyValue.Remove(0, 1);
2817 CaptureString(&PropertyValue, FALSE);
2819 if (PropertyName == wxT("ALTID")){
2821 GeneralRelatedListAltID.erase(*RelatedCount);
2822 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2824 } else if (PropertyName == wxT("PID")){
2826 GeneralRelatedListPID.erase(*RelatedCount);
2827 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2829 } else if (PropertyName == wxT("PREF")){
2831 int PriorityNumber = 0;
2832 bool ValidNumber = TRUE;
2835 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2838 catch(std::invalid_argument &e){
2839 ValidNumber = FALSE;
2842 if (ValidNumber == TRUE){
2844 GeneralRelatedListPref.erase(*RelatedCount);
2845 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2849 } else if (PropertyName == wxT("LANGUAGE")){
2851 GeneralRelatedListLanguage.erase(*RelatedCount);
2852 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2854 } else if (PropertyName != wxT("TYPE")) {
2856 // Something else we don't know about so append
2857 // to the tokens variable.
2859 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2861 if (FirstToken == TRUE){
2863 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2868 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2878 // Add the data to the General/Home/Work address variables.
2880 GeneralRelatedList.erase(*RelatedCount);
2881 GeneralRelatedListRelType.erase(*RelatedCount);
2882 GeneralRelatedListType.erase(*RelatedCount);
2883 GeneralRelatedListTokens.erase(*RelatedCount);
2884 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2885 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2886 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2887 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2891 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2893 std::map<int, int> SplitPoints;
2894 std::map<int, int> SplitLength;
2895 std::map<int, int>::iterator SLiter;
2896 wxString PropertyData;
2897 wxString PropertyName;
2898 wxString PropertyValue;
2899 wxString PropertyTokens;
2900 bool FirstToken = TRUE;
2901 int intPrevValue = 5;
2906 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2910 PropertyType PropType = PROPERTY_NONE;
2912 // Look for type before continuing.
2914 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2916 // Setup the pointers.
2918 std::map<int, wxString> *WebsiteList = NULL;
2919 std::map<int, wxString> *WebsiteListAltID = NULL;
2920 std::map<int, wxString> *WebsiteListPID = NULL;
2921 std::map<int, wxString> *WebsiteListType = NULL;
2922 std::map<int, wxString> *WebsiteListTokens = NULL;
2923 std::map<int, wxString> *WebsiteListMediatype = NULL;
2924 std::map<int, int> *WebsiteListPref = NULL;
2926 // Setup blank lines for later on.
2930 WebsiteList = &GeneralWebsiteList;
2931 WebsiteListType = &GeneralWebsiteListType;
2932 WebsiteListAltID = &GeneralWebsiteListAltID;
2933 WebsiteListPID = &GeneralWebsiteListPID;
2934 WebsiteListTokens = &GeneralWebsiteListTokens;
2935 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2936 WebsiteListPref = &GeneralWebsiteListPref;
2939 WebsiteList = &HomeWebsiteList;
2940 WebsiteListType = &HomeWebsiteListType;
2941 WebsiteListAltID = &HomeWebsiteListAltID;
2942 WebsiteListPID = &HomeWebsiteListPID;
2943 WebsiteListTokens = &HomeWebsiteListTokens;
2944 WebsiteListMediatype = &HomeWebsiteListMediatype;
2945 WebsiteListPref = &HomeWebsiteListPref;
2948 WebsiteList = &BusinessWebsiteList;
2949 WebsiteListType = &BusinessWebsiteListType;
2950 WebsiteListAltID = &BusinessWebsiteListAltID;
2951 WebsiteListPID = &BusinessWebsiteListPID;
2952 WebsiteListTokens = &BusinessWebsiteListTokens;
2953 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2954 WebsiteListPref = &BusinessWebsiteListPref;
2960 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2961 intiter != SplitPoints.end(); ++intiter){
2963 SLiter = SplitLength.find(intiter->first);
2965 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2967 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2968 PropertyName = PropertyElement.GetNextToken();
2969 PropertyValue = PropertyElement.GetNextToken();
2971 intPrevValue = intiter->second;
2973 // Process properties.
2975 size_t intPropertyValueLen = PropertyValue.Len();
2977 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2979 PropertyValue.Trim();
2980 PropertyValue.RemoveLast();
2984 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2986 PropertyValue.Remove(0, 1);
2990 CaptureString(&PropertyValue, FALSE);
2992 if (PropertyName == wxT("ALTID")){
2994 WebsiteListAltID->erase(*URLCount);
2995 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2997 } else if (PropertyName == wxT("PID")){
2999 WebsiteListPID->erase(*URLCount);
3000 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3002 } else if (PropertyName == wxT("PREF")){
3004 int PriorityNumber = 0;
3005 bool ValidNumber = TRUE;
3008 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3011 catch(std::invalid_argument &e){
3012 ValidNumber = FALSE;
3015 if (ValidNumber == TRUE){
3017 WebsiteListPref->erase(*URLCount);
3018 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3022 } else if (PropertyName == wxT("MEDIATYPE")){
3024 WebsiteListMediatype->erase(*URLCount);
3025 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3029 // Something else we don't know about so append
3030 // to the tokens variable.
3032 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3034 if (FirstToken == TRUE){
3036 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3041 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3051 // Add the data to the General/Home/Work address variables.
3053 CaptureString(&PropertySeg2, FALSE);
3055 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3057 if (!PropertyTokens.IsEmpty()){
3059 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3065 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3067 std::map<int, int> SplitPoints;
3068 std::map<int, int> SplitLength;
3069 std::map<int, int>::iterator SLiter;
3070 wxString PropertyData;
3071 wxString PropertyName;
3072 wxString PropertyValue;
3073 wxString PropertyTokens;
3074 bool FirstToken = TRUE;
3075 int intPrevValue = 7;
3080 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3084 PropertyType PropType = PROPERTY_NONE;
3086 // Look for type before continuing.
3088 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3090 // Setup the pointers.
3092 std::map<int, wxString> *TitleList = NULL;
3093 std::map<int, wxString> *TitleListAltID = NULL;
3094 std::map<int, wxString> *TitleListPID = NULL;
3095 std::map<int, wxString> *TitleListType = NULL;
3096 std::map<int, wxString> *TitleListTokens = NULL;
3097 std::map<int, wxString> *TitleListLanguage = NULL;
3098 std::map<int, int> *TitleListPref = NULL;
3100 // Setup blank lines for later on.
3104 TitleList = &GeneralTitleList;
3105 TitleListType = &GeneralTitleListType;
3106 TitleListAltID = &GeneralTitleListAltID;
3107 TitleListPID = &GeneralTitleListPID;
3108 TitleListTokens = &GeneralTitleListTokens;
3109 TitleListLanguage = &GeneralTitleListLanguage;
3110 TitleListPref = &GeneralTitleListPref;
3113 TitleList = &HomeTitleList;
3114 TitleListType = &HomeTitleListType;
3115 TitleListAltID = &HomeTitleListAltID;
3116 TitleListPID = &HomeTitleListPID;
3117 TitleListTokens = &HomeTitleListTokens;
3118 TitleListLanguage = &HomeTitleListLanguage;
3119 TitleListPref = &HomeTitleListPref;
3122 TitleList = &BusinessTitleList;
3123 TitleListType = &BusinessTitleListType;
3124 TitleListAltID = &BusinessTitleListAltID;
3125 TitleListPID = &BusinessTitleListPID;
3126 TitleListTokens = &BusinessTitleListTokens;
3127 TitleListLanguage = &BusinessTitleListLanguage;
3128 TitleListPref = &BusinessTitleListPref;
3134 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3135 intiter != SplitPoints.end(); ++intiter){
3137 SLiter = SplitLength.find(intiter->first);
3139 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3141 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3142 PropertyName = PropertyElement.GetNextToken();
3143 PropertyValue = PropertyElement.GetNextToken();
3145 intPrevValue = intiter->second;
3147 // Process properties.
3149 size_t intPropertyValueLen = PropertyValue.Len();
3151 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3153 PropertyValue.Trim();
3154 PropertyValue.RemoveLast();
3158 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3160 PropertyValue.Remove(0, 1);
3164 CaptureString(&PropertyValue, FALSE);
3166 if (PropertyName == wxT("ALTID")){
3168 TitleListAltID->erase(*TitleCount);
3169 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3171 } else if (PropertyName == wxT("PID")){
3173 TitleListPID->erase(*TitleCount);
3174 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3176 } else if (PropertyName == wxT("PREF")){
3178 int PriorityNumber = 0;
3179 bool ValidNumber = TRUE;
3182 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3185 catch(std::invalid_argument &e){
3186 ValidNumber = FALSE;
3189 if (ValidNumber == TRUE){
3191 TitleListPref->erase(*TitleCount);
3192 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3196 } else if (PropertyName == wxT("LANGUAGE")){
3198 TitleListLanguage->erase(*TitleCount);
3199 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3203 // Something else we don't know about so append
3204 // to the tokens variable.
3206 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3208 if (FirstToken == TRUE){
3210 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3215 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3225 // Add the data to the General/Home/Work address variables.
3227 CaptureString(&PropertySeg2, FALSE);
3229 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3231 if (!PropertyTokens.IsEmpty()){
3233 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3239 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3241 std::map<int, int> SplitPoints;
3242 std::map<int, int> SplitLength;
3243 std::map<int, int>::iterator SLiter;
3244 wxString PropertyData;
3245 wxString PropertyName;
3246 wxString PropertyValue;
3247 wxString PropertyTokens;
3248 bool FirstToken = TRUE;
3249 int intPrevValue = 6;
3254 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3258 PropertyType PropType = PROPERTY_NONE;
3260 // Look for type before continuing.
3262 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3264 // Setup the pointers.
3266 std::map<int, wxString> *RoleList = NULL;
3267 std::map<int, wxString> *RoleListAltID = NULL;
3268 std::map<int, wxString> *RoleListPID = NULL;
3269 std::map<int, wxString> *RoleListType = NULL;
3270 std::map<int, wxString> *RoleListTokens = NULL;
3271 std::map<int, wxString> *RoleListLanguage = NULL;
3272 std::map<int, int> *RoleListPref = NULL;
3274 // Setup blank lines for later on.
3278 RoleList = &GeneralRoleList;
3279 RoleListType = &GeneralRoleListType;
3280 RoleListAltID = &GeneralRoleListAltID;
3281 RoleListPID = &GeneralRoleListPID;
3282 RoleListTokens = &GeneralRoleListTokens;
3283 RoleListLanguage = &GeneralRoleListLanguage;
3284 RoleListPref = &GeneralRoleListPref;
3287 RoleList = &HomeRoleList;
3288 RoleListType = &HomeRoleListType;
3289 RoleListAltID = &HomeRoleListAltID;
3290 RoleListPID = &HomeRoleListPID;
3291 RoleListTokens = &HomeRoleListTokens;
3292 RoleListLanguage = &HomeRoleListLanguage;
3293 RoleListPref = &HomeRoleListPref;
3296 RoleList = &BusinessRoleList;
3297 RoleListType = &BusinessRoleListType;
3298 RoleListAltID = &BusinessRoleListAltID;
3299 RoleListPID = &BusinessRoleListPID;
3300 RoleListTokens = &BusinessRoleListTokens;
3301 RoleListLanguage = &BusinessRoleListLanguage;
3302 RoleListPref = &BusinessRoleListPref;
3308 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3309 intiter != SplitPoints.end(); ++intiter){
3311 SLiter = SplitLength.find(intiter->first);
3313 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3315 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3316 PropertyName = PropertyElement.GetNextToken();
3317 PropertyValue = PropertyElement.GetNextToken();
3319 intPrevValue = intiter->second;
3321 // Process properties.
3323 size_t intPropertyValueLen = PropertyValue.Len();
3325 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3327 PropertyValue.Trim();
3328 PropertyValue.RemoveLast();
3332 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3334 PropertyValue.Remove(0, 1);
3338 CaptureString(&PropertyValue, FALSE);
3340 if (PropertyName == wxT("ALTID")){
3342 RoleListAltID->erase(*RoleCount);
3343 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3345 } else if (PropertyName == wxT("PID")){
3347 RoleListPID->erase(*RoleCount);
3348 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3350 } else if (PropertyName == wxT("PREF")){
3352 int PriorityNumber = 0;
3353 bool ValidNumber = TRUE;
3356 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3359 catch(std::invalid_argument &e){
3360 ValidNumber = FALSE;
3363 if (ValidNumber == TRUE){
3365 RoleListPref->erase(*RoleCount);
3366 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3370 } else if (PropertyName == wxT("LANGUAGE")){
3372 RoleListLanguage->erase(*RoleCount);
3373 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3377 // Something else we don't know about so append
3378 // to the tokens variable.
3380 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3382 if (FirstToken == TRUE){
3384 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3389 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3399 // Add the data to the General/Home/Work address variables.
3401 CaptureString(&PropertySeg2, FALSE);
3403 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3405 if (!PropertyTokens.IsEmpty()){
3407 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3413 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3415 std::map<int, int> SplitPoints;
3416 std::map<int, int> SplitLength;
3417 std::map<int, int>::iterator SLiter;
3418 wxString PropertyData;
3419 wxString PropertyName;
3420 wxString PropertyValue;
3421 wxString PropertyTokens;
3422 bool FirstToken = TRUE;
3423 int intPrevValue = 5;
3428 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3432 PropertyType PropType = PROPERTY_NONE;
3434 // Look for type before continuing.
3436 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3438 // Setup the pointers.
3440 std::map<int, wxString> *OrganisationsList = NULL;
3441 std::map<int, wxString> *OrganisationsListAltID = NULL;
3442 std::map<int, wxString> *OrganisationsListPID = NULL;
3443 std::map<int, wxString> *OrganisationsListType = NULL;
3444 std::map<int, wxString> *OrganisationsListTokens = NULL;
3445 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3446 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3447 std::map<int, int> *OrganisationsListPref = NULL;
3449 // Setup blank lines for later on.
3453 OrganisationsList = &GeneralOrganisationsList;
3454 OrganisationsListType = &GeneralOrganisationsListType;
3455 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3456 OrganisationsListPID = &GeneralOrganisationsListPID;
3457 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3458 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3459 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3460 OrganisationsListPref = &GeneralOrganisationsListPref;
3463 OrganisationsList = &HomeOrganisationsList;
3464 OrganisationsListType = &HomeOrganisationsListType;
3465 OrganisationsListAltID = &HomeOrganisationsListAltID;
3466 OrganisationsListPID = &HomeOrganisationsListPID;
3467 OrganisationsListTokens = &HomeOrganisationsListTokens;
3468 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3469 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3470 OrganisationsListPref = &HomeOrganisationsListPref;
3473 OrganisationsList = &BusinessOrganisationsList;
3474 OrganisationsListType = &BusinessOrganisationsListType;
3475 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3476 OrganisationsListPID = &BusinessOrganisationsListPID;
3477 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3478 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3479 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3480 OrganisationsListPref = &BusinessOrganisationsListPref;
3486 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3487 intiter != SplitPoints.end(); ++intiter){
3489 SLiter = SplitLength.find(intiter->first);
3491 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3493 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3494 PropertyName = PropertyElement.GetNextToken();
3495 PropertyValue = PropertyElement.GetNextToken();
3497 intPrevValue = intiter->second;
3499 // Process properties.
3501 size_t intPropertyValueLen = PropertyValue.Len();
3503 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3505 PropertyValue.Trim();
3506 PropertyValue.RemoveLast();
3510 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3512 PropertyValue.Remove(0, 1);
3516 CaptureString(&PropertyValue, FALSE);
3518 if (PropertyName == wxT("ALTID")){
3520 OrganisationsListAltID->erase(*OrganisationCount);
3521 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3523 } else if (PropertyName == wxT("PID")){
3525 OrganisationsListPID->erase(*OrganisationCount);
3526 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3528 } else if (PropertyName == wxT("SORT-AS")){
3530 OrganisationsListSortAs->erase(*OrganisationCount);
3531 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3533 } else if (PropertyName == wxT("PREF")){
3535 int PriorityNumber = 0;
3536 bool ValidNumber = TRUE;
3539 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3542 catch(std::invalid_argument &e){
3543 ValidNumber = FALSE;
3546 if (ValidNumber == TRUE){
3548 OrganisationsListPref->erase(*OrganisationCount);
3549 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3553 } else if (PropertyName == wxT("LANGUAGE")){
3555 OrganisationsListLanguage->erase(*OrganisationCount);
3556 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3560 // Something else we don't know about so append
3561 // to the tokens variable.
3563 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3565 if (FirstToken == TRUE){
3567 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3572 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3582 // Add the data to the General/Home/Work address variables.
3584 CaptureString(&PropertySeg2, FALSE);
3586 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3588 if (!PropertyTokens.IsEmpty()){
3590 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3596 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3598 std::map<int, int> SplitPoints;
3599 std::map<int, int> SplitLength;
3600 std::map<int, int>::iterator SLiter;
3601 wxString PropertyData;
3602 wxString PropertyName;
3603 wxString PropertyValue;
3604 wxString PropertyTokens;
3605 bool FirstToken = TRUE;
3606 int intPrevValue = 6;
3611 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3615 PropertyType PropType = PROPERTY_NONE;
3617 // Look for type before continuing.
3619 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3621 // Setup the pointers.
3623 std::map<int, wxString> *NoteList = NULL;
3624 std::map<int, wxString> *NoteListAltID = NULL;
3625 std::map<int, wxString> *NoteListPID = NULL;
3626 std::map<int, wxString> *NoteListType = NULL;
3627 std::map<int, wxString> *NoteListTokens = NULL;
3628 std::map<int, wxString> *NoteListLanguage = NULL;
3629 std::map<int, int> *NoteListPref = NULL;
3631 // Setup blank lines for later on.
3635 NoteList = &GeneralNoteList;
3636 NoteListType = &GeneralNoteListType;
3637 NoteListAltID = &GeneralNoteListAltID;
3638 NoteListPID = &GeneralNoteListPID;
3639 NoteListTokens = &GeneralNoteListTokens;
3640 NoteListLanguage = &GeneralNoteListLanguage;
3641 NoteListPref = &GeneralNoteListPref;
3644 NoteList = &HomeNoteList;
3645 NoteListType = &HomeNoteListType;
3646 NoteListAltID = &HomeNoteListAltID;
3647 NoteListPID = &HomeNoteListPID;
3648 NoteListTokens = &HomeNoteListTokens;
3649 NoteListLanguage = &HomeNoteListLanguage;
3650 NoteListPref = &HomeNoteListPref;
3653 NoteList = &BusinessNoteList;
3654 NoteListType = &BusinessNoteListType;
3655 NoteListAltID = &BusinessNoteListAltID;
3656 NoteListPID = &BusinessNoteListPID;
3657 NoteListTokens = &BusinessNoteListTokens;
3658 NoteListLanguage = &BusinessNoteListLanguage;
3659 NoteListPref = &BusinessNoteListPref;
3665 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3666 intiter != SplitPoints.end(); ++intiter){
3668 SLiter = SplitLength.find(intiter->first);
3670 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3672 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3673 PropertyName = PropertyElement.GetNextToken();
3674 PropertyValue = PropertyElement.GetNextToken();
3676 intPrevValue = intiter->second;
3678 // Process properties.
3680 size_t intPropertyValueLen = PropertyValue.Len();
3682 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3684 PropertyValue.Trim();
3685 PropertyValue.RemoveLast();
3689 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3691 PropertyValue.Remove(0, 1);
3695 CaptureString(&PropertyValue, FALSE);
3697 if (PropertyName == wxT("ALTID")){
3699 NoteListAltID->erase(*NoteCount);
3700 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3702 } else if (PropertyName == wxT("PID")){
3704 NoteListPID->erase(*NoteCount);
3705 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3707 } else if (PropertyName == wxT("PREF")){
3709 int PriorityNumber = 0;
3710 bool ValidNumber = TRUE;
3713 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3716 catch(std::invalid_argument &e){
3717 ValidNumber = FALSE;
3720 if (ValidNumber == TRUE){
3722 NoteListPref->erase(*NoteCount);
3723 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3727 } else if (PropertyName == wxT("LANGUAGE")){
3729 NoteListLanguage->erase(*NoteCount);
3730 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3734 // Something else we don't know about so append
3735 // to the tokens variable.
3737 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3739 if (FirstToken == TRUE){
3741 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3746 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3756 // Add the data to the General/Home/Work address variables.
3758 CaptureString(&PropertySeg2, FALSE);
3760 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3762 if (!PropertyTokens.IsEmpty()){
3764 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3770 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3772 std::map<int, int> SplitPoints;
3773 std::map<int, int> SplitLength;
3774 std::map<int, int>::iterator SLiter;
3775 wxString PropertyData;
3776 wxString PropertyName;
3777 wxString PropertyValue;
3778 wxString PropertyTokens;
3779 bool FirstToken = TRUE;
3780 int intPrevValue = 12;
3785 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3789 PropertyType PropType = PROPERTY_NONE;
3791 // Look for type before continuing.
3793 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3795 // Setup blank lines for later on.
3801 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3804 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3810 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3811 intiter != SplitPoints.end(); ++intiter){
3813 SLiter = SplitLength.find(intiter->first);
3815 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3817 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3818 PropertyName = PropertyElement.GetNextToken();
3819 PropertyValue = PropertyElement.GetNextToken();
3821 intPrevValue = intiter->second;
3823 // Process properties.
3825 size_t intPropertyValueLen = PropertyValue.Len();
3827 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3829 PropertyValue.Trim();
3830 PropertyValue.RemoveLast();
3834 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3836 PropertyValue.Remove(0, 1);
3840 CaptureString(&PropertyValue, FALSE);
3842 if (PropertyName == wxT("ALTID")){
3844 CategoriesListAltID.erase(*CategoryCount);
3845 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3847 } else if (PropertyName == wxT("PID")){
3849 CategoriesListPID.erase(*CategoryCount);
3850 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3852 } else if (PropertyName == wxT("PREF")){
3854 int PriorityNumber = 0;
3855 bool ValidNumber = TRUE;
3858 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3861 catch(std::invalid_argument &e){
3862 ValidNumber = FALSE;
3865 if (ValidNumber == TRUE){
3867 CategoriesListPref.erase(*CategoryCount);
3868 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3872 } else if (PropertyName == wxT("LANGUAGE")){
3874 CategoriesListLanguage.erase(*CategoryCount);
3875 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3879 // Something else we don't know about so append
3880 // to the tokens variable.
3882 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3884 if (FirstToken == TRUE){
3886 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3891 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3901 // Deal with multiple categories.
3903 int intOrigCatCount = *CategoryCount;
3904 bool FirstCategoryProcessed = TRUE;
3905 bool AfterFirstToken = FALSE;
3906 int intSplitSize = 0;
3907 int intSplitsFound = 0;
3908 int intSplitSeek = 0;
3909 int intPropertyLen = PropertySeg2.Len();
3911 SplitPoints.clear();
3912 SplitLength.clear();
3915 for (int i = 0; i <= intPropertyLen; i++){
3917 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3925 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3927 if (AfterFirstToken == TRUE){
3929 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3930 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3934 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3935 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3936 AfterFirstToken = TRUE;
3948 if (SplitPoints.size() > 0){
3950 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3951 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3955 if (SplitPoints.size() == 0){
3957 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3959 if (!PropertyTokens.IsEmpty()){
3961 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3967 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3968 intiter != SplitPoints.end(); ++intiter){
3970 SLiter = SplitLength.find(intiter->first);
3972 intPrevValue = intiter->second;
3974 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3976 // Add the data to the General/Home/Work address variables.
3978 // Trim any whitespace from the start and end.
3980 PropertyData = PropertyData.Trim(FALSE);
3981 PropertyData = PropertyData.Trim(TRUE);
3983 CaptureString(&PropertyData, FALSE);
3985 if (FirstCategoryProcessed == TRUE){
3987 FirstCategoryProcessed = FALSE;
3989 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3991 if (!PropertyTokens.IsEmpty()){
3993 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4003 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4005 if (!PropertyTokens.IsEmpty()){
4007 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4013 // Copy the properties to each of the categories (if it exists).
4015 if (!PropertyTokens.IsEmpty()){
4017 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4021 // Check if ALTID was used.
4023 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4025 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4029 // Check if PID was used.
4031 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4033 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4037 // Check if PREF was used.
4039 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4041 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4045 // Check if LANGUAGE was used.
4047 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4049 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4053 // Check if TYPE was used.
4059 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4062 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4070 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4072 size_t intPropertyLen = PropertySeg1.Len();
4073 std::map<int, int> SplitPoints;
4074 std::map<int, int> SplitLength;
4075 std::map<int, int>::iterator SLiter;
4076 wxString PropertyData;
4077 wxString PropertyName;
4078 wxString PropertyValue;
4079 wxString PropertyTokens;
4080 bool FirstToken = TRUE;
4081 int intSplitsFound = 0;
4082 int intSplitSize = 0;
4083 int intPrevValue = 7;
4087 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4091 PropertyType PropType = PROPERTY_NONE;
4093 // Look for type before continuing.
4095 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4099 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4100 intiter != SplitPoints.end(); ++intiter){
4102 SLiter = SplitLength.find(intiter->first);
4104 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4106 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4107 PropertyName = PropertyElement.GetNextToken();
4108 PropertyValue = PropertyElement.GetNextToken();
4110 intPrevValue = intiter->second;
4112 // Process properties.
4114 size_t intPropertyValueLen = PropertyValue.Len();
4116 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4118 PropertyValue.Trim();
4119 PropertyValue.RemoveLast();
4123 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4125 PropertyValue.Remove(0, 1);
4129 CaptureString(&PropertyValue, FALSE);
4131 if (PropertyName == wxT("ALTID")){
4133 PicturesListAltID.erase(*PhotoCount);
4134 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4136 } else if (PropertyName == wxT("PID")){
4138 PicturesListPID.erase(*PhotoCount);
4139 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4141 } else if (PropertyName == wxT("PREF")){
4143 int PriorityNumber = 0;
4144 bool ValidNumber = TRUE;
4147 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4150 catch(std::invalid_argument &e){
4151 ValidNumber = FALSE;
4154 if (ValidNumber == TRUE){
4156 PicturesListPref.erase(*PhotoCount);
4157 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4161 } else if (PropertyName == wxT("MEDIATYPE")){
4163 PicturesListMediatype.erase(*PhotoCount);
4164 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4168 // Something else we don't know about so append
4169 // to the tokens variable.
4171 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4173 if (FirstToken == TRUE){
4175 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4180 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4190 intPropertyLen = PropertySeg2.Len();
4191 SplitPoints.clear();
4192 SplitLength.clear();
4197 CaptureString(&PropertySeg2, FALSE);
4199 for (int i = 0; i <= intPropertyLen; i++){
4203 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4206 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4208 if (intSplitsFound == 6){
4210 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4215 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4225 wxString wxSPhotoURI;
4226 wxString wxSPhotoMIME;
4227 wxString wxSPhotoEncoding;
4228 wxString wxSPhotoData;
4229 std::string base64enc;
4231 if (intSplitsFound == 0){
4235 std::map<int, int>::iterator striter;
4237 striter = SplitLength.find(1);
4239 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4241 while (wSTDataType.HasMoreTokens() == TRUE){
4243 wxSPhotoURI = wSTDataType.GetNextToken();
4244 wxSPhotoMIME = wSTDataType.GetNextToken();
4249 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4251 while (wSTDataInfo.HasMoreTokens() == TRUE){
4253 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4254 wxSPhotoData = wSTDataInfo.GetNextToken();
4255 base64enc = wxSPhotoData.mb_str();
4262 // Add the data to the General/Home/Work address variables.
4264 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4265 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4266 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4272 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4275 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4279 if (!PropertyTokens.IsEmpty()){
4281 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4287 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4289 size_t intPropertyLen = PropertySeg1.Len();
4290 std::map<int, int> SplitPoints;
4291 std::map<int, int> SplitLength;
4292 std::map<int, int>::iterator SLiter;
4293 wxString PropertyData;
4294 wxString PropertyName;
4295 wxString PropertyValue;
4296 wxString PropertyTokens;
4297 bool FirstToken = TRUE;
4298 int intSplitsFound = 0;
4299 int intSplitSize = 0;
4300 int intPrevValue = 6;
4304 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4308 PropertyType PropType = PROPERTY_NONE;
4310 // Look for type before continuing.
4312 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4316 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4317 intiter != SplitPoints.end(); ++intiter){
4319 SLiter = SplitLength.find(intiter->first);
4321 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4323 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4324 PropertyName = PropertyElement.GetNextToken();
4325 PropertyValue = PropertyElement.GetNextToken();
4327 intPrevValue = intiter->second;
4329 // Process properties.
4331 size_t intPropertyValueLen = PropertyValue.Len();
4333 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4335 PropertyValue.Trim();
4336 PropertyValue.RemoveLast();
4340 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4342 PropertyValue.Remove(0, 1);
4346 CaptureString(&PropertyValue, FALSE);
4348 if (PropertyName == wxT("ALTID")){
4350 LogosListAltID.erase(*LogoCount);
4351 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4353 } else if (PropertyName == wxT("PID")){
4355 LogosListPID.erase(*LogoCount);
4356 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4358 } else if (PropertyName == wxT("PREF")){
4360 int PriorityNumber = 0;
4361 bool ValidNumber = TRUE;
4364 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4367 catch(std::invalid_argument &e){
4368 ValidNumber = FALSE;
4371 if (ValidNumber == TRUE){
4373 LogosListPref.erase(*LogoCount);
4374 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4378 } else if (PropertyName == wxT("MEDIATYPE")){
4380 LogosListMediatype.erase(*LogoCount);
4381 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4385 // Something else we don't know about so append
4386 // to the tokens variable.
4388 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4390 if (FirstToken == TRUE){
4392 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4397 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4407 intPropertyLen = PropertySeg2.Len();
4408 SplitPoints.clear();
4409 SplitLength.clear();
4414 CaptureString(&PropertySeg2, FALSE);
4416 for (int i = 0; i <= intPropertyLen; i++){
4420 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4423 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4425 if (intSplitsFound == 6){
4427 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4432 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4442 wxString wxSPhotoURI;
4443 wxString wxSPhotoMIME;
4444 wxString wxSPhotoEncoding;
4445 wxString wxSPhotoData;
4446 std::string base64enc;
4448 if (intSplitsFound == 0){
4452 std::map<int, int>::iterator striter;
4454 striter = SplitLength.find(1);
4456 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4458 while (wSTDataType.HasMoreTokens() == TRUE){
4460 wxSPhotoURI = wSTDataType.GetNextToken();
4461 wxSPhotoMIME = wSTDataType.GetNextToken();
4466 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4468 while (wSTDataInfo.HasMoreTokens() == TRUE){
4470 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4471 wxSPhotoData = wSTDataInfo.GetNextToken();
4472 base64enc = wxSPhotoData.mb_str();
4479 // Add the data to the General/Home/Work address variables.
4481 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4482 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4483 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4489 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4492 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4496 if (!PropertyTokens.IsEmpty()){
4498 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4504 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4506 size_t intPropertyLen = PropertySeg1.Len();
4507 std::map<int, int> SplitPoints;
4508 std::map<int, int> SplitLength;
4509 std::map<int, int>::iterator SLiter;
4510 wxString PropertyData;
4511 wxString PropertyName;
4512 wxString PropertyValue;
4513 wxString PropertyTokens;
4514 bool FirstToken = TRUE;
4515 int intSplitsFound = 0;
4516 int intSplitSize = 0;
4517 int intPrevValue = 7;
4521 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4525 PropertyType PropType = PROPERTY_NONE;
4527 // Look for type before continuing.
4529 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4533 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4534 intiter != SplitPoints.end(); ++intiter){
4536 SLiter = SplitLength.find(intiter->first);
4538 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4540 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4541 PropertyName = PropertyElement.GetNextToken();
4542 PropertyValue = PropertyElement.GetNextToken();
4544 intPrevValue = intiter->second;
4546 // Process properties.
4548 size_t intPropertyValueLen = PropertyValue.Len();
4550 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4552 PropertyValue.Trim();
4553 PropertyValue.RemoveLast();
4557 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4559 PropertyValue.Remove(0, 1);
4563 CaptureString(&PropertyValue, FALSE);
4565 if (PropertyName == wxT("ALTID")){
4567 SoundsListAltID.erase(*SoundCount);
4568 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4570 } else if (PropertyName == wxT("PID")){
4572 SoundsListPID.erase(*SoundCount);
4573 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4575 } else if (PropertyName == wxT("PREF")){
4577 int PriorityNumber = 0;
4578 bool ValidNumber = TRUE;
4581 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4584 catch(std::invalid_argument &e){
4585 ValidNumber = FALSE;
4588 if (ValidNumber == TRUE){
4590 SoundsListPref.erase(*SoundCount);
4591 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4595 } else if (PropertyName == wxT("MEDIATYPE")){
4597 SoundsListMediatype.erase(*SoundCount);
4598 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4600 } else if (PropertyName == wxT("LANGUAGE")){
4602 SoundsListLanguage.erase(*SoundCount);
4603 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4607 // Something else we don't know about so append
4608 // to the tokens variable.
4610 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4612 if (FirstToken == TRUE){
4614 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4619 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4629 intPropertyLen = PropertySeg2.Len();
4630 SplitPoints.clear();
4631 SplitLength.clear();
4636 CaptureString(&PropertySeg2, FALSE);
4638 for (int i = 0; i <= intPropertyLen; i++){
4642 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4645 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4647 if (intSplitsFound == 6){
4649 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4654 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4664 wxString wxSSoundURI;
4665 wxString wxSSoundMIME;
4666 wxString wxSSoundEncoding;
4667 wxString wxSSoundData;
4668 std::string base64enc;
4670 if (intSplitsFound == 0){
4674 std::map<int, int>::iterator striter;
4676 striter = SplitLength.find(1);
4678 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4680 while (wSTDataType.HasMoreTokens() == TRUE){
4682 wxSSoundURI = wSTDataType.GetNextToken();
4683 wxSSoundMIME = wSTDataType.GetNextToken();
4688 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4690 while (wSTDataInfo.HasMoreTokens() == TRUE){
4692 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4693 wxSSoundData = wSTDataInfo.GetNextToken();
4694 base64enc = wxSSoundData.mb_str();
4701 // Add the data to the General/Home/Work address variables.
4707 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4710 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4714 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4715 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4716 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4718 if (!PropertyTokens.IsEmpty()){
4720 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4726 void SplitValues(wxString *PropertyLine,
4727 std::map<int,int> *SplitPoints,
4728 std::map<int,int> *SplitLength,
4731 size_t intPropertyLen = PropertyLine->Len();
4732 int intSplitsFound = 0;
4733 int intSplitSize = 0;
4734 int intSplitSeek = 0;
4736 for (int i = intSize; i <= intPropertyLen; i++){
4740 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4741 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4743 if (intSplitsFound == 0){
4745 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4749 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4753 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4763 if (intSplitsFound == 0){
4765 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4766 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4770 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4771 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4777 void CheckType(wxString *PropertySeg1,
4778 std::map<int,int> *SplitPoints,
4779 std::map<int,int> *SplitLength,
4781 PropertyType *PropType){
4783 wxString PropertyData;
4784 wxString PropertyName;
4785 wxString PropertyValue;
4786 std::map<int,int>::iterator SLiter;
4788 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
4789 intiter != SplitPoints->end(); ++intiter){
4791 SLiter = SplitLength->find(intiter->first);
4793 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4795 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4796 PropertyName = PropertyElement.GetNextToken();
4797 PropertyValue = PropertyElement.GetNextToken();
4799 *intPrevValue = intiter->second;
4801 if (PropertyName == wxT("TYPE")){
4803 if (PropertyValue == wxT("work")){
4805 *PropType = PROPERTY_WORK;
4807 } else if (PropertyValue == wxT("home")){
4809 *PropType = PROPERTY_HOME;
4813 *PropType = PROPERTY_NONE;