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 bool UIDProcessed = FALSE;
82 int ContactLineLen = 0;
83 int QuoteBreakPoint = 0;
87 int NicknameCount = 0;
88 int TimeZoneCount = 0;
92 int TelephoneCount = 0;
93 int LanguageCount = 0;
94 int GeographicCount = 0;
99 int OrganisationCount = 0;
101 int CategoryCount = 0;
105 int CalendarCount = 0;
106 int CalendarAddressCount = 0;
107 int FreeBusyAddressCount = 0;
111 wxString ContactLine;
112 wxString PropertyLine;
113 wxString PropertySeg1;
114 wxString PropertySeg2;
115 wxString PropertyNextLine;
118 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
119 iter != ContactFileLines.end(); ++iter){
121 ExtraLineSeek = TRUE;
127 PropertyLine.Clear();
128 PropertySeg1.Clear();
129 PropertySeg2.Clear();
132 ContactLine = iter->second;
134 while (ExtraLineSeek == TRUE){
136 // Check if there is extra data on the next line
137 // (indicated by space or tab at the start) and add data.
141 if (iter == ContactFileLines.end()){
148 PropertyNextLine = iter->second;
150 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
152 PropertyNextLine.Remove(0, 1);
153 ContactLine.Append(PropertyNextLine);
158 ExtraLineSeek = FALSE;
164 ContactLineLen = ContactLine.Len();
166 // Make sure we are not in quotation mode.
167 // Make sure colon does not have \ or \\ before it.
169 for (int i = 0; i <= ContactLineLen; i++){
171 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
173 PropertyFind = FALSE;
175 } else if (PropertyFind == TRUE){
177 Property.Append(ContactLine.Mid(i, 1));
181 if (ContactLine.Mid(i, 1) == wxT("\"")){
183 if (QuoteMode == TRUE){
195 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
204 // Split that line at the point into two variables (ignore the colon).
206 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
207 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
209 if (Property == wxT("KIND") && KindProcessed == FALSE){
211 ProcessKind(PropertySeg2);
213 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
215 UIDToken = PropertySeg2;
218 } else if (Property == wxT("SOURCE")){
220 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
223 } else if (Property == wxT("MEMBER")){
225 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
228 } else if (Property == wxT("FN")){
230 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
233 } else if (Property == wxT("N") && NameProcessed == FALSE){
235 ProcessN(PropertySeg1, PropertySeg2);
236 NameProcessed = TRUE;
238 } else if (Property == wxT("NICKNAME")){
240 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
243 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
245 ProcessGender(PropertySeg1, PropertySeg2);
246 GenderProcessed = TRUE;
248 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
250 ProcessBirthday(PropertySeg1, PropertySeg2);
251 BirthdayProcessed = TRUE;
253 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
255 ProcessAnniversary(PropertySeg1, PropertySeg2);
256 AnniversaryProcessed = TRUE;
258 } else if (Property == wxT("TZ")){
260 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
263 } else if (Property == wxT("ADR")){
265 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
268 } else if (Property == wxT("EMAIL")){
270 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
273 } else if (Property == wxT("IMPP")){
275 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
278 } else if (Property == wxT("TEL")){
280 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
283 } else if (Property == wxT("LANG")){
285 // See frmContactEditor-LoadLanguage.cpp
287 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
290 } else if (Property == wxT("GEO")){
292 // See frmContactEditor-LoadGeo.cpp
294 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
297 } else if (Property == wxT("RELATED")){
299 // See fromContactEditor-LoadRelated.cpp
301 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
304 } else if (Property == wxT("URL")){
306 // See frmContactEditor-LoadURL.cpp
308 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
311 } else if (Property == wxT("TITLE")) {
313 // See frmContactEditor-LoadTitle.cpp
315 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
318 } else if (Property == wxT("ROLE")) {
320 // See frmContactEditor-LoadTitle.cpp
322 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
325 } else if (Property == wxT("ORG")) {
327 // See frmContactEditor-LoadOrg.cpp
329 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
332 } else if (Property == wxT("NOTE")) {
334 // See frmContactEditor-LoadNote.cpp
336 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
339 } else if (Property == wxT("CATEGORIES")) {
341 // See frmContactEditor-LoadCategory.cpp
343 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
346 } else if (Property == wxT("PHOTO")) {
348 // See frmContactEditor-LoadPhoto.cpp
350 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
353 } else if (Property == wxT("LOGO")) {
355 // See frmContactEditor-LoadPhoto.cpp
357 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
360 } else if (Property == wxT("LOGO")) {
362 // See frmContactEditor-LoadPhoto.cpp
364 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
367 } else if (Property == wxT("SOUND")) {
369 // See frmContactEditor-LoadSound.cpp
371 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
374 } else if (Property == wxT("CALURI")){
376 // See frmContactEditor-LoadCalendar.cpp
378 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
381 } else if (Property == wxT("CALADRURI")){
383 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
384 CalendarAddressCount++;
386 } else if (Property == wxT("FBURL")){
388 // See frmContactEditor-LoadCalendar.cpp
390 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
391 FreeBusyAddressCount++;
393 } else if (Property == wxT("KEY")){
395 // See frmContactEditor-LoadKey.cpp
397 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
400 } else if (Property.Mid(0, 3) == wxT("VND")){
402 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
405 } else if (Property.Mid(0, 2) == wxT("X-")){
407 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
408 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
415 return CONTACTLOAD_OK;
419 void ContactDataObject::ProcessKind(wxString KindType){
421 if (KindType == wxT("individual")){
423 ContactKind = CONTACTKIND_INDIVIDUAL;
425 } else if (KindType == wxT("group")){
427 ContactKind = CONTACTKIND_GROUP;
429 } else if (KindType == wxT("org")){
431 ContactKind = CONTACTKIND_ORGANISATION;
433 } else if (KindType == wxT("location")){
435 ContactKind = CONTACTKIND_LOCATION;
439 ContactKind = CONTACTKIND_NONE;
444 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
446 size_t intPropertyLen = PropertySeg1.Len();
447 std::map<int, int> SplitPoints;
448 std::map<int, int> SplitLength;
449 std::map<int, int>::iterator SLiter;
450 wxString PropertyData;
451 wxString PropertyName;
452 wxString PropertyValue;
453 wxString PropertyTokens;
454 bool FirstToken = TRUE;
455 int intSplitsFound = 0;
456 int intSplitSize = 0;
457 int intPrevValue = 8;
461 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
465 PropertyType PropType = PROPERTY_NONE;
467 // Look for type before continuing.
469 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
473 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
474 intiter != SplitPoints.end(); ++intiter){
476 SLiter = SplitLength.find(intiter->first);
478 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
480 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
481 PropertyName = PropertyElement.GetNextToken();
482 PropertyValue = PropertyElement.GetNextToken();
484 intPrevValue = intiter->second;
486 // Process properties.
488 size_t intPropertyValueLen = PropertyValue.Len();
490 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
492 PropertyValue.Trim();
493 PropertyValue.RemoveLast();
497 if (PropertyValue.Mid(0, 1) == wxT("\"")){
499 PropertyValue.Remove(0, 1);
503 CaptureString(&PropertyValue, FALSE);
505 if (PropertyName == wxT("ALTID")){
507 SourceListAltID.erase(*SourceCount);
508 SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
510 } else if (PropertyName == wxT("PID")){
512 SourceListPID.erase(*SourceCount);
513 SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
515 } else if (PropertyName == wxT("PREF")){
517 int PriorityNumber = 0;
518 bool ValidNumber = TRUE;
521 PriorityNumber = std::stoi(PropertyValue.ToStdString());
524 catch(std::invalid_argument &e){
528 if (ValidNumber == TRUE){
530 SourceListPref.erase(*SourceCount);
531 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
535 } else if (PropertyName == wxT("MEDIATYPE")){
537 SourceListMediatype.erase(*SourceCount);
538 SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
542 // Something else we don't know about so append
543 // to the tokens variable.
545 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
547 if (FirstToken == TRUE){
549 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
554 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
564 intPropertyLen = PropertySeg2.Len();
571 CaptureString(&PropertySeg2, FALSE);
573 // Add the data to the General/Home/Work address variables.
579 SourceListType.insert(std::make_pair(*SourceCount, "home"));
582 SourceListType.insert(std::make_pair(*SourceCount, "work"));
586 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
588 if (!PropertyTokens.IsEmpty()){
590 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
596 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
598 std::map<int, int> SplitPoints;
599 std::map<int, int> SplitLength;
601 int intPrevValue = 8;
605 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
609 wxString PropertyName;
610 wxString PropertyValue;
611 wxString PropertyData;
612 wxString PropertyTokens;
613 std::map<int,int>::iterator SLiter;
614 bool FirstToken = TRUE;
616 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
617 intiter != SplitPoints.end(); ++intiter){
619 SLiter = SplitLength.find(intiter->first);
621 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
623 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
624 PropertyName = PropertyElement.GetNextToken();
625 PropertyValue = PropertyElement.GetNextToken();
627 intPrevValue = intiter->second;
629 CaptureString(&PropertyValue, FALSE);
631 if (PropertyName == wxT("ALTID")){
633 GroupsListAltID.erase(*GroupCount);
634 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
636 } else if (PropertyName == wxT("PID")){
638 GroupsListPID.erase(*GroupCount);
639 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
641 } else if (PropertyName == wxT("PREF")){
643 int PriorityNumber = 0;
644 bool ValidNumber = TRUE;
647 PriorityNumber = std::stoi(PropertyValue.ToStdString());
650 catch(std::invalid_argument &e){
654 if (ValidNumber == TRUE){
656 GroupsListPref.erase(*GroupCount);
657 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
661 } else if (PropertyName == wxT("MEDIATYPE")){
663 GroupsListMediaType.erase(*GroupCount);
664 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
666 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
668 if (FirstToken == TRUE){
670 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
675 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
683 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
685 if (!PropertyTokens.IsEmpty()){
687 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
694 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
696 std::map<int, int> SplitPoints;
697 std::map<int, int> SplitLength;
699 int intPrevValue = 4;
703 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
707 wxString PropertyName;
708 wxString PropertyValue;
709 wxString PropertyData;
710 wxString PropertyTokens;
711 std::map<int,int>::iterator SLiter;
712 bool FirstToken = TRUE;
714 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
715 intiter != SplitPoints.end(); ++intiter){
717 SLiter = SplitLength.find(intiter->first);
719 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
721 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
722 PropertyName = PropertyElement.GetNextToken();
723 PropertyValue = PropertyElement.GetNextToken();
725 intPrevValue = intiter->second;
727 CaptureString(&PropertyValue, FALSE);
729 if (PropertyName == wxT("TYPE")){
731 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
732 PropertyValue == wxT("work") ){
734 FullNamesListType.erase(*FNCount);
735 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
739 } else if (PropertyName == wxT("LANGUAGE")){
741 FullNamesListLanguage.erase(*FNCount);
742 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
744 } else if (PropertyName == wxT("ALTID")){
746 FullNamesListAltID.erase(*FNCount);
747 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
749 } else if (PropertyName == wxT("PID")){
751 FullNamesListPID.erase(*FNCount);
752 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
754 } else if (PropertyName == wxT("PREF")){
756 int PriorityNumber = 0;
757 bool ValidNumber = TRUE;
760 PriorityNumber = std::stoi(PropertyValue.ToStdString());
763 catch(std::invalid_argument &e){
767 if (ValidNumber == TRUE){
769 FullNamesListPref.erase(*FNCount);
770 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
774 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
776 if (FirstToken == TRUE){
778 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
783 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
791 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
793 if (!PropertyTokens.IsEmpty()){
795 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
801 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
803 std::map<int, int> SplitPoints;
804 std::map<int, int> SplitLength;
806 int intPrevValue = 3;
810 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
814 wxString PropertyName;
815 wxString PropertyValue;
816 wxString PropertyData;
817 wxString PropertyTokens;
818 std::map<int,int>::iterator SLiter;
819 bool FirstToken = TRUE;
821 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
822 intiter != SplitPoints.end(); ++intiter){
824 SLiter = SplitLength.find(intiter->first);
826 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
828 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
829 PropertyName = PropertyElement.GetNextToken();
830 PropertyValue = PropertyElement.GetNextToken();
832 intPrevValue = intiter->second;
834 CaptureString(&PropertyValue, FALSE);
836 if (PropertyName == wxT("ALTID")){
838 NameAltID = PropertyValue;
840 } else if (PropertyName == wxT("LANGUAGE")){
842 NameLanguage = PropertyValue;
844 } else if (PropertyName == wxT("SORT-AS")){
846 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
847 PropertyValue.Len() >= 3){
848 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
851 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
853 if (FirstToken == TRUE){
855 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
860 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
868 // Split the name data.
870 int intSplitSeek = 0;
871 int intSplitsFound = 0;
872 int intSplitSize = 0;
873 int intPropertyLen = PropertySeg2.Len();
875 std::map<int,wxString> NameValues;
878 for (int i = 0; i <= intPropertyLen; i++){
880 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
882 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
887 if (intSplitsFound == 4){
889 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
903 // Split the data into several parts.
905 for (std::map<int, wxString>::iterator iter = NameValues.begin();
906 iter != NameValues.end(); ++iter){
908 if (iter->first == 1){
910 // Deal with family name.
912 NameSurname = iter->second;
914 } else if (iter->first == 2){
916 // Deal with given names.
918 NameForename = iter->second;
920 } else if (iter->first == 3){
922 // Deal with additional names.
924 NameOtherNames = iter->second;
926 } else if (iter->first == 4){
928 // Deal with honorifix prefixes and suffixes.
930 NameTitle = iter->second;
934 if (iter == NameValues.end()){
940 NameSuffix = iter->second;
946 // Add the name token data.
948 if (!PropertyTokens.IsEmpty()){
950 NameTokens = PropertyTokens;
956 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
958 std::map<int, int> SplitPoints;
959 std::map<int, int> SplitLength;
961 int intPrevValue = 10;
964 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
968 PropertyType PropType = PROPERTY_NONE;
970 // Look for type before continuing.
972 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
976 std::map<int, wxString> *NicknamesList = NULL;
977 std::map<int, wxString> *NicknamesListType = NULL;
978 std::map<int, wxString> *NicknamesListLanguage = NULL;
979 std::map<int, wxString> *NicknamesListAltID = NULL;
980 std::map<int, wxString> *NicknamesListPID = NULL;
981 std::map<int, wxString> *NicknamesListTokens = NULL;
982 std::map<int, int> *NicknamesListPref = NULL;
986 NicknamesList = &GeneralNicknamesList;
987 NicknamesListType = &GeneralNicknamesListType;
988 NicknamesListLanguage = &GeneralNicknamesListLanguage;
989 NicknamesListAltID = &GeneralNicknamesListAltID;
990 NicknamesListPID = &GeneralNicknamesListPID;
991 NicknamesListTokens = &GeneralNicknamesListTokens;
992 NicknamesListPref = &GeneralNicknamesListPref;
995 NicknamesList = &HomeNicknamesList;
996 NicknamesListType = &HomeNicknamesListType;
997 NicknamesListLanguage = &HomeNicknamesListLanguage;
998 NicknamesListAltID = &HomeNicknamesListAltID;
999 NicknamesListPID = &HomeNicknamesListPID;
1000 NicknamesListTokens = &HomeNicknamesListTokens;
1001 NicknamesListPref = &HomeNicknamesListPref;
1004 NicknamesList = &BusinessNicknamesList;
1005 NicknamesListType = &BusinessNicknamesListType;
1006 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1007 NicknamesListAltID = &BusinessNicknamesListAltID;
1008 NicknamesListPID = &BusinessNicknamesListPID;
1009 NicknamesListTokens = &BusinessNicknamesListTokens;
1010 NicknamesListPref = &BusinessNicknamesListPref;
1014 std::map<int, int>::iterator SLiter;
1015 wxString PropertyData;
1016 wxString PropertyName;
1017 wxString PropertyValue;
1018 wxString PropertyTokens;
1019 bool FirstToken = TRUE;
1021 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1022 intiter != SplitPoints.end(); ++intiter){
1024 SLiter = SplitLength.find(intiter->first);
1026 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1028 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1029 PropertyName = PropertyElement.GetNextToken();
1030 PropertyValue = PropertyElement.GetNextToken();
1032 intPrevValue = intiter->second;
1034 CaptureString(&PropertyValue, FALSE);
1036 if (PropertyName == wxT("ALTID")){
1038 NicknamesListAltID->erase(*NicknameCount);
1039 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1041 } else if (PropertyName == wxT("PID")){
1043 NicknamesListPID->erase(*NicknameCount);
1044 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1046 } else if (PropertyName == wxT("PREF")){
1048 int PriorityNumber = 0;
1049 bool ValidNumber = TRUE;
1052 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1055 catch(std::invalid_argument &e){
1056 ValidNumber = FALSE;
1059 if (ValidNumber == TRUE){
1061 NicknamesListPref->erase(*NicknameCount);
1062 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1066 } else if (PropertyName == wxT("LANGUAGE")){
1068 NicknamesListLanguage->erase(*NicknameCount);
1069 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1073 // Something else we don't know about so append
1074 // to the tokens variable.
1076 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1078 if (FirstToken == TRUE){
1080 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1085 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1095 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1097 // Add the name token data.
1099 if (!PropertyTokens.IsEmpty()){
1101 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1107 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1109 std::map<int, int> SplitPoints;
1110 std::map<int, int> SplitLength;
1111 std::map<int, int>::iterator SLiter;
1112 wxString PropertyData;
1113 wxString PropertyName;
1114 wxString PropertyValue;
1115 wxString PropertyTokens;
1116 bool FirstToken = TRUE;
1117 int intPrevValue = 8;
1119 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1123 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1124 intiter != SplitPoints.end(); ++intiter){
1126 SLiter = SplitLength.find(intiter->first);
1128 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1130 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1131 PropertyName = PropertyElement.GetNextToken();
1132 PropertyValue = PropertyElement.GetNextToken();
1134 intPrevValue = intiter->second;
1136 // Process properties.
1138 size_t intPropertyValueLen = PropertyValue.Len();
1140 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1142 PropertyValue.Trim();
1143 PropertyValue.RemoveLast();
1147 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1149 PropertyValue.Remove(0, 1);
1153 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1155 if (FirstToken == TRUE){
1157 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1162 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1170 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1172 wxString GenderComponent;
1174 if (GenderData.CountTokens() >= 2){
1176 Gender = GenderData.GetNextToken();
1177 GenderDetails = GenderData.GetString();
1179 CaptureString(&GenderDetails, FALSE);
1183 Gender = GenderData.GetNextToken();
1187 if (!PropertyTokens.IsEmpty()){
1189 GenderTokens = PropertyTokens;
1195 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1197 // Process date. Preserve the remainder in the string.
1199 std::map<int, int> SplitPoints;
1200 std::map<int, int> SplitLength;
1201 std::map<int, int>::iterator SLiter;
1202 wxString PropertyData;
1203 wxString PropertyName;
1204 wxString PropertyValue;
1205 wxString PropertyTokens;
1206 bool BirthdayText = FALSE;
1207 int intPrevValue = 6;
1209 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1213 // Look for type before continuing.
1215 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1216 intiter != SplitPoints.end(); ++intiter){
1218 SLiter = SplitLength.find(intiter->first);
1220 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1222 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1223 PropertyName = PropertyElement.GetNextToken();
1224 PropertyValue = PropertyElement.GetNextToken();
1226 intPrevValue = intiter->second;
1228 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1230 CaptureString(&PropertySeg2, FALSE);
1231 Birthday = PropertySeg2;
1232 BirthdayText = TRUE;
1238 // Setup blank lines for later on.
1241 bool FirstToken = TRUE;
1243 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1244 intiter != SplitPoints.end(); ++intiter){
1246 SLiter = SplitLength.find(intiter->first);
1248 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1250 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1251 PropertyName = PropertyElement.GetNextToken();
1252 PropertyValue = PropertyElement.GetNextToken();
1254 intPrevValue = intiter->second;
1256 // Process properties.
1258 CaptureString(&PropertyValue, FALSE);
1260 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1262 PropertyValue.Trim();
1263 PropertyValue.RemoveLast();
1267 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1269 PropertyValue.Remove(0, 1);
1273 if (PropertyName == wxT("ALTID")){
1275 BirthdayAltID = PropertyValue;
1277 } else if (PropertyName == wxT("CALSCALE")){
1279 BirthdayCalScale = PropertyValue;
1281 } else if (PropertyName != wxT("VALUE")) {
1283 // Something else we don't know about so append
1284 // to the tokens variable.
1286 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1288 if (FirstToken == TRUE){
1290 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1295 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1305 // Add the data to the variables and form.
1307 if (BirthdayText == FALSE){
1309 Birthday = PropertySeg2;
1313 if (!PropertyTokens.IsEmpty()){
1315 BirthdayTokens = PropertyTokens;
1321 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1323 // Process date. Preserve the remainder in the string.
1325 std::map<int, int> SplitPoints;
1326 std::map<int, int> SplitLength;
1327 std::map<int, int>::iterator SLiter;
1328 wxString PropertyData;
1329 wxString PropertyName;
1330 wxString PropertyValue;
1331 wxString PropertyTokens;
1332 bool AnniversaryText = FALSE;
1333 int intPrevValue = 13;
1335 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1339 // Look for type before continuing.
1341 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1342 intiter != SplitPoints.end(); ++intiter){
1344 SLiter = SplitLength.find(intiter->first);
1346 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1348 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1349 PropertyName = PropertyElement.GetNextToken();
1350 PropertyValue = PropertyElement.GetNextToken();
1352 intPrevValue = intiter->second;
1354 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1356 CaptureString(&PropertySeg2, FALSE);
1357 Anniversary = PropertySeg2;
1358 AnniversaryText = TRUE;
1364 // Setup blank lines for later on.
1367 bool FirstToken = TRUE;
1369 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1370 intiter != SplitPoints.end(); ++intiter){
1372 SLiter = SplitLength.find(intiter->first);
1374 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1376 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1377 PropertyName = PropertyElement.GetNextToken();
1378 PropertyValue = PropertyElement.GetNextToken();
1380 intPrevValue = intiter->second;
1382 // Process properties.
1384 CaptureString(&PropertyValue, FALSE);
1386 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1388 PropertyValue.Trim();
1389 PropertyValue.RemoveLast();
1393 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1395 PropertyValue.Remove(0, 1);
1399 if (PropertyName == wxT("ALTID")){
1401 AnniversaryAltID = PropertyValue;
1403 } else if (PropertyName == wxT("CALSCALE")){
1405 AnniversaryCalScale = PropertyValue;
1407 } else if (PropertyName != wxT("VALUE")) {
1409 // Something else we don't know about so append
1410 // to the tokens variable.
1412 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1414 if (FirstToken == TRUE){
1416 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1421 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1431 // Add the data to the variables and form.
1433 if (AnniversaryText == FALSE){
1435 Anniversary = PropertySeg2;
1439 if (!PropertyTokens.IsEmpty()){
1441 AnniversaryTokens = PropertyTokens;
1447 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1449 std::map<int, int> SplitPoints;
1450 std::map<int, int> SplitLength;
1452 int intPrevValue = 4;
1455 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1459 PropertyType PropType = PROPERTY_NONE;
1461 // Look for type before continuing.
1463 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1467 std::map<int, wxString> *TZList = NULL;
1468 std::map<int, wxString> *TZListType = NULL;
1469 std::map<int, wxString> *TZListMediatype = NULL;
1470 std::map<int, wxString> *TZListAltID = NULL;
1471 std::map<int, wxString> *TZListPID = NULL;
1472 std::map<int, wxString> *TZListTokens = NULL;
1473 std::map<int, int> *TZListPref = NULL;
1477 TZList = &GeneralTZList;
1478 TZListType = &GeneralTZListType;
1479 TZListMediatype = &GeneralTZListMediatype;
1480 TZListAltID = &GeneralTZListAltID;
1481 TZListPID = &GeneralTZListPID;
1482 TZListTokens = &GeneralTZListTokens;
1483 TZListPref = &GeneralTZListPref;
1486 TZList = &HomeTZList;
1487 TZListType = &HomeTZListType;
1488 TZListMediatype = &HomeTZListMediatype;
1489 TZListAltID = &HomeTZListAltID;
1490 TZListPID = &HomeTZListPID;
1491 TZListTokens = &HomeTZListTokens;
1492 TZListPref = &HomeTZListPref;
1495 TZList = &BusinessTZList;
1496 TZListType = &BusinessTZListType;
1497 TZListMediatype = &BusinessTZListMediatype;
1498 TZListAltID = &BusinessTZListAltID;
1499 TZListPID = &BusinessTZListPID;
1500 TZListTokens = &BusinessTZListTokens;
1501 TZListPref = &BusinessTZListPref;
1505 std::map<int, int>::iterator SLiter;
1506 wxString PropertyData;
1507 wxString PropertyName;
1508 wxString PropertyValue;
1509 wxString PropertyTokens;
1510 bool FirstToken = TRUE;
1512 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1513 intiter != SplitPoints.end(); ++intiter){
1515 SLiter = SplitLength.find(intiter->first);
1517 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1519 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1520 PropertyName = PropertyElement.GetNextToken();
1521 PropertyValue = PropertyElement.GetNextToken();
1523 intPrevValue = intiter->second;
1525 CaptureString(&PropertyValue, FALSE);
1527 if (PropertyName == wxT("ALTID")){
1529 TZListAltID->erase(*TimeZoneCount);
1530 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1532 } else if (PropertyName == wxT("PID")){
1534 TZListPID->erase(*TimeZoneCount);
1535 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1537 } else if (PropertyName == wxT("PREF")){
1539 int PriorityNumber = 0;
1540 bool ValidNumber = TRUE;
1543 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1546 catch(std::invalid_argument &e){
1547 ValidNumber = FALSE;
1550 if (ValidNumber == TRUE){
1552 TZListPref->erase(*TimeZoneCount);
1553 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1557 } else if (PropertyName == wxT("MEDIATYPE")){
1559 TZListMediatype->erase(*TimeZoneCount);
1560 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1564 // Something else we don't know about so append
1565 // to the tokens variable.
1567 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1569 if (FirstToken == TRUE){
1571 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1576 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1586 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1588 // Add the name token data.
1590 if (!PropertyTokens.IsEmpty()){
1592 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1599 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1601 size_t intPropertyLen = PropertySeg1.Len();
1602 std::map<int, int> SplitPoints;
1603 std::map<int, int> SplitLength;
1604 std::map<int, int>::iterator SLiter;
1605 wxString PropertyData;
1606 wxString PropertyName;
1607 wxString PropertyValue;
1608 wxString PropertyTokens;
1609 wxString AddressLabel;
1610 wxString AddressLang;
1611 wxString AddressAltID;
1612 wxString AddressPID;
1613 wxString AddressTokens;
1614 wxString AddressGeo;
1615 wxString AddressTimezone;
1616 wxString AddressType;
1617 wxString AddressMediatype;
1618 wxString AddressPOBox;
1619 wxString AddressExtended;
1620 wxString AddressStreet;
1621 wxString AddressLocality;
1622 wxString AddressCity;
1623 wxString AddressRegion;
1624 wxString AddressPostalCode;
1625 wxString AddressCountry;
1626 bool FirstToken = TRUE;
1627 int intSplitsFound = 0;
1628 int intSplitSize = 0;
1629 int intPrevValue = 5;
1634 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1638 PropertyType PropType = PROPERTY_NONE;
1640 // Look for type before continuing.
1642 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1646 std::map<int, wxString> *AddressList = NULL;
1647 std::map<int, wxString> *AddressListTown = NULL;
1648 std::map<int, wxString> *AddressListCounty = NULL;
1649 std::map<int, wxString> *AddressListPostCode = NULL;
1650 std::map<int, wxString> *AddressListCountry = NULL;
1651 std::map<int, wxString> *AddressListLabel = NULL;
1652 std::map<int, wxString> *AddressListLang = NULL;
1653 std::map<int, wxString> *AddressListAltID = NULL;
1654 std::map<int, wxString> *AddressListPID = NULL;
1655 std::map<int, wxString> *AddressListTokens = NULL;
1656 std::map<int, wxString> *AddressListGeo = NULL;
1657 std::map<int, wxString> *AddressListTimezone = NULL;
1658 std::map<int, wxString> *AddressListType = NULL;
1659 std::map<int, wxString> *AddressListMediatype = NULL;
1660 std::map<int, int> *AddressListPref = NULL;
1664 AddressList = &GeneralAddressList;
1665 AddressListTown = &GeneralAddressListTown;
1666 AddressListCounty = &GeneralAddressListCounty;
1667 AddressListPostCode = &GeneralAddressListPostCode;
1668 AddressListCountry = &GeneralAddressListCountry;
1669 AddressListLabel = &GeneralAddressListLabel;
1670 AddressListLang = &GeneralAddressListLang;
1671 AddressListAltID = &GeneralAddressListAltID;
1672 AddressListPID = &GeneralAddressListPID;
1673 AddressListTokens = &GeneralAddressListTokens;
1674 AddressListGeo = &GeneralAddressListGeo;
1675 AddressListTimezone = &GeneralAddressListTimezone;
1676 AddressListType = &GeneralAddressListType;
1677 AddressListMediatype = &GeneralAddressListMediatype;
1678 AddressListPref = &GeneralAddressListPref;
1681 AddressList = &HomeAddressList;
1682 AddressListTown = &HomeAddressListTown;
1683 AddressListCounty = &HomeAddressListCounty;
1684 AddressListPostCode = &HomeAddressListPostCode;
1685 AddressListCountry = &HomeAddressListCountry;
1686 AddressListLabel = &HomeAddressListLabel;
1687 AddressListLang = &HomeAddressListLang;
1688 AddressListAltID = &HomeAddressListAltID;
1689 AddressListPID = &HomeAddressListPID;
1690 AddressListTokens = &HomeAddressListTokens;
1691 AddressListGeo = &HomeAddressListGeo;
1692 AddressListTimezone = &HomeAddressListTimezone;
1693 AddressListType = &HomeAddressListType;
1694 AddressListMediatype = &HomeAddressListMediatype;
1695 AddressListPref = &HomeAddressListPref;
1698 AddressList = &BusinessAddressList;
1699 AddressListTown = &BusinessAddressListTown;
1700 AddressListCounty = &BusinessAddressListCounty;
1701 AddressListPostCode = &BusinessAddressListPostCode;
1702 AddressListCountry = &BusinessAddressListCountry;
1703 AddressListLabel = &BusinessAddressListLabel;
1704 AddressListLang = &BusinessAddressListLang;
1705 AddressListAltID = &BusinessAddressListAltID;
1706 AddressListPID = &BusinessAddressListPID;
1707 AddressListTokens = &BusinessAddressListTokens;
1708 AddressListGeo = &BusinessAddressListGeo;
1709 AddressListTimezone = &BusinessAddressListTimezone;
1710 AddressListType = &BusinessAddressListType;
1711 AddressListMediatype = &BusinessAddressListMediatype;
1712 AddressListPref = &BusinessAddressListPref;
1718 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1719 intiter != SplitPoints.end(); ++intiter){
1721 SLiter = SplitLength.find(intiter->first);
1723 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1725 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1726 PropertyName = PropertyElement.GetNextToken();
1727 PropertyValue = PropertyElement.GetNextToken();
1729 intPrevValue = intiter->second;
1731 CaptureString(&PropertyValue, FALSE);
1733 // Process properties.
1735 if (PropertyName == wxT("LABEL")){
1737 AddressListLabel->erase(*AddressCount);
1738 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1740 } else if (PropertyName == wxT("LANGUAGE")){
1742 AddressListLang->erase(*AddressCount);
1743 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1745 } else if (PropertyName == wxT("ALTID")){
1747 AddressListAltID->erase(*AddressCount);
1748 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1750 } else if (PropertyName == wxT("PID")){
1752 AddressListPID->erase(*AddressCount);
1753 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1755 } else if (PropertyName == wxT("GEO")){
1757 AddressListGeo->erase(*AddressCount);
1758 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1760 } else if (PropertyName == wxT("TZ")){
1762 AddressListTimezone->erase(*AddressCount);
1763 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1765 } else if (PropertyName == wxT("MEDIATYPE")){
1767 AddressListMediatype->erase(*AddressCount);
1768 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1770 } else if (PropertyName == wxT("PREF")){
1772 int PriorityNumber = 0;
1773 bool ValidNumber = TRUE;
1776 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1779 catch(std::invalid_argument &e){
1780 ValidNumber = FALSE;
1783 if (ValidNumber == TRUE){
1785 AddressListPref->erase(*AddressCount);
1786 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1792 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1794 if (FirstToken == TRUE){
1796 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1801 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1811 // Split the address.
1813 //std::map<int, int>::iterator SLiter;
1814 intPropertyLen = PropertySeg2.Len();
1815 SplitPoints.clear();
1816 SplitLength.clear();
1821 for (int i = 0; i <= intPropertyLen; i++){
1825 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1828 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1830 if (intSplitsFound == 6){
1832 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1837 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1847 // Split the data into several parts.
1849 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1850 intiter != SplitPoints.end(); ++intiter){
1852 if (intiter->first == 1){
1854 // Deal with PO Box.
1856 SLiter = SplitLength.find(1);
1858 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1859 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1860 intPrevValue = intiter->second;
1862 } else if (intiter->first == 2){
1864 // Deal with extended address.
1866 SLiter = SplitLength.find(2);
1868 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1869 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1870 intPrevValue = intiter->second;
1872 } else if (intiter->first == 3){
1874 // Deal with street address.
1876 SLiter = SplitLength.find(3);
1878 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1879 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1880 intPrevValue = intiter->second;
1882 } else if (intiter->first == 4){
1884 // Deal with locality
1886 SLiter = SplitLength.find(4);
1888 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1889 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1890 intPrevValue = intiter->second;
1892 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1894 } else if (intiter->first == 5){
1896 // Deal with region.
1898 SLiter = SplitLength.find(5);
1900 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1901 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1902 intPrevValue = intiter->second;
1904 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1906 } else if (intiter->first == 6){
1908 // Deal with post code.
1910 SLiter = SplitLength.find(6);
1912 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1913 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1914 intPrevValue = intiter->second;
1916 // Deal with country.
1918 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1919 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1927 // Add the data to the General/Home/Work address variables.
1929 CaptureString(&AddressStreet, FALSE);
1930 CaptureString(&AddressLocality, FALSE);
1931 CaptureString(&AddressRegion, FALSE);
1932 CaptureString(&AddressPostalCode, FALSE);
1933 CaptureString(&AddressCountry, FALSE);
1935 if (!PropertyTokens.IsEmpty()){
1937 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1941 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1942 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1943 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1944 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1945 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1949 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1952 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1955 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1959 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1963 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1965 std::map<int, int> SplitPoints;
1966 std::map<int, int> SplitLength;
1968 int intPrevValue = 7;
1971 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1975 PropertyType PropType = PROPERTY_NONE;
1977 // Look for type before continuing.
1979 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1981 std::map<int, wxString> *EmailList = NULL;
1982 std::map<int, wxString> *EmailListType = NULL;
1983 std::map<int, wxString> *EmailListAltID = NULL;
1984 std::map<int, wxString> *EmailListPID = NULL;
1985 std::map<int, wxString> *EmailListTokens = NULL;
1986 std::map<int, int> *EmailListPref = NULL;
1990 EmailList = &GeneralEmailList;
1991 EmailListType = &GeneralEmailListType;
1992 EmailListAltID = &GeneralEmailListAltID;
1993 EmailListPID = &GeneralEmailListPID;
1994 EmailListTokens = &GeneralEmailListTokens;
1995 EmailListPref = &GeneralEmailListPref;
1998 EmailList = &HomeEmailList;
1999 EmailListType = &HomeEmailListType;
2000 EmailListAltID = &HomeEmailListAltID;
2001 EmailListPID = &HomeEmailListPID;
2002 EmailListTokens = &HomeEmailListTokens;
2003 EmailListPref = &HomeEmailListPref;
2006 EmailList = &BusinessEmailList;
2007 EmailListType = &BusinessEmailListType;
2008 EmailListAltID = &BusinessEmailListAltID;
2009 EmailListPID = &BusinessEmailListPID;
2010 EmailListTokens = &BusinessEmailListTokens;
2011 EmailListPref = &BusinessEmailListPref;
2017 std::map<int,int>::iterator SLiter;
2018 wxString PropertyData;
2019 wxString PropertyName;
2020 wxString PropertyValue;
2021 wxString PropertyTokens;
2022 bool FirstToken = TRUE;
2024 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2025 intiter != SplitPoints.end(); ++intiter){
2027 SLiter = SplitLength.find(intiter->first);
2029 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2031 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2032 PropertyName = PropertyElement.GetNextToken();
2033 PropertyValue = PropertyElement.GetNextToken();
2035 intPrevValue = intiter->second;
2037 CaptureString(&PropertyValue, FALSE);
2039 // Process properties.
2041 if (PropertyName == wxT("ALTID")){
2043 EmailListAltID->erase(*EmailCount);
2044 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2046 } else if (PropertyName == wxT("PID")){
2048 EmailListPID->erase(*EmailCount);
2049 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2051 } else if (PropertyName == wxT("PREF")){
2053 int PriorityNumber = 0;
2054 bool ValidNumber = TRUE;
2057 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2060 catch(std::invalid_argument &e){
2061 ValidNumber = FALSE;
2064 if (ValidNumber == TRUE){
2066 EmailListPref->erase(*EmailCount);
2067 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2073 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2075 if (FirstToken == TRUE){
2077 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2082 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2092 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2094 // Add the name token data.
2096 if (!PropertyTokens.IsEmpty()){
2098 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2105 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2107 std::map<int, int> SplitPoints;
2108 std::map<int, int> SplitLength;
2110 int intPrevValue = 6;
2113 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2117 PropertyType PropType = PROPERTY_NONE;
2119 // Look for type before continuing.
2121 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2123 std::map<int, wxString> *IMList = NULL;
2124 std::map<int, wxString> *IMListType = NULL;
2125 std::map<int, wxString> *IMListAltID = NULL;
2126 std::map<int, wxString> *IMListPID = NULL;
2127 std::map<int, wxString> *IMListTokens = NULL;
2128 std::map<int, wxString> *IMListMediatype = NULL;
2129 std::map<int, int> *IMListPref = NULL;
2133 IMList = &GeneralIMList;
2134 IMListType = &GeneralIMListType;
2135 IMListAltID = &GeneralIMListAltID;
2136 IMListPID = &GeneralIMListPID;
2137 IMListTokens = &GeneralIMListTokens;
2138 IMListMediatype = &GeneralIMListMediatype;
2139 IMListPref = &GeneralIMListPref;
2142 IMList = &HomeIMList;
2143 IMListType = &HomeIMListType;
2144 IMListAltID = &HomeIMListAltID;
2145 IMListPID = &HomeIMListPID;
2146 IMListTokens = &HomeIMListTokens;
2147 IMListMediatype = &HomeIMListMediatype;
2148 IMListPref = &HomeIMListPref;
2151 IMList = &BusinessIMList;
2152 IMListType = &BusinessIMListType;
2153 IMListAltID = &BusinessIMListAltID;
2154 IMListPID = &BusinessIMListPID;
2155 IMListTokens = &BusinessIMListTokens;
2156 IMListMediatype = &BusinessIMListMediatype;
2157 IMListPref = &BusinessIMListPref;
2163 std::map<int,int>::iterator SLiter;
2164 wxString PropertyData;
2165 wxString PropertyName;
2166 wxString PropertyValue;
2167 wxString PropertyTokens;
2168 bool FirstToken = TRUE;
2170 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2171 intiter != SplitPoints.end(); ++intiter){
2173 SLiter = SplitLength.find(intiter->first);
2175 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2177 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2178 PropertyName = PropertyElement.GetNextToken();
2179 PropertyValue = PropertyElement.GetNextToken();
2181 intPrevValue = intiter->second;
2183 CaptureString(&PropertyValue, FALSE);
2185 // Process properties.
2187 if (PropertyName == wxT("ALTID")){
2189 IMListAltID->erase(*IMCount);
2190 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2192 } else if (PropertyName == wxT("PID")){
2194 IMListPID->erase(*IMCount);
2195 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2197 } else if (PropertyName == wxT("MEDIATYPE")){
2199 IMListMediatype->erase(*IMCount);
2200 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2202 } else if (PropertyName == wxT("PREF")){
2204 int PriorityNumber = 0;
2205 bool ValidNumber = TRUE;
2208 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2211 catch(std::invalid_argument &e){
2212 ValidNumber = FALSE;
2215 if (ValidNumber == TRUE){
2217 IMListPref->erase(*IMCount);
2218 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2224 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2226 if (FirstToken == TRUE){
2228 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2233 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2243 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2245 // Add the name token data.
2247 if (!PropertyTokens.IsEmpty()){
2249 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2255 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2257 std::map<int, int> SplitPoints;
2258 std::map<int, int> SplitLength;
2259 std::map<int, int>::iterator SLiter;
2263 PropertyType PropType = PROPERTY_NONE;
2265 // Look for type before continuing.
2268 wxString TelTypeDetail;
2269 wxString PropertyData;
2270 wxString PropertyName;
2271 wxString PropertyValue;
2272 wxString PropertyTokens;
2274 std::map<int,int> TypeSplitPoints;
2275 std::map<int,int> TypeSplitLength;
2276 std::map<int,int>::iterator TSLiter;
2278 int intSplitSize = 0;
2279 int intSplitsFound = 0;
2280 int intSplitPoint = 0;
2282 int intPrevValue = 5;
2284 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2288 // Look for type before continuing.
2290 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2291 intiter != SplitPoints.end(); ++intiter){
2293 SLiter = SplitLength.find(intiter->first);
2295 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2297 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2298 PropertyName = PropertyElement.GetNextToken();
2299 PropertyValue = PropertyElement.GetNextToken();
2301 intPrevValue = intiter->second;
2303 if (PropertyName == wxT("TYPE")){
2305 // Process each value in type and translate each
2308 // Strip out the quotes if they are there.
2310 size_t intPropertyValueLen = PropertyValue.Len();
2312 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2314 PropertyValue.Trim();
2315 PropertyValue.RemoveLast();
2319 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2321 PropertyValue.Remove(0, 1);
2325 TelTypeDetail = PropertyValue;
2331 for (int i = 0; i <= intPropertyValueLen; i++){
2335 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2337 if (intSplitsFound == 0){
2339 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2340 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2344 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2345 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2358 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2359 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2361 int intTypeSeek = 0;
2363 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2364 typeiter != TypeSplitPoints.end(); ++typeiter){
2366 wxString TypePropertyName;
2368 TSLiter = TypeSplitLength.find(typeiter->first);
2370 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2372 if (intTypeSeek == 0){
2377 TelTypeUI.Append(wxT(","));
2381 if (TypePropertyName == wxT("home")){
2383 PropType = PROPERTY_HOME;
2385 } else if (TypePropertyName == wxT("work")){
2387 PropType = PROPERTY_WORK;
2392 if (TypePropertyName == wxT("text")){
2394 TelTypeUI.Append(_("text"));
2397 } else if (TypePropertyName == wxT("voice")){
2399 TelTypeUI.Append(_("voice"));
2402 } else if (TypePropertyName == wxT("fax")){
2404 TelTypeUI.Append(_("fax"));
2407 } else if (TypePropertyName == wxT("cell")){
2409 TelTypeUI.Append(_("mobile"));
2412 } else if (TypePropertyName == wxT("video")){
2414 TelTypeUI.Append(_("video"));
2417 } else if (TypePropertyName == wxT("pager")){
2419 TelTypeUI.Append(_("pager"));
2422 } else if (TypePropertyName == wxT("textphone")){
2424 TelTypeUI.Append(_("textphone"));
2435 std::map<int, wxString> *TelephoneList = NULL;
2436 std::map<int, wxString> *TelephoneListType = NULL;
2437 std::map<int, wxString> *TelephoneListAltID = NULL;
2438 std::map<int, wxString> *TelephoneListPID = NULL;
2439 std::map<int, wxString> *TelephoneListTokens = NULL;
2440 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2441 std::map<int, int> *TelephoneListPref = NULL;
2445 TelephoneList = &GeneralTelephoneList;
2446 TelephoneListType = &GeneralTelephoneListType;
2447 TelephoneListAltID = &GeneralTelephoneListAltID;
2448 TelephoneListPID = &GeneralTelephoneListPID;
2449 TelephoneListTokens = &GeneralTelephoneListTokens;
2450 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2451 TelephoneListPref = &GeneralTelephoneListPref;
2454 TelephoneList = &HomeTelephoneList;
2455 TelephoneListType = &HomeTelephoneListType;
2456 TelephoneListAltID = &HomeTelephoneListAltID;
2457 TelephoneListPID = &HomeTelephoneListPID;
2458 TelephoneListTokens = &HomeTelephoneListTokens;
2459 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2460 TelephoneListPref = &HomeTelephoneListPref;
2463 TelephoneList = &BusinessTelephoneList;
2464 TelephoneListType = &BusinessTelephoneListType;
2465 TelephoneListAltID = &BusinessTelephoneListAltID;
2466 TelephoneListPID = &BusinessTelephoneListPID;
2467 TelephoneListTokens = &BusinessTelephoneListTokens;
2468 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2469 TelephoneListPref = &BusinessTelephoneListPref;
2473 // Process the properties.
2475 bool FirstToken = TRUE;
2478 SplitPoints.clear();
2479 SplitLength.clear();
2481 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2485 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2486 intiter != SplitPoints.end(); ++intiter){
2488 SLiter = SplitLength.find(intiter->first);
2490 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2492 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2493 PropertyName = PropertyElement.GetNextToken();
2494 PropertyValue = PropertyElement.GetNextToken();
2496 intPrevValue = intiter->second;
2498 CaptureString(&PropertyValue, FALSE);
2500 // Process properties.
2502 if (PropertyName == wxT("ALTID")){
2504 TelephoneListAltID->erase(*TelephoneCount);
2505 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2507 } else if (PropertyName == wxT("PID")){
2509 TelephoneListPID->erase(*TelephoneCount);
2510 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2512 } else if (PropertyName == wxT("PREF")){
2514 int PriorityNumber = 0;
2515 bool ValidNumber = TRUE;
2518 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2521 catch(std::invalid_argument &e){
2522 ValidNumber = FALSE;
2525 if (ValidNumber == TRUE){
2527 TelephoneListPref->erase(*TelephoneCount);
2528 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2534 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2536 if (FirstToken == TRUE){
2538 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2543 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2553 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2554 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2556 // Add the name token data.
2558 if (!PropertyTokens.IsEmpty()){
2560 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2566 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2568 std::map<int, int> SplitPoints;
2569 std::map<int, int> SplitLength;
2571 int intPrevValue = 6;
2574 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2578 PropertyType PropType = PROPERTY_NONE;
2580 // Look for type before continuing.
2582 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2584 std::map<int, wxString> *LanguageList = NULL;
2585 std::map<int, wxString> *LanguageListType = NULL;
2586 std::map<int, wxString> *LanguageListAltID = NULL;
2587 std::map<int, wxString> *LanguageListPID = NULL;
2588 std::map<int, wxString> *LanguageListTokens = NULL;
2589 std::map<int, int> *LanguageListPref = NULL;
2593 LanguageList = &GeneralLanguageList;
2594 LanguageListType = &GeneralLanguageListType;
2595 LanguageListAltID = &GeneralLanguageListAltID;
2596 LanguageListPID = &GeneralLanguageListPID;
2597 LanguageListTokens = &GeneralLanguageListTokens;
2598 LanguageListPref = &GeneralLanguageListPref;
2601 LanguageList = &HomeLanguageList;
2602 LanguageListType = &HomeLanguageListType;
2603 LanguageListAltID = &HomeLanguageListAltID;
2604 LanguageListPID = &HomeLanguageListPID;
2605 LanguageListTokens = &HomeLanguageListTokens;
2606 LanguageListPref = &HomeLanguageListPref;
2609 LanguageList = &BusinessLanguageList;
2610 LanguageListType = &BusinessLanguageListType;
2611 LanguageListAltID = &BusinessLanguageListAltID;
2612 LanguageListPID = &BusinessLanguageListPID;
2613 LanguageListTokens = &BusinessLanguageListTokens;
2614 LanguageListPref = &BusinessLanguageListPref;
2620 std::map<int,int>::iterator SLiter;
2621 wxString PropertyData;
2622 wxString PropertyName;
2623 wxString PropertyValue;
2624 wxString PropertyTokens;
2625 bool FirstToken = TRUE;
2627 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2628 intiter != SplitPoints.end(); ++intiter){
2630 SLiter = SplitLength.find(intiter->first);
2632 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2634 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2635 PropertyName = PropertyElement.GetNextToken();
2636 PropertyValue = PropertyElement.GetNextToken();
2638 intPrevValue = intiter->second;
2640 CaptureString(&PropertyValue, FALSE);
2642 // Process properties.
2644 if (PropertyName == wxT("ALTID")){
2646 LanguageListAltID->erase(*LanguageCount);
2647 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2649 } else if (PropertyName == wxT("PID")){
2651 LanguageListPID->erase(*LanguageCount);
2652 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2654 } else if (PropertyName == wxT("PREF")){
2656 int PriorityNumber = 0;
2657 bool ValidNumber = TRUE;
2660 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2663 catch(std::invalid_argument &e){
2664 ValidNumber = FALSE;
2667 if (ValidNumber == TRUE){
2669 LanguageListPref->erase(*LanguageCount);
2670 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2676 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2678 if (FirstToken == TRUE){
2680 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2685 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2695 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2697 // Add the name token data.
2699 if (!PropertyTokens.IsEmpty()){
2701 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2707 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2709 std::map<int, int> SplitPoints;
2710 std::map<int, int> SplitLength;
2712 int intPrevValue = 5;
2715 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2719 PropertyType PropType = PROPERTY_NONE;
2721 // Look for type before continuing.
2723 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2725 std::map<int, wxString> *GeopositionList = NULL;
2726 std::map<int, wxString> *GeopositionListType = NULL;
2727 std::map<int, wxString> *GeopositionListAltID = NULL;
2728 std::map<int, wxString> *GeopositionListPID = NULL;
2729 std::map<int, wxString> *GeopositionListTokens = NULL;
2730 std::map<int, wxString> *GeopositionListMediatype = NULL;
2731 std::map<int, int> *GeopositionListPref = NULL;
2735 GeopositionList = &GeneralGeographyList;
2736 GeopositionListType = &GeneralGeographyListType;
2737 GeopositionListAltID = &GeneralGeographyListAltID;
2738 GeopositionListPID = &GeneralGeographyListPID;
2739 GeopositionListTokens = &GeneralGeographyListTokens;
2740 GeopositionListMediatype = &GeneralGeographyListMediatype;
2741 GeopositionListPref = &GeneralGeographyListPref;
2744 GeopositionList = &HomeGeographyList;
2745 GeopositionListType = &HomeGeographyListType;
2746 GeopositionListAltID = &HomeGeographyListAltID;
2747 GeopositionListPID = &HomeGeographyListPID;
2748 GeopositionListTokens = &HomeGeographyListTokens;
2749 GeopositionListMediatype = &HomeGeographyListMediatype;
2750 GeopositionListPref = &HomeGeographyListPref;
2753 GeopositionList = &BusinessGeographyList;
2754 GeopositionListType = &BusinessGeographyListType;
2755 GeopositionListAltID = &BusinessGeographyListAltID;
2756 GeopositionListPID = &BusinessGeographyListPID;
2757 GeopositionListTokens = &BusinessGeographyListTokens;
2758 GeopositionListMediatype = &BusinessGeographyListMediatype;
2759 GeopositionListPref = &BusinessGeographyListPref;
2765 std::map<int,int>::iterator SLiter;
2766 wxString PropertyData;
2767 wxString PropertyName;
2768 wxString PropertyValue;
2769 wxString PropertyTokens;
2770 bool FirstToken = TRUE;
2772 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2773 intiter != SplitPoints.end(); ++intiter){
2775 SLiter = SplitLength.find(intiter->first);
2777 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2779 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2780 PropertyName = PropertyElement.GetNextToken();
2781 PropertyValue = PropertyElement.GetNextToken();
2783 intPrevValue = intiter->second;
2785 CaptureString(&PropertyValue, FALSE);
2787 // Process properties.
2789 if (PropertyName == wxT("ALTID")){
2791 GeopositionListAltID->erase(*GeographicCount);
2792 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2794 } else if (PropertyName == wxT("PID")){
2796 GeopositionListPID->erase(*GeographicCount);
2797 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2799 } else if (PropertyName == wxT("MEDIATYPE")){
2801 GeopositionListMediatype->erase(*GeographicCount);
2802 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2804 } else if (PropertyName == wxT("PREF")){
2806 int PriorityNumber = 0;
2807 bool ValidNumber = TRUE;
2810 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2813 catch(std::invalid_argument &e){
2814 ValidNumber = FALSE;
2817 if (ValidNumber == TRUE){
2819 GeopositionListPref->erase(*GeographicCount);
2820 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2826 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2828 if (FirstToken == TRUE){
2830 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2835 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2845 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2847 // Add the name token data.
2849 if (!PropertyTokens.IsEmpty()){
2851 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2857 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2859 size_t intPropertyLen = PropertySeg1.Len();
2860 std::map<int, int> SplitPoints;
2861 std::map<int, int> SplitLength;
2862 std::map<int, int>::iterator SLiter;
2863 wxString PropertyData;
2864 wxString PropertyName;
2865 wxString PropertyValue;
2866 wxString PropertyTokens;
2867 wxString RelatedType;
2868 wxString RelatedTypeOriginal;
2869 wxString RelatedName;
2870 bool FirstToken = TRUE;
2871 int intSplitsFound = 0;
2872 int intSplitSize = 0;
2873 int intPrevValue = 9;
2877 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2881 // Look for type before continuing.
2883 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2884 intiter != SplitPoints.end(); ++intiter){
2886 SLiter = SplitLength.find(intiter->first);
2888 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2890 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2891 PropertyName = PropertyElement.GetNextToken();
2892 PropertyValue = PropertyElement.GetNextToken();
2894 intPrevValue = intiter->second;
2898 RelatedTypeOriginal = PropertyValue;
2900 if (PropertyName == wxT("TYPE")){
2902 if (PropertyValue == wxT("contact")){
2904 RelatedType = _("Contact");
2906 } else if (PropertyValue == wxT("acquaintance")){
2908 RelatedType = _("Acquaintance");
2910 } else if (PropertyValue == wxT("friend")){
2912 RelatedType = _("Friend");
2914 } else if (PropertyValue == wxT("met")){
2916 RelatedType = _("Met");
2918 } else if (PropertyValue == wxT("co-worker")){
2920 RelatedType = _("Co-worker");
2922 } else if (PropertyValue == wxT("colleague")){
2924 RelatedType = _("Colleague");
2926 } else if (PropertyValue == wxT("co-resident")){
2928 RelatedType = _("Co-resident");
2930 } else if (PropertyValue == wxT("neighbor")){
2932 RelatedType = _("Neighbour");
2934 } else if (PropertyValue == wxT("child")){
2936 RelatedType = _("Child");
2938 } else if (PropertyValue == wxT("parent")){
2940 RelatedType = _("Parent");
2942 } else if (PropertyValue == wxT("sibling")){
2944 RelatedType = _("Sibling");
2946 } else if (PropertyValue == wxT("spouse")){
2948 RelatedType = _("Spouse");
2950 } else if (PropertyValue == wxT("kin")){
2952 RelatedType = _("Kin");
2954 } else if (PropertyValue == wxT("muse")){
2956 RelatedType = _("Muse");
2958 } else if (PropertyValue == wxT("crush")){
2960 RelatedType = _("Crush");
2962 } else if (PropertyValue == wxT("date")){
2964 RelatedType = _("Date");
2966 } else if (PropertyValue == wxT("sweetheart")){
2968 RelatedType = _("Sweetheart");
2970 } else if (PropertyValue == wxT("me")){
2972 RelatedType = _("Me");
2974 } else if (PropertyValue == wxT("agent")){
2976 RelatedType = _("Agent");
2978 } else if (PropertyValue == wxT("emergency")){
2980 RelatedType = _("Emergency");
2984 RelatedType = PropertyValue;
2994 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2995 intiter != SplitPoints.end(); ++intiter){
2997 SLiter = SplitLength.find(intiter->first);
2999 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3001 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3002 PropertyName = PropertyElement.GetNextToken();
3003 PropertyValue = PropertyElement.GetNextToken();
3005 intPrevValue = intiter->second;
3007 // Process properties.
3009 size_t intPropertyValueLen = PropertyValue.Len();
3011 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3013 PropertyValue.Trim();
3014 PropertyValue.RemoveLast();
3018 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3020 PropertyValue.Remove(0, 1);
3024 CaptureString(&PropertyValue, FALSE);
3026 if (PropertyName == wxT("ALTID")){
3028 GeneralRelatedListAltID.erase(*RelatedCount);
3029 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3031 } else if (PropertyName == wxT("PID")){
3033 GeneralRelatedListPID.erase(*RelatedCount);
3034 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3036 } else if (PropertyName == wxT("PREF")){
3038 int PriorityNumber = 0;
3039 bool ValidNumber = TRUE;
3042 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3045 catch(std::invalid_argument &e){
3046 ValidNumber = FALSE;
3049 if (ValidNumber == TRUE){
3051 GeneralRelatedListPref.erase(*RelatedCount);
3052 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3056 } else if (PropertyName == wxT("LANGUAGE")){
3058 GeneralRelatedListLanguage.erase(*RelatedCount);
3059 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3061 } else if (PropertyName != wxT("TYPE")) {
3063 // Something else we don't know about so append
3064 // to the tokens variable.
3066 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3068 if (FirstToken == TRUE){
3070 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3075 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3085 // Add the data to the General/Home/Work address variables.
3087 GeneralRelatedList.erase(*RelatedCount);
3088 GeneralRelatedListRelType.erase(*RelatedCount);
3089 GeneralRelatedListType.erase(*RelatedCount);
3090 GeneralRelatedListTokens.erase(*RelatedCount);
3091 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3092 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3093 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3094 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3098 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3100 std::map<int, int> SplitPoints;
3101 std::map<int, int> SplitLength;
3102 std::map<int, int>::iterator SLiter;
3103 wxString PropertyData;
3104 wxString PropertyName;
3105 wxString PropertyValue;
3106 wxString PropertyTokens;
3107 bool FirstToken = TRUE;
3108 int intPrevValue = 5;
3113 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3117 PropertyType PropType = PROPERTY_NONE;
3119 // Look for type before continuing.
3121 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3123 // Setup the pointers.
3125 std::map<int, wxString> *WebsiteList = NULL;
3126 std::map<int, wxString> *WebsiteListAltID = NULL;
3127 std::map<int, wxString> *WebsiteListPID = NULL;
3128 std::map<int, wxString> *WebsiteListType = NULL;
3129 std::map<int, wxString> *WebsiteListTokens = NULL;
3130 std::map<int, wxString> *WebsiteListMediatype = NULL;
3131 std::map<int, int> *WebsiteListPref = NULL;
3133 // Setup blank lines for later on.
3137 WebsiteList = &GeneralWebsiteList;
3138 WebsiteListType = &GeneralWebsiteListType;
3139 WebsiteListAltID = &GeneralWebsiteListAltID;
3140 WebsiteListPID = &GeneralWebsiteListPID;
3141 WebsiteListTokens = &GeneralWebsiteListTokens;
3142 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3143 WebsiteListPref = &GeneralWebsiteListPref;
3146 WebsiteList = &HomeWebsiteList;
3147 WebsiteListType = &HomeWebsiteListType;
3148 WebsiteListAltID = &HomeWebsiteListAltID;
3149 WebsiteListPID = &HomeWebsiteListPID;
3150 WebsiteListTokens = &HomeWebsiteListTokens;
3151 WebsiteListMediatype = &HomeWebsiteListMediatype;
3152 WebsiteListPref = &HomeWebsiteListPref;
3155 WebsiteList = &BusinessWebsiteList;
3156 WebsiteListType = &BusinessWebsiteListType;
3157 WebsiteListAltID = &BusinessWebsiteListAltID;
3158 WebsiteListPID = &BusinessWebsiteListPID;
3159 WebsiteListTokens = &BusinessWebsiteListTokens;
3160 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3161 WebsiteListPref = &BusinessWebsiteListPref;
3167 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3168 intiter != SplitPoints.end(); ++intiter){
3170 SLiter = SplitLength.find(intiter->first);
3172 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3174 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3175 PropertyName = PropertyElement.GetNextToken();
3176 PropertyValue = PropertyElement.GetNextToken();
3178 intPrevValue = intiter->second;
3180 // Process properties.
3182 size_t intPropertyValueLen = PropertyValue.Len();
3184 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3186 PropertyValue.Trim();
3187 PropertyValue.RemoveLast();
3191 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3193 PropertyValue.Remove(0, 1);
3197 CaptureString(&PropertyValue, FALSE);
3199 if (PropertyName == wxT("ALTID")){
3201 WebsiteListAltID->erase(*URLCount);
3202 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3204 } else if (PropertyName == wxT("PID")){
3206 WebsiteListPID->erase(*URLCount);
3207 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3209 } else if (PropertyName == wxT("PREF")){
3211 int PriorityNumber = 0;
3212 bool ValidNumber = TRUE;
3215 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3218 catch(std::invalid_argument &e){
3219 ValidNumber = FALSE;
3222 if (ValidNumber == TRUE){
3224 WebsiteListPref->erase(*URLCount);
3225 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3229 } else if (PropertyName == wxT("MEDIATYPE")){
3231 WebsiteListMediatype->erase(*URLCount);
3232 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3236 // Something else we don't know about so append
3237 // to the tokens variable.
3239 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3241 if (FirstToken == TRUE){
3243 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3248 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3258 // Add the data to the General/Home/Work address variables.
3260 CaptureString(&PropertySeg2, FALSE);
3262 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3264 if (!PropertyTokens.IsEmpty()){
3266 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3272 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3274 std::map<int, int> SplitPoints;
3275 std::map<int, int> SplitLength;
3276 std::map<int, int>::iterator SLiter;
3277 wxString PropertyData;
3278 wxString PropertyName;
3279 wxString PropertyValue;
3280 wxString PropertyTokens;
3281 bool FirstToken = TRUE;
3282 int intPrevValue = 7;
3287 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3291 PropertyType PropType = PROPERTY_NONE;
3293 // Look for type before continuing.
3295 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3297 // Setup the pointers.
3299 std::map<int, wxString> *TitleList = NULL;
3300 std::map<int, wxString> *TitleListAltID = NULL;
3301 std::map<int, wxString> *TitleListPID = NULL;
3302 std::map<int, wxString> *TitleListType = NULL;
3303 std::map<int, wxString> *TitleListTokens = NULL;
3304 std::map<int, wxString> *TitleListLanguage = NULL;
3305 std::map<int, int> *TitleListPref = NULL;
3307 // Setup blank lines for later on.
3311 TitleList = &GeneralTitleList;
3312 TitleListType = &GeneralTitleListType;
3313 TitleListAltID = &GeneralTitleListAltID;
3314 TitleListPID = &GeneralTitleListPID;
3315 TitleListTokens = &GeneralTitleListTokens;
3316 TitleListLanguage = &GeneralTitleListLanguage;
3317 TitleListPref = &GeneralTitleListPref;
3320 TitleList = &HomeTitleList;
3321 TitleListType = &HomeTitleListType;
3322 TitleListAltID = &HomeTitleListAltID;
3323 TitleListPID = &HomeTitleListPID;
3324 TitleListTokens = &HomeTitleListTokens;
3325 TitleListLanguage = &HomeTitleListLanguage;
3326 TitleListPref = &HomeTitleListPref;
3329 TitleList = &BusinessTitleList;
3330 TitleListType = &BusinessTitleListType;
3331 TitleListAltID = &BusinessTitleListAltID;
3332 TitleListPID = &BusinessTitleListPID;
3333 TitleListTokens = &BusinessTitleListTokens;
3334 TitleListLanguage = &BusinessTitleListLanguage;
3335 TitleListPref = &BusinessTitleListPref;
3341 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3342 intiter != SplitPoints.end(); ++intiter){
3344 SLiter = SplitLength.find(intiter->first);
3346 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3348 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3349 PropertyName = PropertyElement.GetNextToken();
3350 PropertyValue = PropertyElement.GetNextToken();
3352 intPrevValue = intiter->second;
3354 // Process properties.
3356 size_t intPropertyValueLen = PropertyValue.Len();
3358 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3360 PropertyValue.Trim();
3361 PropertyValue.RemoveLast();
3365 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3367 PropertyValue.Remove(0, 1);
3371 CaptureString(&PropertyValue, FALSE);
3373 if (PropertyName == wxT("ALTID")){
3375 TitleListAltID->erase(*TitleCount);
3376 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3378 } else if (PropertyName == wxT("PID")){
3380 TitleListPID->erase(*TitleCount);
3381 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3383 } else if (PropertyName == wxT("PREF")){
3385 int PriorityNumber = 0;
3386 bool ValidNumber = TRUE;
3389 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3392 catch(std::invalid_argument &e){
3393 ValidNumber = FALSE;
3396 if (ValidNumber == TRUE){
3398 TitleListPref->erase(*TitleCount);
3399 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3403 } else if (PropertyName == wxT("LANGUAGE")){
3405 TitleListLanguage->erase(*TitleCount);
3406 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3410 // Something else we don't know about so append
3411 // to the tokens variable.
3413 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3415 if (FirstToken == TRUE){
3417 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3422 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3432 // Add the data to the General/Home/Work address variables.
3434 CaptureString(&PropertySeg2, FALSE);
3436 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3438 if (!PropertyTokens.IsEmpty()){
3440 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3446 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3448 std::map<int, int> SplitPoints;
3449 std::map<int, int> SplitLength;
3450 std::map<int, int>::iterator SLiter;
3451 wxString PropertyData;
3452 wxString PropertyName;
3453 wxString PropertyValue;
3454 wxString PropertyTokens;
3455 bool FirstToken = TRUE;
3456 int intPrevValue = 6;
3461 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3465 PropertyType PropType = PROPERTY_NONE;
3467 // Look for type before continuing.
3469 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3471 // Setup the pointers.
3473 std::map<int, wxString> *RoleList = NULL;
3474 std::map<int, wxString> *RoleListAltID = NULL;
3475 std::map<int, wxString> *RoleListPID = NULL;
3476 std::map<int, wxString> *RoleListType = NULL;
3477 std::map<int, wxString> *RoleListTokens = NULL;
3478 std::map<int, wxString> *RoleListLanguage = NULL;
3479 std::map<int, int> *RoleListPref = NULL;
3481 // Setup blank lines for later on.
3485 RoleList = &GeneralRoleList;
3486 RoleListType = &GeneralRoleListType;
3487 RoleListAltID = &GeneralRoleListAltID;
3488 RoleListPID = &GeneralRoleListPID;
3489 RoleListTokens = &GeneralRoleListTokens;
3490 RoleListLanguage = &GeneralRoleListLanguage;
3491 RoleListPref = &GeneralRoleListPref;
3494 RoleList = &HomeRoleList;
3495 RoleListType = &HomeRoleListType;
3496 RoleListAltID = &HomeRoleListAltID;
3497 RoleListPID = &HomeRoleListPID;
3498 RoleListTokens = &HomeRoleListTokens;
3499 RoleListLanguage = &HomeRoleListLanguage;
3500 RoleListPref = &HomeRoleListPref;
3503 RoleList = &BusinessRoleList;
3504 RoleListType = &BusinessRoleListType;
3505 RoleListAltID = &BusinessRoleListAltID;
3506 RoleListPID = &BusinessRoleListPID;
3507 RoleListTokens = &BusinessRoleListTokens;
3508 RoleListLanguage = &BusinessRoleListLanguage;
3509 RoleListPref = &BusinessRoleListPref;
3515 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3516 intiter != SplitPoints.end(); ++intiter){
3518 SLiter = SplitLength.find(intiter->first);
3520 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3522 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3523 PropertyName = PropertyElement.GetNextToken();
3524 PropertyValue = PropertyElement.GetNextToken();
3526 intPrevValue = intiter->second;
3528 // Process properties.
3530 size_t intPropertyValueLen = PropertyValue.Len();
3532 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3534 PropertyValue.Trim();
3535 PropertyValue.RemoveLast();
3539 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3541 PropertyValue.Remove(0, 1);
3545 CaptureString(&PropertyValue, FALSE);
3547 if (PropertyName == wxT("ALTID")){
3549 RoleListAltID->erase(*RoleCount);
3550 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3552 } else if (PropertyName == wxT("PID")){
3554 RoleListPID->erase(*RoleCount);
3555 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3557 } else if (PropertyName == wxT("PREF")){
3559 int PriorityNumber = 0;
3560 bool ValidNumber = TRUE;
3563 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3566 catch(std::invalid_argument &e){
3567 ValidNumber = FALSE;
3570 if (ValidNumber == TRUE){
3572 RoleListPref->erase(*RoleCount);
3573 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3577 } else if (PropertyName == wxT("LANGUAGE")){
3579 RoleListLanguage->erase(*RoleCount);
3580 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3584 // Something else we don't know about so append
3585 // to the tokens variable.
3587 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3589 if (FirstToken == TRUE){
3591 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3596 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3606 // Add the data to the General/Home/Work address variables.
3608 CaptureString(&PropertySeg2, FALSE);
3610 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3612 if (!PropertyTokens.IsEmpty()){
3614 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3620 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3622 std::map<int, int> SplitPoints;
3623 std::map<int, int> SplitLength;
3624 std::map<int, int>::iterator SLiter;
3625 wxString PropertyData;
3626 wxString PropertyName;
3627 wxString PropertyValue;
3628 wxString PropertyTokens;
3629 bool FirstToken = TRUE;
3630 int intPrevValue = 5;
3635 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3639 PropertyType PropType = PROPERTY_NONE;
3641 // Look for type before continuing.
3643 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3645 // Setup the pointers.
3647 std::map<int, wxString> *OrganisationsList = NULL;
3648 std::map<int, wxString> *OrganisationsListAltID = NULL;
3649 std::map<int, wxString> *OrganisationsListPID = NULL;
3650 std::map<int, wxString> *OrganisationsListType = NULL;
3651 std::map<int, wxString> *OrganisationsListTokens = NULL;
3652 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3653 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3654 std::map<int, int> *OrganisationsListPref = NULL;
3656 // Setup blank lines for later on.
3660 OrganisationsList = &GeneralOrganisationsList;
3661 OrganisationsListType = &GeneralOrganisationsListType;
3662 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3663 OrganisationsListPID = &GeneralOrganisationsListPID;
3664 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3665 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3666 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3667 OrganisationsListPref = &GeneralOrganisationsListPref;
3670 OrganisationsList = &HomeOrganisationsList;
3671 OrganisationsListType = &HomeOrganisationsListType;
3672 OrganisationsListAltID = &HomeOrganisationsListAltID;
3673 OrganisationsListPID = &HomeOrganisationsListPID;
3674 OrganisationsListTokens = &HomeOrganisationsListTokens;
3675 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3676 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3677 OrganisationsListPref = &HomeOrganisationsListPref;
3680 OrganisationsList = &BusinessOrganisationsList;
3681 OrganisationsListType = &BusinessOrganisationsListType;
3682 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3683 OrganisationsListPID = &BusinessOrganisationsListPID;
3684 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3685 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3686 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3687 OrganisationsListPref = &BusinessOrganisationsListPref;
3693 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3694 intiter != SplitPoints.end(); ++intiter){
3696 SLiter = SplitLength.find(intiter->first);
3698 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3700 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3701 PropertyName = PropertyElement.GetNextToken();
3702 PropertyValue = PropertyElement.GetNextToken();
3704 intPrevValue = intiter->second;
3706 // Process properties.
3708 size_t intPropertyValueLen = PropertyValue.Len();
3710 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3712 PropertyValue.Trim();
3713 PropertyValue.RemoveLast();
3717 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3719 PropertyValue.Remove(0, 1);
3723 CaptureString(&PropertyValue, FALSE);
3725 if (PropertyName == wxT("ALTID")){
3727 OrganisationsListAltID->erase(*OrganisationCount);
3728 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3730 } else if (PropertyName == wxT("PID")){
3732 OrganisationsListPID->erase(*OrganisationCount);
3733 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3735 } else if (PropertyName == wxT("SORT-AS")){
3737 OrganisationsListSortAs->erase(*OrganisationCount);
3738 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3740 } else if (PropertyName == wxT("PREF")){
3742 int PriorityNumber = 0;
3743 bool ValidNumber = TRUE;
3746 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3749 catch(std::invalid_argument &e){
3750 ValidNumber = FALSE;
3753 if (ValidNumber == TRUE){
3755 OrganisationsListPref->erase(*OrganisationCount);
3756 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3760 } else if (PropertyName == wxT("LANGUAGE")){
3762 OrganisationsListLanguage->erase(*OrganisationCount);
3763 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3767 // Something else we don't know about so append
3768 // to the tokens variable.
3770 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3772 if (FirstToken == TRUE){
3774 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3779 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3789 // Add the data to the General/Home/Work address variables.
3791 CaptureString(&PropertySeg2, FALSE);
3793 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3795 if (!PropertyTokens.IsEmpty()){
3797 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3803 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3805 std::map<int, int> SplitPoints;
3806 std::map<int, int> SplitLength;
3807 std::map<int, int>::iterator SLiter;
3808 wxString PropertyData;
3809 wxString PropertyName;
3810 wxString PropertyValue;
3811 wxString PropertyTokens;
3812 bool FirstToken = TRUE;
3813 int intPrevValue = 6;
3818 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3822 PropertyType PropType = PROPERTY_NONE;
3824 // Look for type before continuing.
3826 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3828 // Setup the pointers.
3830 std::map<int, wxString> *NoteList = NULL;
3831 std::map<int, wxString> *NoteListAltID = NULL;
3832 std::map<int, wxString> *NoteListPID = NULL;
3833 std::map<int, wxString> *NoteListType = NULL;
3834 std::map<int, wxString> *NoteListTokens = NULL;
3835 std::map<int, wxString> *NoteListLanguage = NULL;
3836 std::map<int, int> *NoteListPref = NULL;
3838 // Setup blank lines for later on.
3842 NoteList = &GeneralNoteList;
3843 NoteListType = &GeneralNoteListType;
3844 NoteListAltID = &GeneralNoteListAltID;
3845 NoteListPID = &GeneralNoteListPID;
3846 NoteListTokens = &GeneralNoteListTokens;
3847 NoteListLanguage = &GeneralNoteListLanguage;
3848 NoteListPref = &GeneralNoteListPref;
3851 NoteList = &HomeNoteList;
3852 NoteListType = &HomeNoteListType;
3853 NoteListAltID = &HomeNoteListAltID;
3854 NoteListPID = &HomeNoteListPID;
3855 NoteListTokens = &HomeNoteListTokens;
3856 NoteListLanguage = &HomeNoteListLanguage;
3857 NoteListPref = &HomeNoteListPref;
3860 NoteList = &BusinessNoteList;
3861 NoteListType = &BusinessNoteListType;
3862 NoteListAltID = &BusinessNoteListAltID;
3863 NoteListPID = &BusinessNoteListPID;
3864 NoteListTokens = &BusinessNoteListTokens;
3865 NoteListLanguage = &BusinessNoteListLanguage;
3866 NoteListPref = &BusinessNoteListPref;
3872 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3873 intiter != SplitPoints.end(); ++intiter){
3875 SLiter = SplitLength.find(intiter->first);
3877 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3879 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3880 PropertyName = PropertyElement.GetNextToken();
3881 PropertyValue = PropertyElement.GetNextToken();
3883 intPrevValue = intiter->second;
3885 // Process properties.
3887 size_t intPropertyValueLen = PropertyValue.Len();
3889 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3891 PropertyValue.Trim();
3892 PropertyValue.RemoveLast();
3896 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3898 PropertyValue.Remove(0, 1);
3902 CaptureString(&PropertyValue, FALSE);
3904 if (PropertyName == wxT("ALTID")){
3906 NoteListAltID->erase(*NoteCount);
3907 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3909 } else if (PropertyName == wxT("PID")){
3911 NoteListPID->erase(*NoteCount);
3912 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3914 } else if (PropertyName == wxT("PREF")){
3916 int PriorityNumber = 0;
3917 bool ValidNumber = TRUE;
3920 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3923 catch(std::invalid_argument &e){
3924 ValidNumber = FALSE;
3927 if (ValidNumber == TRUE){
3929 NoteListPref->erase(*NoteCount);
3930 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3934 } else if (PropertyName == wxT("LANGUAGE")){
3936 NoteListLanguage->erase(*NoteCount);
3937 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3941 // Something else we don't know about so append
3942 // to the tokens variable.
3944 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3946 if (FirstToken == TRUE){
3948 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3953 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3963 // Add the data to the General/Home/Work address variables.
3965 CaptureString(&PropertySeg2, FALSE);
3967 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3969 if (!PropertyTokens.IsEmpty()){
3971 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3977 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3979 std::map<int, int> SplitPoints;
3980 std::map<int, int> SplitLength;
3981 std::map<int, int>::iterator SLiter;
3982 wxString PropertyData;
3983 wxString PropertyName;
3984 wxString PropertyValue;
3985 wxString PropertyTokens;
3986 bool FirstToken = TRUE;
3987 int intPrevValue = 12;
3992 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3996 PropertyType PropType = PROPERTY_NONE;
3998 // Look for type before continuing.
4000 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4002 // Setup blank lines for later on.
4008 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4011 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4017 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4018 intiter != SplitPoints.end(); ++intiter){
4020 SLiter = SplitLength.find(intiter->first);
4022 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4024 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4025 PropertyName = PropertyElement.GetNextToken();
4026 PropertyValue = PropertyElement.GetNextToken();
4028 intPrevValue = intiter->second;
4030 // Process properties.
4032 size_t intPropertyValueLen = PropertyValue.Len();
4034 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4036 PropertyValue.Trim();
4037 PropertyValue.RemoveLast();
4041 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4043 PropertyValue.Remove(0, 1);
4047 CaptureString(&PropertyValue, FALSE);
4049 if (PropertyName == wxT("ALTID")){
4051 CategoriesListAltID.erase(*CategoryCount);
4052 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4054 } else if (PropertyName == wxT("PID")){
4056 CategoriesListPID.erase(*CategoryCount);
4057 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4059 } else if (PropertyName == wxT("PREF")){
4061 int PriorityNumber = 0;
4062 bool ValidNumber = TRUE;
4065 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4068 catch(std::invalid_argument &e){
4069 ValidNumber = FALSE;
4072 if (ValidNumber == TRUE){
4074 CategoriesListPref.erase(*CategoryCount);
4075 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4079 } else if (PropertyName == wxT("LANGUAGE")){
4081 CategoriesListLanguage.erase(*CategoryCount);
4082 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4086 // Something else we don't know about so append
4087 // to the tokens variable.
4089 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4091 if (FirstToken == TRUE){
4093 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4098 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4108 // Deal with multiple categories.
4110 int intOrigCatCount = *CategoryCount;
4111 bool FirstCategoryProcessed = TRUE;
4112 bool AfterFirstToken = FALSE;
4113 int intSplitSize = 0;
4114 int intSplitsFound = 0;
4115 int intSplitSeek = 0;
4116 int intPropertyLen = PropertySeg2.Len();
4118 SplitPoints.clear();
4119 SplitLength.clear();
4122 for (int i = 0; i <= intPropertyLen; i++){
4124 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4132 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4134 if (AfterFirstToken == TRUE){
4136 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4137 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4141 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4142 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4143 AfterFirstToken = TRUE;
4155 if (SplitPoints.size() > 0){
4157 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4158 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4162 if (SplitPoints.size() == 0){
4164 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4166 if (!PropertyTokens.IsEmpty()){
4168 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4174 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4175 intiter != SplitPoints.end(); ++intiter){
4177 SLiter = SplitLength.find(intiter->first);
4179 intPrevValue = intiter->second;
4181 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4183 // Add the data to the General/Home/Work address variables.
4185 // Trim any whitespace from the start and end.
4187 PropertyData = PropertyData.Trim(FALSE);
4188 PropertyData = PropertyData.Trim(TRUE);
4190 CaptureString(&PropertyData, FALSE);
4192 if (FirstCategoryProcessed == TRUE){
4194 FirstCategoryProcessed = FALSE;
4196 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4198 if (!PropertyTokens.IsEmpty()){
4200 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4210 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4212 if (!PropertyTokens.IsEmpty()){
4214 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4220 // Copy the properties to each of the categories (if it exists).
4222 if (!PropertyTokens.IsEmpty()){
4224 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4228 // Check if ALTID was used.
4230 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4232 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4236 // Check if PID was used.
4238 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4240 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4244 // Check if PREF was used.
4246 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4248 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4252 // Check if LANGUAGE was used.
4254 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4256 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4260 // Check if TYPE was used.
4266 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4269 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4277 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4279 size_t intPropertyLen = PropertySeg1.Len();
4280 std::map<int, int> SplitPoints;
4281 std::map<int, int> SplitLength;
4282 std::map<int, int>::iterator SLiter;
4283 wxString PropertyData;
4284 wxString PropertyName;
4285 wxString PropertyValue;
4286 wxString PropertyTokens;
4287 bool FirstToken = TRUE;
4288 int intSplitsFound = 0;
4289 int intSplitSize = 0;
4290 int intPrevValue = 7;
4294 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4298 PropertyType PropType = PROPERTY_NONE;
4300 // Look for type before continuing.
4302 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4306 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4307 intiter != SplitPoints.end(); ++intiter){
4309 SLiter = SplitLength.find(intiter->first);
4311 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4313 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4314 PropertyName = PropertyElement.GetNextToken();
4315 PropertyValue = PropertyElement.GetNextToken();
4317 intPrevValue = intiter->second;
4319 // Process properties.
4321 size_t intPropertyValueLen = PropertyValue.Len();
4323 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4325 PropertyValue.Trim();
4326 PropertyValue.RemoveLast();
4330 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4332 PropertyValue.Remove(0, 1);
4336 CaptureString(&PropertyValue, FALSE);
4338 if (PropertyName == wxT("ALTID")){
4340 PicturesListAltID.erase(*PhotoCount);
4341 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4343 } else if (PropertyName == wxT("PID")){
4345 PicturesListPID.erase(*PhotoCount);
4346 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4348 } else if (PropertyName == wxT("PREF")){
4350 int PriorityNumber = 0;
4351 bool ValidNumber = TRUE;
4354 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4357 catch(std::invalid_argument &e){
4358 ValidNumber = FALSE;
4361 if (ValidNumber == TRUE){
4363 PicturesListPref.erase(*PhotoCount);
4364 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4368 } else if (PropertyName == wxT("MEDIATYPE")){
4370 PicturesListMediatype.erase(*PhotoCount);
4371 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4375 // Something else we don't know about so append
4376 // to the tokens variable.
4378 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4380 if (FirstToken == TRUE){
4382 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4387 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4397 intPropertyLen = PropertySeg2.Len();
4398 SplitPoints.clear();
4399 SplitLength.clear();
4404 CaptureString(&PropertySeg2, FALSE);
4406 for (int i = 0; i <= intPropertyLen; i++){
4410 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4413 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4415 if (intSplitsFound == 6){
4417 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4422 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4432 wxString wxSPhotoURI;
4433 wxString wxSPhotoMIME;
4434 wxString wxSPhotoEncoding;
4435 wxString wxSPhotoData;
4436 std::string base64enc;
4438 if (intSplitsFound == 0){
4442 std::map<int, int>::iterator striter;
4444 striter = SplitLength.find(1);
4446 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4448 while (wSTDataType.HasMoreTokens() == TRUE){
4450 wxSPhotoURI = wSTDataType.GetNextToken();
4451 wxSPhotoMIME = wSTDataType.GetNextToken();
4456 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4458 while (wSTDataInfo.HasMoreTokens() == TRUE){
4460 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4461 wxSPhotoData = wSTDataInfo.GetNextToken();
4462 base64enc = wxSPhotoData.mb_str();
4469 // Add the data to the General/Home/Work address variables.
4471 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4472 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4473 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4479 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4482 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4486 if (!PropertyTokens.IsEmpty()){
4488 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4494 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4496 size_t intPropertyLen = PropertySeg1.Len();
4497 std::map<int, int> SplitPoints;
4498 std::map<int, int> SplitLength;
4499 std::map<int, int>::iterator SLiter;
4500 wxString PropertyData;
4501 wxString PropertyName;
4502 wxString PropertyValue;
4503 wxString PropertyTokens;
4504 bool FirstToken = TRUE;
4505 int intSplitsFound = 0;
4506 int intSplitSize = 0;
4507 int intPrevValue = 6;
4511 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4515 PropertyType PropType = PROPERTY_NONE;
4517 // Look for type before continuing.
4519 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4523 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4524 intiter != SplitPoints.end(); ++intiter){
4526 SLiter = SplitLength.find(intiter->first);
4528 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4530 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4531 PropertyName = PropertyElement.GetNextToken();
4532 PropertyValue = PropertyElement.GetNextToken();
4534 intPrevValue = intiter->second;
4536 // Process properties.
4538 size_t intPropertyValueLen = PropertyValue.Len();
4540 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4542 PropertyValue.Trim();
4543 PropertyValue.RemoveLast();
4547 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4549 PropertyValue.Remove(0, 1);
4553 CaptureString(&PropertyValue, FALSE);
4555 if (PropertyName == wxT("ALTID")){
4557 LogosListAltID.erase(*LogoCount);
4558 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4560 } else if (PropertyName == wxT("PID")){
4562 LogosListPID.erase(*LogoCount);
4563 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4565 } else if (PropertyName == wxT("PREF")){
4567 int PriorityNumber = 0;
4568 bool ValidNumber = TRUE;
4571 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4574 catch(std::invalid_argument &e){
4575 ValidNumber = FALSE;
4578 if (ValidNumber == TRUE){
4580 LogosListPref.erase(*LogoCount);
4581 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4585 } else if (PropertyName == wxT("MEDIATYPE")){
4587 LogosListMediatype.erase(*LogoCount);
4588 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4592 // Something else we don't know about so append
4593 // to the tokens variable.
4595 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4597 if (FirstToken == TRUE){
4599 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4604 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4614 intPropertyLen = PropertySeg2.Len();
4615 SplitPoints.clear();
4616 SplitLength.clear();
4621 CaptureString(&PropertySeg2, FALSE);
4623 for (int i = 0; i <= intPropertyLen; i++){
4627 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4630 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4632 if (intSplitsFound == 6){
4634 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4639 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4649 wxString wxSPhotoURI;
4650 wxString wxSPhotoMIME;
4651 wxString wxSPhotoEncoding;
4652 wxString wxSPhotoData;
4653 std::string base64enc;
4655 if (intSplitsFound == 0){
4659 std::map<int, int>::iterator striter;
4661 striter = SplitLength.find(1);
4663 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4665 while (wSTDataType.HasMoreTokens() == TRUE){
4667 wxSPhotoURI = wSTDataType.GetNextToken();
4668 wxSPhotoMIME = wSTDataType.GetNextToken();
4673 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4675 while (wSTDataInfo.HasMoreTokens() == TRUE){
4677 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4678 wxSPhotoData = wSTDataInfo.GetNextToken();
4679 base64enc = wxSPhotoData.mb_str();
4686 // Add the data to the General/Home/Work address variables.
4688 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4689 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4690 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4696 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4699 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4703 if (!PropertyTokens.IsEmpty()){
4705 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4711 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4713 size_t intPropertyLen = PropertySeg1.Len();
4714 std::map<int, int> SplitPoints;
4715 std::map<int, int> SplitLength;
4716 std::map<int, int>::iterator SLiter;
4717 wxString PropertyData;
4718 wxString PropertyName;
4719 wxString PropertyValue;
4720 wxString PropertyTokens;
4721 bool FirstToken = TRUE;
4722 int intSplitsFound = 0;
4723 int intSplitSize = 0;
4724 int intPrevValue = 7;
4728 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4732 PropertyType PropType = PROPERTY_NONE;
4734 // Look for type before continuing.
4736 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4740 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4741 intiter != SplitPoints.end(); ++intiter){
4743 SLiter = SplitLength.find(intiter->first);
4745 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4747 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4748 PropertyName = PropertyElement.GetNextToken();
4749 PropertyValue = PropertyElement.GetNextToken();
4751 intPrevValue = intiter->second;
4753 // Process properties.
4755 size_t intPropertyValueLen = PropertyValue.Len();
4757 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4759 PropertyValue.Trim();
4760 PropertyValue.RemoveLast();
4764 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4766 PropertyValue.Remove(0, 1);
4770 CaptureString(&PropertyValue, FALSE);
4772 if (PropertyName == wxT("ALTID")){
4774 SoundsListAltID.erase(*SoundCount);
4775 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4777 } else if (PropertyName == wxT("PID")){
4779 SoundsListPID.erase(*SoundCount);
4780 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4782 } else if (PropertyName == wxT("PREF")){
4784 int PriorityNumber = 0;
4785 bool ValidNumber = TRUE;
4788 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4791 catch(std::invalid_argument &e){
4792 ValidNumber = FALSE;
4795 if (ValidNumber == TRUE){
4797 SoundsListPref.erase(*SoundCount);
4798 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4802 } else if (PropertyName == wxT("MEDIATYPE")){
4804 SoundsListMediatype.erase(*SoundCount);
4805 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4807 } else if (PropertyName == wxT("LANGUAGE")){
4809 SoundsListLanguage.erase(*SoundCount);
4810 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4814 // Something else we don't know about so append
4815 // to the tokens variable.
4817 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4819 if (FirstToken == TRUE){
4821 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4826 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4836 intPropertyLen = PropertySeg2.Len();
4837 SplitPoints.clear();
4838 SplitLength.clear();
4843 CaptureString(&PropertySeg2, FALSE);
4845 for (int i = 0; i <= intPropertyLen; i++){
4849 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4852 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4854 if (intSplitsFound == 6){
4856 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4861 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4871 wxString wxSSoundURI;
4872 wxString wxSSoundMIME;
4873 wxString wxSSoundEncoding;
4874 wxString wxSSoundData;
4875 std::string base64enc;
4877 if (intSplitsFound == 0){
4881 std::map<int, int>::iterator striter;
4883 striter = SplitLength.find(1);
4885 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4887 while (wSTDataType.HasMoreTokens() == TRUE){
4889 wxSSoundURI = wSTDataType.GetNextToken();
4890 wxSSoundMIME = wSTDataType.GetNextToken();
4895 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4897 while (wSTDataInfo.HasMoreTokens() == TRUE){
4899 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4900 wxSSoundData = wSTDataInfo.GetNextToken();
4901 base64enc = wxSSoundData.mb_str();
4908 // Add the data to the General/Home/Work address variables.
4914 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4917 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4921 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4922 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4923 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4925 if (!PropertyTokens.IsEmpty()){
4927 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4933 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4935 size_t intPropertyLen = PropertySeg1.Len();
4936 std::map<int, int> SplitPoints;
4937 std::map<int, int> SplitLength;
4938 std::map<int, int>::iterator SLiter;
4939 wxString PropertyData;
4940 wxString PropertyName;
4941 wxString PropertyValue;
4942 wxString PropertyTokens;
4943 bool FirstToken = TRUE;
4944 int intSplitsFound = 0;
4945 int intSplitSize = 0;
4946 int intPrevValue = 8;
4950 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4954 PropertyType PropType = PROPERTY_NONE;
4956 // Look for type before continuing.
4958 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4962 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4963 intiter != SplitPoints.end(); ++intiter){
4965 SLiter = SplitLength.find(intiter->first);
4967 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4969 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4970 PropertyName = PropertyElement.GetNextToken();
4971 PropertyValue = PropertyElement.GetNextToken();
4973 intPrevValue = intiter->second;
4975 // Process properties.
4977 size_t intPropertyValueLen = PropertyValue.Len();
4979 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4981 PropertyValue.Trim();
4982 PropertyValue.RemoveLast();
4986 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4988 PropertyValue.Remove(0, 1);
4992 CaptureString(&PropertyValue, FALSE);
4994 if (PropertyName == wxT("ALTID")){
4996 CalendarListAltID.erase(*CalURICount);
4997 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4999 } else if (PropertyName == wxT("PID")){
5001 CalendarListPID.erase(*CalURICount);
5002 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5004 } else if (PropertyName == wxT("PREF")){
5006 int PriorityNumber = 0;
5007 bool ValidNumber = TRUE;
5010 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5013 catch(std::invalid_argument &e){
5014 ValidNumber = FALSE;
5017 if (ValidNumber == TRUE){
5019 CalendarListPref.erase(*CalURICount);
5020 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5024 } else if (PropertyName == wxT("MEDIATYPE")){
5026 CalendarListMediatype.erase(*CalURICount);
5027 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5031 // Something else we don't know about so append
5032 // to the tokens variable.
5034 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5036 if (FirstToken == TRUE){
5038 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5043 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5053 intPropertyLen = PropertySeg2.Len();
5054 SplitPoints.clear();
5055 SplitLength.clear();
5060 CaptureString(&PropertySeg2, FALSE);
5062 // Add the data to the General/Home/Work address variables.
5068 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5071 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5075 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5077 if (!PropertyTokens.IsEmpty()){
5079 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5085 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5087 size_t intPropertyLen = PropertySeg1.Len();
5088 std::map<int, int> SplitPoints;
5089 std::map<int, int> SplitLength;
5090 std::map<int, int>::iterator SLiter;
5091 wxString PropertyData;
5092 wxString PropertyName;
5093 wxString PropertyValue;
5094 wxString PropertyTokens;
5095 bool FirstToken = TRUE;
5096 int intSplitsFound = 0;
5097 int intSplitSize = 0;
5098 int intPrevValue = 8;
5102 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5106 PropertyType PropType = PROPERTY_NONE;
5108 // Look for type before continuing.
5110 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5114 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5115 intiter != SplitPoints.end(); ++intiter){
5117 SLiter = SplitLength.find(intiter->first);
5119 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5121 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5122 PropertyName = PropertyElement.GetNextToken();
5123 PropertyValue = PropertyElement.GetNextToken();
5125 intPrevValue = intiter->second;
5127 // Process properties.
5129 size_t intPropertyValueLen = PropertyValue.Len();
5131 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5133 PropertyValue.Trim();
5134 PropertyValue.RemoveLast();
5138 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5140 PropertyValue.Remove(0, 1);
5144 CaptureString(&PropertyValue, FALSE);
5146 if (PropertyName == wxT("ALTID")){
5148 CalendarRequestListAltID.erase(*CalAdrURICount);
5149 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5151 } else if (PropertyName == wxT("PID")){
5153 CalendarRequestListPID.erase(*CalAdrURICount);
5154 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5156 } else if (PropertyName == wxT("PREF")){
5158 int PriorityNumber = 0;
5159 bool ValidNumber = TRUE;
5162 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5165 catch(std::invalid_argument &e){
5166 ValidNumber = FALSE;
5169 if (ValidNumber == TRUE){
5171 CalendarRequestListPref.erase(*CalAdrURICount);
5172 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5176 } else if (PropertyName == wxT("MEDIATYPE")){
5178 CalendarRequestListMediatype.erase(*CalAdrURICount);
5179 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5183 // Something else we don't know about so append
5184 // to the tokens variable.
5186 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5188 if (FirstToken == TRUE){
5190 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5195 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5205 intPropertyLen = PropertySeg2.Len();
5206 SplitPoints.clear();
5207 SplitLength.clear();
5212 CaptureString(&PropertySeg2, FALSE);
5214 // Add the data to the General/Home/Work address variables.
5220 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5223 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5227 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5229 if (!PropertyTokens.IsEmpty()){
5231 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5237 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5239 size_t intPropertyLen = PropertySeg1.Len();
5240 std::map<int, int> SplitPoints;
5241 std::map<int, int> SplitLength;
5242 std::map<int, int>::iterator SLiter;
5243 wxString PropertyData;
5244 wxString PropertyName;
5245 wxString PropertyValue;
5246 wxString PropertyTokens;
5247 bool FirstToken = TRUE;
5248 int intSplitsFound = 0;
5249 int intSplitSize = 0;
5250 int intPrevValue = 7;
5254 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5258 PropertyType PropType = PROPERTY_NONE;
5260 // Look for type before continuing.
5262 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5266 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5267 intiter != SplitPoints.end(); ++intiter){
5269 SLiter = SplitLength.find(intiter->first);
5271 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5273 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5274 PropertyName = PropertyElement.GetNextToken();
5275 PropertyValue = PropertyElement.GetNextToken();
5277 intPrevValue = intiter->second;
5279 // Process properties.
5281 size_t intPropertyValueLen = PropertyValue.Len();
5283 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5285 PropertyValue.Trim();
5286 PropertyValue.RemoveLast();
5290 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5292 PropertyValue.Remove(0, 1);
5296 CaptureString(&PropertyValue, FALSE);
5298 if (PropertyName == wxT("ALTID")){
5300 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5301 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5303 } else if (PropertyName == wxT("PID")){
5305 FreeBusyListPID.erase(*FreeBusyAddressCount);
5306 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5308 } else if (PropertyName == wxT("PREF")){
5310 int PriorityNumber = 0;
5311 bool ValidNumber = TRUE;
5314 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5317 catch(std::invalid_argument &e){
5318 ValidNumber = FALSE;
5321 if (ValidNumber == TRUE){
5323 FreeBusyListPref.erase(*FreeBusyAddressCount);
5324 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5328 } else if (PropertyName == wxT("MEDIATYPE")){
5330 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5331 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5335 // Something else we don't know about so append
5336 // to the tokens variable.
5338 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5340 if (FirstToken == TRUE){
5342 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5347 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5357 intPropertyLen = PropertySeg2.Len();
5358 SplitPoints.clear();
5359 SplitLength.clear();
5364 CaptureString(&PropertySeg2, FALSE);
5366 // Add the data to the General/Home/Work address variables.
5372 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5375 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5379 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5381 if (!PropertyTokens.IsEmpty()){
5383 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5389 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5391 size_t intPropertyLen = PropertySeg1.Len();
5392 std::map<int, int> SplitPoints;
5393 std::map<int, int> SplitLength;
5394 std::map<int, int>::iterator SLiter;
5395 wxString PropertyData;
5396 wxString PropertyName;
5397 wxString PropertyValue;
5398 wxString PropertyTokens;
5399 bool FirstToken = TRUE;
5400 int intSplitsFound = 0;
5401 int intSplitSize = 0;
5402 int intPrevValue = 5;
5407 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5411 PropertyType PropType = PROPERTY_NONE;
5413 // Look for type before continuing.
5415 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5419 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5420 intiter != SplitPoints.end(); ++intiter){
5422 SLiter = SplitLength.find(intiter->first);
5424 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5426 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5427 PropertyName = PropertyElement.GetNextToken();
5428 PropertyValue = PropertyElement.GetNextToken();
5430 intPrevValue = intiter->second;
5432 // Process properties.
5434 size_t intPropertyValueLen = PropertyValue.Len();
5436 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5438 PropertyValue.Trim();
5439 PropertyValue.RemoveLast();
5443 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5445 PropertyValue.Remove(0, 1);
5449 if (PropertyName == wxT("ALTID")){
5451 KeyListAltID.erase(*KeyCount);
5452 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5454 } else if (PropertyName == wxT("PID")){
5456 KeyListPID.erase(*KeyCount);
5457 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5459 } else if (PropertyName == wxT("PREF")){
5461 int PriorityNumber = 0;
5462 bool ValidNumber = TRUE;
5465 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5468 catch(std::invalid_argument &e){
5469 ValidNumber = FALSE;
5472 if (ValidNumber == TRUE){
5474 KeyListPref.erase(*KeyCount);
5475 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5481 // Something else we don't know about so append
5482 // to the tokens variable.
5484 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5486 if (FirstToken == TRUE){
5488 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5493 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5503 intPropertyLen = PropertySeg2.Len();
5504 SplitPoints.clear();
5505 SplitLength.clear();
5510 for (int i = 0; i <= intPropertyLen; i++){
5514 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5517 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5519 if (intSplitsFound == 6){
5521 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5526 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5537 wxString wxSKeyMIME;
5538 wxString wxSKeyEncoding;
5539 wxString wxSKeyData;
5540 std::string base64enc;
5542 if (intSplitsFound == 0){
5546 std::map<int, int>::iterator striter;
5548 striter = SplitLength.find(1);
5550 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5552 while (wSTDataType.HasMoreTokens() == TRUE){
5554 wxSKeyURI = wSTDataType.GetNextToken();
5555 wxSKeyMIME = wSTDataType.GetNextToken();
5560 if (wxSKeyURI == wxT("data")){
5562 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5564 while (wSTDataInfo.HasMoreTokens() == TRUE){
5566 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5567 wxSKeyData = wSTDataInfo.GetNextToken();
5576 // Add the data to the General/Home/Work address variables.
5578 if (wxSKeyURI == wxT("data")){
5580 KeyListDataEncType.erase(*KeyCount);
5581 KeyListKeyType.erase(*KeyCount);
5582 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5583 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5585 KeyList.erase(*KeyCount);
5586 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5590 KeyList.erase(*KeyCount);
5591 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5595 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5601 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5604 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5608 if (!PropertyTokens.IsEmpty()){
5610 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5616 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5618 // Split the Vendor three ways.
5620 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5623 wxString wxSVNDPropName;
5626 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5628 wSTVendorDetails.GetNextToken();
5629 wxSVNDID = wSTVendorDetails.GetNextToken();
5630 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5635 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5637 // Add the data to the vendor variables.
5639 VendorList.erase(*VendorCount);
5640 VendorListPEN.erase(*VendorCount);
5641 VendorListElement.erase(*VendorCount);
5643 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5644 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5645 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5651 void SplitValues(wxString *PropertyLine,
5652 std::map<int,int> *SplitPoints,
5653 std::map<int,int> *SplitLength,
5656 size_t intPropertyLen = PropertyLine->Len();
5657 int intSplitsFound = 0;
5658 int intSplitSize = 0;
5659 int intSplitSeek = 0;
5661 for (int i = intSize; i <= intPropertyLen; i++){
5665 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5666 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5668 if (intSplitsFound == 0){
5670 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5674 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5678 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5688 if (intSplitsFound == 0){
5690 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5691 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5695 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5696 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5702 void CheckType(wxString *PropertySeg1,
5703 std::map<int,int> *SplitPoints,
5704 std::map<int,int> *SplitLength,
5706 PropertyType *PropType){
5708 wxString PropertyData;
5709 wxString PropertyName;
5710 wxString PropertyValue;
5711 std::map<int,int>::iterator SLiter;
5713 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5714 intiter != SplitPoints->end(); ++intiter){
5716 SLiter = SplitLength->find(intiter->first);
5718 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5720 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5721 PropertyName = PropertyElement.GetNextToken();
5722 PropertyValue = PropertyElement.GetNextToken();
5724 *intPrevValue = intiter->second;
5726 if (PropertyName == wxT("TYPE")){
5728 if (PropertyValue == wxT("work")){
5730 *PropType = PROPERTY_WORK;
5732 } else if (PropertyValue == wxT("home")){
5734 *PropType = PROPERTY_HOME;
5738 *PropType = PROPERTY_NONE;