1 // ContactDataObject.cpp - Client Data Object.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 int ContactLineLen = 0;
82 int QuoteBreakPoint = 0;
85 int NicknameCount = 0;
86 int TimeZoneCount = 0;
90 int TelephoneCount = 0;
91 int LanguageCount = 0;
92 int GeographicCount = 0;
97 int OrganisationCount = 0;
99 int CategoryCount = 0;
104 wxString ContactLine;
105 wxString PropertyLine;
106 wxString PropertySeg1;
107 wxString PropertySeg2;
108 wxString PropertyNextLine;
111 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
112 iter != ContactFileLines.end(); ++iter){
114 ExtraLineSeek = TRUE;
120 PropertyLine.Clear();
121 PropertySeg1.Clear();
122 PropertySeg2.Clear();
125 ContactLine = iter->second;
127 while (ExtraLineSeek == TRUE){
129 // Check if there is extra data on the next line
130 // (indicated by space or tab at the start) and add data.
134 if (iter == ContactFileLines.end()){
141 PropertyNextLine = iter->second;
143 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
145 PropertyNextLine.Remove(0, 1);
146 ContactLine.Append(PropertyNextLine);
151 ExtraLineSeek = FALSE;
157 ContactLineLen = ContactLine.Len();
159 // Make sure we are not in quotation mode.
160 // Make sure colon does not have \ or \\ before it.
162 for (int i = 0; i <= ContactLineLen; i++){
164 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
166 PropertyFind = FALSE;
168 } else if (PropertyFind == TRUE){
170 Property.Append(ContactLine.Mid(i, 1));
174 if (ContactLine.Mid(i, 1) == wxT("\"")){
176 if (QuoteMode == TRUE){
188 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
197 // Split that line at the point into two variables (ignore the colon).
199 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
200 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
202 if (Property == wxT("KIND") && KindProcessed == FALSE){
204 ProcessKind(PropertySeg2);
206 } else if (Property == wxT("MEMBER")){
208 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
211 } else if (Property == wxT("FN")){
213 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
216 } else if (Property == wxT("N") && NameProcessed == FALSE){
218 ProcessN(PropertySeg1, PropertySeg2);
219 NameProcessed = TRUE;
221 } else if (Property == wxT("NICKNAME")){
223 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
226 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
228 ProcessGender(PropertySeg1, PropertySeg2);
229 GenderProcessed = TRUE;
231 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
233 ProcessBirthday(PropertySeg1, PropertySeg2);
234 BirthdayProcessed = TRUE;
236 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
238 ProcessAnniversary(PropertySeg1, PropertySeg2);
239 AnniversaryProcessed = TRUE;
241 } else if (Property == wxT("TZ")){
243 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
246 } else if (Property == wxT("ADR")){
248 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
251 } else if (Property == wxT("EMAIL")){
253 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
256 } else if (Property == wxT("IMPP")){
258 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
261 } else if (Property == wxT("TEL")){
263 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
266 } else if (Property == wxT("LANG")){
268 // See frmContactEditor-LoadLanguage.cpp
270 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
273 } else if (Property == wxT("GEO")){
275 // See frmContactEditor-LoadGeo.cpp
277 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
280 } else if (Property == wxT("RELATED")){
282 // See fromContactEditor-LoadRelated.cpp
284 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
287 } else if (Property == wxT("URL")){
289 // See frmContactEditor-LoadURL.cpp
291 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
294 } else if (Property == wxT("TITLE")) {
296 // See frmContactEditor-LoadTitle.cpp
298 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
301 } else if (Property == wxT("ROLE")) {
303 // See frmContactEditor-LoadTitle.cpp
305 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
308 } else if (Property == wxT("ORG")) {
310 // See frmContactEditor-LoadOrg.cpp
312 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
315 } else if (Property == wxT("NOTE")) {
317 // See frmContactEditor-LoadNote.cpp
319 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
322 } else if (Property == wxT("CATEGORIES")) {
324 // See frmContactEditor-LoadCategory.cpp
326 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
329 } else if (Property == wxT("PHOTO")) {
331 // See frmContactEditor-LoadPhoto.cpp
333 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
336 } else if (Property == wxT("LOGO")) {
338 // See frmContactEditor-LoadPhoto.cpp
340 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
343 } else if (Property == wxT("LOGO")) {
345 // See frmContactEditor-LoadPhoto.cpp
347 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
350 } else if (Property == wxT("SOUND")) {
352 // See frmContactEditor-LoadSound.cpp
354 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
357 } else if (Property == wxT("CALURI")){
359 // See frmContactEditor-LoadCalendar.cpp
361 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalAdrCount);
368 return CONTACTLOAD_OK;
372 void ContactDataObject::ProcessKind(wxString KindType){
374 if (KindType == wxT("individual")){
376 ContactKind = CONTACTKIND_INDIVIDUAL;
378 } else if (KindType == wxT("group")){
380 ContactKind = CONTACTKIND_GROUP;
382 } else if (KindType == wxT("org")){
384 ContactKind = CONTACTKIND_ORGANISATION;
386 } else if (KindType == wxT("location")){
388 ContactKind = CONTACTKIND_LOCATION;
392 ContactKind = CONTACTKIND_NONE;
397 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
399 std::map<int, int> SplitPoints;
400 std::map<int, int> SplitLength;
402 int intPrevValue = 8;
406 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
410 wxString PropertyName;
411 wxString PropertyValue;
412 wxString PropertyData;
413 wxString PropertyTokens;
414 std::map<int,int>::iterator SLiter;
415 bool FirstToken = TRUE;
417 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
418 intiter != SplitPoints.end(); ++intiter){
420 SLiter = SplitLength.find(intiter->first);
422 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
424 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
425 PropertyName = PropertyElement.GetNextToken();
426 PropertyValue = PropertyElement.GetNextToken();
428 intPrevValue = intiter->second;
430 CaptureString(&PropertyValue, FALSE);
432 if (PropertyName == wxT("ALTID")){
434 GroupsListAltID.erase(*GroupCount);
435 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
437 } else if (PropertyName == wxT("PID")){
439 GroupsListPID.erase(*GroupCount);
440 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
442 } else if (PropertyName == wxT("PREF")){
444 int PriorityNumber = 0;
445 bool ValidNumber = TRUE;
448 PriorityNumber = std::stoi(PropertyValue.ToStdString());
451 catch(std::invalid_argument &e){
455 if (ValidNumber == TRUE){
457 GroupsListPref.erase(*GroupCount);
458 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
462 } else if (PropertyName == wxT("MEDIATYPE")){
464 GroupsListMediaType.erase(*GroupCount);
465 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
467 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
469 if (FirstToken == TRUE){
471 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
476 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
484 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
486 if (!PropertyTokens.IsEmpty()){
488 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
495 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
497 std::map<int, int> SplitPoints;
498 std::map<int, int> SplitLength;
500 int intPrevValue = 4;
504 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
508 wxString PropertyName;
509 wxString PropertyValue;
510 wxString PropertyData;
511 wxString PropertyTokens;
512 std::map<int,int>::iterator SLiter;
513 bool FirstToken = TRUE;
515 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
516 intiter != SplitPoints.end(); ++intiter){
518 SLiter = SplitLength.find(intiter->first);
520 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
522 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
523 PropertyName = PropertyElement.GetNextToken();
524 PropertyValue = PropertyElement.GetNextToken();
526 intPrevValue = intiter->second;
528 CaptureString(&PropertyValue, FALSE);
530 if (PropertyName == wxT("TYPE")){
532 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
533 PropertyValue == wxT("work") ){
535 FullNamesListType.erase(*FNCount);
536 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
540 } else if (PropertyName == wxT("LANGUAGE")){
542 FullNamesListLanguage.erase(*FNCount);
543 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
545 } else if (PropertyName == wxT("ALTID")){
547 FullNamesListAltID.erase(*FNCount);
548 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
550 } else if (PropertyName == wxT("PID")){
552 FullNamesListPID.erase(*FNCount);
553 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
555 } else if (PropertyName == wxT("PREF")){
557 int PriorityNumber = 0;
558 bool ValidNumber = TRUE;
561 PriorityNumber = std::stoi(PropertyValue.ToStdString());
564 catch(std::invalid_argument &e){
568 if (ValidNumber == TRUE){
570 FullNamesListPref.erase(*FNCount);
571 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
575 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
577 if (FirstToken == TRUE){
579 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
584 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
592 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
594 if (!PropertyTokens.IsEmpty()){
596 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
602 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
604 std::map<int, int> SplitPoints;
605 std::map<int, int> SplitLength;
607 int intPrevValue = 3;
611 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
615 wxString PropertyName;
616 wxString PropertyValue;
617 wxString PropertyData;
618 wxString PropertyTokens;
619 std::map<int,int>::iterator SLiter;
620 bool FirstToken = TRUE;
622 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
623 intiter != SplitPoints.end(); ++intiter){
625 SLiter = SplitLength.find(intiter->first);
627 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
629 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
630 PropertyName = PropertyElement.GetNextToken();
631 PropertyValue = PropertyElement.GetNextToken();
633 intPrevValue = intiter->second;
635 CaptureString(&PropertyValue, FALSE);
637 if (PropertyName == wxT("ALTID")){
639 NameAltID = PropertyValue;
641 } else if (PropertyName == wxT("LANGUAGE")){
643 NameLanguage = PropertyValue;
645 } else if (PropertyName == wxT("SORT-AS")){
647 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
648 PropertyValue.Len() >= 3){
649 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
652 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
654 if (FirstToken == TRUE){
656 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
661 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
669 // Split the name data.
671 int intSplitSeek = 0;
672 int intSplitsFound = 0;
673 int intSplitSize = 0;
674 int intPropertyLen = PropertySeg2.Len();
676 std::map<int,wxString> NameValues;
679 for (int i = 0; i <= intPropertyLen; i++){
681 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
683 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
688 if (intSplitsFound == 4){
690 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
704 // Split the data into several parts.
706 for (std::map<int, wxString>::iterator iter = NameValues.begin();
707 iter != NameValues.end(); ++iter){
709 if (iter->first == 1){
711 // Deal with family name.
713 NameSurname = iter->second;
715 } else if (iter->first == 2){
717 // Deal with given names.
719 NameForename = iter->second;
721 } else if (iter->first == 3){
723 // Deal with additional names.
725 NameOtherNames = iter->second;
727 } else if (iter->first == 4){
729 // Deal with honorifix prefixes and suffixes.
731 NameTitle = iter->second;
735 if (iter == NameValues.end()){
741 NameSuffix = iter->second;
747 // Add the name token data.
749 if (!PropertyTokens.IsEmpty()){
751 NameTokens = PropertyTokens;
757 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
759 std::map<int, int> SplitPoints;
760 std::map<int, int> SplitLength;
762 int intPrevValue = 10;
765 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
769 PropertyType PropType = PROPERTY_NONE;
771 // Look for type before continuing.
773 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
777 std::map<int, wxString> *NicknamesList = NULL;
778 std::map<int, wxString> *NicknamesListType = NULL;
779 std::map<int, wxString> *NicknamesListLanguage = NULL;
780 std::map<int, wxString> *NicknamesListAltID = NULL;
781 std::map<int, wxString> *NicknamesListPID = NULL;
782 std::map<int, wxString> *NicknamesListTokens = NULL;
783 std::map<int, int> *NicknamesListPref = NULL;
787 NicknamesList = &GeneralNicknamesList;
788 NicknamesListType = &GeneralNicknamesListType;
789 NicknamesListLanguage = &GeneralNicknamesListLanguage;
790 NicknamesListAltID = &GeneralNicknamesListAltID;
791 NicknamesListPID = &GeneralNicknamesListPID;
792 NicknamesListTokens = &GeneralNicknamesListTokens;
793 NicknamesListPref = &GeneralNicknamesListPref;
796 NicknamesList = &HomeNicknamesList;
797 NicknamesListType = &HomeNicknamesListType;
798 NicknamesListLanguage = &HomeNicknamesListLanguage;
799 NicknamesListAltID = &HomeNicknamesListAltID;
800 NicknamesListPID = &HomeNicknamesListPID;
801 NicknamesListTokens = &HomeNicknamesListTokens;
802 NicknamesListPref = &HomeNicknamesListPref;
805 NicknamesList = &BusinessNicknamesList;
806 NicknamesListType = &BusinessNicknamesListType;
807 NicknamesListLanguage = &BusinessNicknamesListLanguage;
808 NicknamesListAltID = &BusinessNicknamesListAltID;
809 NicknamesListPID = &BusinessNicknamesListPID;
810 NicknamesListTokens = &BusinessNicknamesListTokens;
811 NicknamesListPref = &BusinessNicknamesListPref;
815 std::map<int, int>::iterator SLiter;
816 wxString PropertyData;
817 wxString PropertyName;
818 wxString PropertyValue;
819 wxString PropertyTokens;
820 bool FirstToken = TRUE;
822 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
823 intiter != SplitPoints.end(); ++intiter){
825 SLiter = SplitLength.find(intiter->first);
827 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
829 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
830 PropertyName = PropertyElement.GetNextToken();
831 PropertyValue = PropertyElement.GetNextToken();
833 intPrevValue = intiter->second;
835 CaptureString(&PropertyValue, FALSE);
837 if (PropertyName == wxT("ALTID")){
839 NicknamesListAltID->erase(*NicknameCount);
840 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
842 } else if (PropertyName == wxT("PID")){
844 NicknamesListPID->erase(*NicknameCount);
845 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
847 } else if (PropertyName == wxT("PREF")){
849 int PriorityNumber = 0;
850 bool ValidNumber = TRUE;
853 PriorityNumber = std::stoi(PropertyValue.ToStdString());
856 catch(std::invalid_argument &e){
860 if (ValidNumber == TRUE){
862 NicknamesListPref->erase(*NicknameCount);
863 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
867 } else if (PropertyName == wxT("LANGUAGE")){
869 NicknamesListLanguage->erase(*NicknameCount);
870 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
874 // Something else we don't know about so append
875 // to the tokens variable.
877 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
879 if (FirstToken == TRUE){
881 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
886 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
896 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
898 // Add the name token data.
900 if (!PropertyTokens.IsEmpty()){
902 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
908 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
910 std::map<int, int> SplitPoints;
911 std::map<int, int> SplitLength;
912 std::map<int, int>::iterator SLiter;
913 wxString PropertyData;
914 wxString PropertyName;
915 wxString PropertyValue;
916 wxString PropertyTokens;
917 bool FirstToken = TRUE;
918 int intPrevValue = 8;
920 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
924 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
925 intiter != SplitPoints.end(); ++intiter){
927 SLiter = SplitLength.find(intiter->first);
929 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
931 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
932 PropertyName = PropertyElement.GetNextToken();
933 PropertyValue = PropertyElement.GetNextToken();
935 intPrevValue = intiter->second;
937 // Process properties.
939 size_t intPropertyValueLen = PropertyValue.Len();
941 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
943 PropertyValue.Trim();
944 PropertyValue.RemoveLast();
948 if (PropertyValue.Mid(0, 1) == wxT("\"")){
950 PropertyValue.Remove(0, 1);
954 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
956 if (FirstToken == TRUE){
958 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
963 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
971 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
973 wxString GenderComponent;
975 if (GenderData.CountTokens() >= 2){
977 Gender = GenderData.GetNextToken();
978 GenderDetails = GenderData.GetString();
980 CaptureString(&GenderDetails, FALSE);
984 Gender = GenderData.GetNextToken();
988 if (!PropertyTokens.IsEmpty()){
990 GenderTokens = PropertyTokens;
996 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
998 // Process date. Preserve the remainder in the string.
1000 std::map<int, int> SplitPoints;
1001 std::map<int, int> SplitLength;
1002 std::map<int, int>::iterator SLiter;
1003 wxString PropertyData;
1004 wxString PropertyName;
1005 wxString PropertyValue;
1006 wxString PropertyTokens;
1007 bool BirthdayText = FALSE;
1008 int intPrevValue = 6;
1010 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1014 // Look for type before continuing.
1016 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1017 intiter != SplitPoints.end(); ++intiter){
1019 SLiter = SplitLength.find(intiter->first);
1021 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1023 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1024 PropertyName = PropertyElement.GetNextToken();
1025 PropertyValue = PropertyElement.GetNextToken();
1027 intPrevValue = intiter->second;
1029 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1031 CaptureString(&PropertySeg2, FALSE);
1032 Birthday = PropertySeg2;
1033 BirthdayText = TRUE;
1039 // Setup blank lines for later on.
1042 bool FirstToken = TRUE;
1044 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1045 intiter != SplitPoints.end(); ++intiter){
1047 SLiter = SplitLength.find(intiter->first);
1049 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1051 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1052 PropertyName = PropertyElement.GetNextToken();
1053 PropertyValue = PropertyElement.GetNextToken();
1055 intPrevValue = intiter->second;
1057 // Process properties.
1059 CaptureString(&PropertyValue, FALSE);
1061 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1063 PropertyValue.Trim();
1064 PropertyValue.RemoveLast();
1068 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1070 PropertyValue.Remove(0, 1);
1074 if (PropertyName == wxT("ALTID")){
1076 BirthdayAltID = PropertyValue;
1078 } else if (PropertyName == wxT("CALSCALE")){
1080 BirthdayCalScale = PropertyValue;
1082 } else if (PropertyName != wxT("VALUE")) {
1084 // Something else we don't know about so append
1085 // to the tokens variable.
1087 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1089 if (FirstToken == TRUE){
1091 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1096 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1106 // Add the data to the variables and form.
1108 if (BirthdayText == FALSE){
1110 Birthday = PropertySeg2;
1114 if (!PropertyTokens.IsEmpty()){
1116 BirthdayTokens = PropertyTokens;
1122 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1124 // Process date. Preserve the remainder in the string.
1126 std::map<int, int> SplitPoints;
1127 std::map<int, int> SplitLength;
1128 std::map<int, int>::iterator SLiter;
1129 wxString PropertyData;
1130 wxString PropertyName;
1131 wxString PropertyValue;
1132 wxString PropertyTokens;
1133 bool AnniversaryText = FALSE;
1134 int intPrevValue = 13;
1136 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1140 // Look for type before continuing.
1142 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1143 intiter != SplitPoints.end(); ++intiter){
1145 SLiter = SplitLength.find(intiter->first);
1147 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1149 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1150 PropertyName = PropertyElement.GetNextToken();
1151 PropertyValue = PropertyElement.GetNextToken();
1153 intPrevValue = intiter->second;
1155 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1157 CaptureString(&PropertySeg2, FALSE);
1158 Anniversary = PropertySeg2;
1159 AnniversaryText = TRUE;
1165 // Setup blank lines for later on.
1168 bool FirstToken = TRUE;
1170 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1171 intiter != SplitPoints.end(); ++intiter){
1173 SLiter = SplitLength.find(intiter->first);
1175 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1177 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1178 PropertyName = PropertyElement.GetNextToken();
1179 PropertyValue = PropertyElement.GetNextToken();
1181 intPrevValue = intiter->second;
1183 // Process properties.
1185 CaptureString(&PropertyValue, FALSE);
1187 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1189 PropertyValue.Trim();
1190 PropertyValue.RemoveLast();
1194 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1196 PropertyValue.Remove(0, 1);
1200 if (PropertyName == wxT("ALTID")){
1202 AnniversaryAltID = PropertyValue;
1204 } else if (PropertyName == wxT("CALSCALE")){
1206 AnniversaryCalScale = PropertyValue;
1208 } else if (PropertyName != wxT("VALUE")) {
1210 // Something else we don't know about so append
1211 // to the tokens variable.
1213 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1215 if (FirstToken == TRUE){
1217 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1222 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1232 // Add the data to the variables and form.
1234 if (AnniversaryText == FALSE){
1236 Anniversary = PropertySeg2;
1240 if (!PropertyTokens.IsEmpty()){
1242 AnniversaryTokens = PropertyTokens;
1248 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1250 std::map<int, int> SplitPoints;
1251 std::map<int, int> SplitLength;
1253 int intPrevValue = 4;
1256 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1260 PropertyType PropType = PROPERTY_NONE;
1262 // Look for type before continuing.
1264 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1268 std::map<int, wxString> *TZList = NULL;
1269 std::map<int, wxString> *TZListType = NULL;
1270 std::map<int, wxString> *TZListMediatype = NULL;
1271 std::map<int, wxString> *TZListAltID = NULL;
1272 std::map<int, wxString> *TZListPID = NULL;
1273 std::map<int, wxString> *TZListTokens = NULL;
1274 std::map<int, int> *TZListPref = NULL;
1278 TZList = &GeneralTZList;
1279 TZListType = &GeneralTZListType;
1280 TZListMediatype = &GeneralTZListMediatype;
1281 TZListAltID = &GeneralTZListAltID;
1282 TZListPID = &GeneralTZListPID;
1283 TZListTokens = &GeneralTZListTokens;
1284 TZListPref = &GeneralTZListPref;
1287 TZList = &HomeTZList;
1288 TZListType = &HomeTZListType;
1289 TZListMediatype = &HomeTZListMediatype;
1290 TZListAltID = &HomeTZListAltID;
1291 TZListPID = &HomeTZListPID;
1292 TZListTokens = &HomeTZListTokens;
1293 TZListPref = &HomeTZListPref;
1296 TZList = &BusinessTZList;
1297 TZListType = &BusinessTZListType;
1298 TZListMediatype = &BusinessTZListMediatype;
1299 TZListAltID = &BusinessTZListAltID;
1300 TZListPID = &BusinessTZListPID;
1301 TZListTokens = &BusinessTZListTokens;
1302 TZListPref = &BusinessTZListPref;
1306 std::map<int, int>::iterator SLiter;
1307 wxString PropertyData;
1308 wxString PropertyName;
1309 wxString PropertyValue;
1310 wxString PropertyTokens;
1311 bool FirstToken = TRUE;
1313 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1314 intiter != SplitPoints.end(); ++intiter){
1316 SLiter = SplitLength.find(intiter->first);
1318 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1320 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1321 PropertyName = PropertyElement.GetNextToken();
1322 PropertyValue = PropertyElement.GetNextToken();
1324 intPrevValue = intiter->second;
1326 CaptureString(&PropertyValue, FALSE);
1328 if (PropertyName == wxT("ALTID")){
1330 TZListAltID->erase(*TimeZoneCount);
1331 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1333 } else if (PropertyName == wxT("PID")){
1335 TZListPID->erase(*TimeZoneCount);
1336 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1338 } else if (PropertyName == wxT("PREF")){
1340 int PriorityNumber = 0;
1341 bool ValidNumber = TRUE;
1344 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1347 catch(std::invalid_argument &e){
1348 ValidNumber = FALSE;
1351 if (ValidNumber == TRUE){
1353 TZListPref->erase(*TimeZoneCount);
1354 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1358 } else if (PropertyName == wxT("MEDIATYPE")){
1360 TZListMediatype->erase(*TimeZoneCount);
1361 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1365 // Something else we don't know about so append
1366 // to the tokens variable.
1368 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1370 if (FirstToken == TRUE){
1372 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1377 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1387 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1389 // Add the name token data.
1391 if (!PropertyTokens.IsEmpty()){
1393 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1400 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1402 size_t intPropertyLen = PropertySeg1.Len();
1403 std::map<int, int> SplitPoints;
1404 std::map<int, int> SplitLength;
1405 std::map<int, int>::iterator SLiter;
1406 wxString PropertyData;
1407 wxString PropertyName;
1408 wxString PropertyValue;
1409 wxString PropertyTokens;
1410 wxString AddressLabel;
1411 wxString AddressLang;
1412 wxString AddressAltID;
1413 wxString AddressPID;
1414 wxString AddressTokens;
1415 wxString AddressGeo;
1416 wxString AddressTimezone;
1417 wxString AddressType;
1418 wxString AddressMediatype;
1419 wxString AddressPOBox;
1420 wxString AddressExtended;
1421 wxString AddressStreet;
1422 wxString AddressLocality;
1423 wxString AddressCity;
1424 wxString AddressRegion;
1425 wxString AddressPostalCode;
1426 wxString AddressCountry;
1427 bool FirstToken = TRUE;
1428 int intSplitsFound = 0;
1429 int intSplitSize = 0;
1430 int intPrevValue = 5;
1435 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1439 PropertyType PropType = PROPERTY_NONE;
1441 // Look for type before continuing.
1443 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1447 std::map<int, wxString> *AddressList = NULL;
1448 std::map<int, wxString> *AddressListTown = NULL;
1449 std::map<int, wxString> *AddressListCounty = NULL;
1450 std::map<int, wxString> *AddressListPostCode = NULL;
1451 std::map<int, wxString> *AddressListCountry = NULL;
1452 std::map<int, wxString> *AddressListLabel = NULL;
1453 std::map<int, wxString> *AddressListLang = NULL;
1454 std::map<int, wxString> *AddressListAltID = NULL;
1455 std::map<int, wxString> *AddressListPID = NULL;
1456 std::map<int, wxString> *AddressListTokens = NULL;
1457 std::map<int, wxString> *AddressListGeo = NULL;
1458 std::map<int, wxString> *AddressListTimezone = NULL;
1459 std::map<int, wxString> *AddressListType = NULL;
1460 std::map<int, wxString> *AddressListMediatype = NULL;
1461 std::map<int, int> *AddressListPref = NULL;
1465 AddressList = &GeneralAddressList;
1466 AddressListTown = &GeneralAddressListTown;
1467 AddressListCounty = &GeneralAddressListCounty;
1468 AddressListPostCode = &GeneralAddressListPostCode;
1469 AddressListCountry = &GeneralAddressListCountry;
1470 AddressListLabel = &GeneralAddressListLabel;
1471 AddressListLang = &GeneralAddressListLang;
1472 AddressListAltID = &GeneralAddressListAltID;
1473 AddressListPID = &GeneralAddressListPID;
1474 AddressListTokens = &GeneralAddressListTokens;
1475 AddressListGeo = &GeneralAddressListGeo;
1476 AddressListTimezone = &GeneralAddressListTimezone;
1477 AddressListType = &GeneralAddressListType;
1478 AddressListMediatype = &GeneralAddressListMediatype;
1479 AddressListPref = &GeneralAddressListPref;
1482 AddressList = &HomeAddressList;
1483 AddressListTown = &HomeAddressListTown;
1484 AddressListCounty = &HomeAddressListCounty;
1485 AddressListPostCode = &HomeAddressListPostCode;
1486 AddressListCountry = &HomeAddressListCountry;
1487 AddressListLabel = &HomeAddressListLabel;
1488 AddressListLang = &HomeAddressListLang;
1489 AddressListAltID = &HomeAddressListAltID;
1490 AddressListPID = &HomeAddressListPID;
1491 AddressListTokens = &HomeAddressListTokens;
1492 AddressListGeo = &HomeAddressListGeo;
1493 AddressListTimezone = &HomeAddressListTimezone;
1494 AddressListType = &HomeAddressListType;
1495 AddressListMediatype = &HomeAddressListMediatype;
1496 AddressListPref = &HomeAddressListPref;
1499 AddressList = &BusinessAddressList;
1500 AddressListTown = &BusinessAddressListTown;
1501 AddressListCounty = &BusinessAddressListCounty;
1502 AddressListPostCode = &BusinessAddressListPostCode;
1503 AddressListCountry = &BusinessAddressListCountry;
1504 AddressListLabel = &BusinessAddressListLabel;
1505 AddressListLang = &BusinessAddressListLang;
1506 AddressListAltID = &BusinessAddressListAltID;
1507 AddressListPID = &BusinessAddressListPID;
1508 AddressListTokens = &BusinessAddressListTokens;
1509 AddressListGeo = &BusinessAddressListGeo;
1510 AddressListTimezone = &BusinessAddressListTimezone;
1511 AddressListType = &BusinessAddressListType;
1512 AddressListMediatype = &BusinessAddressListMediatype;
1513 AddressListPref = &BusinessAddressListPref;
1519 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1520 intiter != SplitPoints.end(); ++intiter){
1522 SLiter = SplitLength.find(intiter->first);
1524 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1526 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1527 PropertyName = PropertyElement.GetNextToken();
1528 PropertyValue = PropertyElement.GetNextToken();
1530 intPrevValue = intiter->second;
1532 CaptureString(&PropertyValue, FALSE);
1534 // Process properties.
1536 if (PropertyName == wxT("LABEL")){
1538 AddressListLabel->erase(*AddressCount);
1539 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1541 } else if (PropertyName == wxT("LANGUAGE")){
1543 AddressListLang->erase(*AddressCount);
1544 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1546 } else if (PropertyName == wxT("ALTID")){
1548 AddressListAltID->erase(*AddressCount);
1549 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1551 } else if (PropertyName == wxT("PID")){
1553 AddressListPID->erase(*AddressCount);
1554 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1556 } else if (PropertyName == wxT("GEO")){
1558 AddressListGeo->erase(*AddressCount);
1559 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1561 } else if (PropertyName == wxT("TZ")){
1563 AddressListTimezone->erase(*AddressCount);
1564 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1566 } else if (PropertyName == wxT("MEDIATYPE")){
1568 AddressListMediatype->erase(*AddressCount);
1569 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1571 } else if (PropertyName == wxT("PREF")){
1573 int PriorityNumber = 0;
1574 bool ValidNumber = TRUE;
1577 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1580 catch(std::invalid_argument &e){
1581 ValidNumber = FALSE;
1584 if (ValidNumber == TRUE){
1586 AddressListPref->erase(*AddressCount);
1587 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1593 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1595 if (FirstToken == TRUE){
1597 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1602 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1612 // Split the address.
1614 //std::map<int, int>::iterator SLiter;
1615 intPropertyLen = PropertySeg2.Len();
1616 SplitPoints.clear();
1617 SplitLength.clear();
1622 for (int i = 0; i <= intPropertyLen; i++){
1626 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1629 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1631 if (intSplitsFound == 6){
1633 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1638 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1648 // Split the data into several parts.
1650 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1651 intiter != SplitPoints.end(); ++intiter){
1653 if (intiter->first == 1){
1655 // Deal with PO Box.
1657 SLiter = SplitLength.find(1);
1659 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1660 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1661 intPrevValue = intiter->second;
1663 } else if (intiter->first == 2){
1665 // Deal with extended address.
1667 SLiter = SplitLength.find(2);
1669 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1670 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1671 intPrevValue = intiter->second;
1673 } else if (intiter->first == 3){
1675 // Deal with street address.
1677 SLiter = SplitLength.find(3);
1679 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1680 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1681 intPrevValue = intiter->second;
1683 } else if (intiter->first == 4){
1685 // Deal with locality
1687 SLiter = SplitLength.find(4);
1689 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1690 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1691 intPrevValue = intiter->second;
1693 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1695 } else if (intiter->first == 5){
1697 // Deal with region.
1699 SLiter = SplitLength.find(5);
1701 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1702 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1703 intPrevValue = intiter->second;
1705 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1707 } else if (intiter->first == 6){
1709 // Deal with post code.
1711 SLiter = SplitLength.find(6);
1713 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1714 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1715 intPrevValue = intiter->second;
1717 // Deal with country.
1719 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1720 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1728 // Add the data to the General/Home/Work address variables.
1730 CaptureString(&AddressStreet, FALSE);
1731 CaptureString(&AddressLocality, FALSE);
1732 CaptureString(&AddressRegion, FALSE);
1733 CaptureString(&AddressPostalCode, FALSE);
1734 CaptureString(&AddressCountry, FALSE);
1736 if (!PropertyTokens.IsEmpty()){
1738 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1742 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1743 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1744 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1745 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1746 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1750 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1753 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1756 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1760 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1764 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1766 std::map<int, int> SplitPoints;
1767 std::map<int, int> SplitLength;
1769 int intPrevValue = 7;
1772 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1776 PropertyType PropType = PROPERTY_NONE;
1778 // Look for type before continuing.
1780 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1782 std::map<int, wxString> *EmailList = NULL;
1783 std::map<int, wxString> *EmailListType = NULL;
1784 std::map<int, wxString> *EmailListAltID = NULL;
1785 std::map<int, wxString> *EmailListPID = NULL;
1786 std::map<int, wxString> *EmailListTokens = NULL;
1787 std::map<int, int> *EmailListPref = NULL;
1791 EmailList = &GeneralEmailList;
1792 EmailListType = &GeneralEmailListType;
1793 EmailListAltID = &GeneralEmailListAltID;
1794 EmailListPID = &GeneralEmailListPID;
1795 EmailListTokens = &GeneralEmailListTokens;
1796 EmailListPref = &GeneralEmailListPref;
1799 EmailList = &HomeEmailList;
1800 EmailListType = &HomeEmailListType;
1801 EmailListAltID = &HomeEmailListAltID;
1802 EmailListPID = &HomeEmailListPID;
1803 EmailListTokens = &HomeEmailListTokens;
1804 EmailListPref = &HomeEmailListPref;
1807 EmailList = &BusinessEmailList;
1808 EmailListType = &BusinessEmailListType;
1809 EmailListAltID = &BusinessEmailListAltID;
1810 EmailListPID = &BusinessEmailListPID;
1811 EmailListTokens = &BusinessEmailListTokens;
1812 EmailListPref = &BusinessEmailListPref;
1818 std::map<int,int>::iterator SLiter;
1819 wxString PropertyData;
1820 wxString PropertyName;
1821 wxString PropertyValue;
1822 wxString PropertyTokens;
1823 bool FirstToken = TRUE;
1825 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1826 intiter != SplitPoints.end(); ++intiter){
1828 SLiter = SplitLength.find(intiter->first);
1830 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1832 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1833 PropertyName = PropertyElement.GetNextToken();
1834 PropertyValue = PropertyElement.GetNextToken();
1836 intPrevValue = intiter->second;
1838 CaptureString(&PropertyValue, FALSE);
1840 // Process properties.
1842 if (PropertyName == wxT("ALTID")){
1844 EmailListAltID->erase(*EmailCount);
1845 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1847 } else if (PropertyName == wxT("PID")){
1849 EmailListPID->erase(*EmailCount);
1850 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1852 } else if (PropertyName == wxT("PREF")){
1854 int PriorityNumber = 0;
1855 bool ValidNumber = TRUE;
1858 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1861 catch(std::invalid_argument &e){
1862 ValidNumber = FALSE;
1865 if (ValidNumber == TRUE){
1867 EmailListPref->erase(*EmailCount);
1868 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1874 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1876 if (FirstToken == TRUE){
1878 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1883 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1893 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1895 // Add the name token data.
1897 if (!PropertyTokens.IsEmpty()){
1899 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1906 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1908 std::map<int, int> SplitPoints;
1909 std::map<int, int> SplitLength;
1911 int intPrevValue = 6;
1914 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1918 PropertyType PropType = PROPERTY_NONE;
1920 // Look for type before continuing.
1922 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1924 std::map<int, wxString> *IMList = NULL;
1925 std::map<int, wxString> *IMListType = NULL;
1926 std::map<int, wxString> *IMListAltID = NULL;
1927 std::map<int, wxString> *IMListPID = NULL;
1928 std::map<int, wxString> *IMListTokens = NULL;
1929 std::map<int, wxString> *IMListMediatype = NULL;
1930 std::map<int, int> *IMListPref = NULL;
1934 IMList = &GeneralIMList;
1935 IMListType = &GeneralIMListType;
1936 IMListAltID = &GeneralIMListAltID;
1937 IMListPID = &GeneralIMListPID;
1938 IMListTokens = &GeneralIMListTokens;
1939 IMListMediatype = &GeneralIMListMediatype;
1940 IMListPref = &GeneralIMListPref;
1943 IMList = &HomeIMList;
1944 IMListType = &HomeIMListType;
1945 IMListAltID = &HomeIMListAltID;
1946 IMListPID = &HomeIMListPID;
1947 IMListTokens = &HomeIMListTokens;
1948 IMListMediatype = &HomeIMListMediatype;
1949 IMListPref = &HomeIMListPref;
1952 IMList = &BusinessIMList;
1953 IMListType = &BusinessIMListType;
1954 IMListAltID = &BusinessIMListAltID;
1955 IMListPID = &BusinessIMListPID;
1956 IMListTokens = &BusinessIMListTokens;
1957 IMListMediatype = &BusinessIMListMediatype;
1958 IMListPref = &BusinessIMListPref;
1964 std::map<int,int>::iterator SLiter;
1965 wxString PropertyData;
1966 wxString PropertyName;
1967 wxString PropertyValue;
1968 wxString PropertyTokens;
1969 bool FirstToken = TRUE;
1971 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1972 intiter != SplitPoints.end(); ++intiter){
1974 SLiter = SplitLength.find(intiter->first);
1976 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1978 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1979 PropertyName = PropertyElement.GetNextToken();
1980 PropertyValue = PropertyElement.GetNextToken();
1982 intPrevValue = intiter->second;
1984 CaptureString(&PropertyValue, FALSE);
1986 // Process properties.
1988 if (PropertyName == wxT("ALTID")){
1990 IMListAltID->erase(*IMCount);
1991 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1993 } else if (PropertyName == wxT("PID")){
1995 IMListPID->erase(*IMCount);
1996 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1998 } else if (PropertyName == wxT("MEDIATYPE")){
2000 IMListMediatype->erase(*IMCount);
2001 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2003 } else if (PropertyName == wxT("PREF")){
2005 int PriorityNumber = 0;
2006 bool ValidNumber = TRUE;
2009 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2012 catch(std::invalid_argument &e){
2013 ValidNumber = FALSE;
2016 if (ValidNumber == TRUE){
2018 IMListPref->erase(*IMCount);
2019 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2025 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2027 if (FirstToken == TRUE){
2029 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2034 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2044 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2046 // Add the name token data.
2048 if (!PropertyTokens.IsEmpty()){
2050 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2056 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2058 std::map<int, int> SplitPoints;
2059 std::map<int, int> SplitLength;
2060 std::map<int, int>::iterator SLiter;
2064 PropertyType PropType = PROPERTY_NONE;
2066 // Look for type before continuing.
2069 wxString TelTypeDetail;
2070 wxString PropertyData;
2071 wxString PropertyName;
2072 wxString PropertyValue;
2073 wxString PropertyTokens;
2075 std::map<int,int> TypeSplitPoints;
2076 std::map<int,int> TypeSplitLength;
2077 std::map<int,int>::iterator TSLiter;
2079 int intSplitSize = 0;
2080 int intSplitsFound = 0;
2081 int intSplitPoint = 0;
2083 int intPrevValue = 5;
2085 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2089 // Look for type before continuing.
2091 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2092 intiter != SplitPoints.end(); ++intiter){
2094 SLiter = SplitLength.find(intiter->first);
2096 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2098 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2099 PropertyName = PropertyElement.GetNextToken();
2100 PropertyValue = PropertyElement.GetNextToken();
2102 intPrevValue = intiter->second;
2104 if (PropertyName == wxT("TYPE")){
2106 // Process each value in type and translate each
2109 // Strip out the quotes if they are there.
2111 size_t intPropertyValueLen = PropertyValue.Len();
2113 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2115 PropertyValue.Trim();
2116 PropertyValue.RemoveLast();
2120 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2122 PropertyValue.Remove(0, 1);
2126 TelTypeDetail = PropertyValue;
2132 for (int i = 0; i <= intPropertyValueLen; i++){
2136 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2138 if (intSplitsFound == 0){
2140 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2141 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2145 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2146 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2159 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2160 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2162 int intTypeSeek = 0;
2164 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2165 typeiter != TypeSplitPoints.end(); ++typeiter){
2167 wxString TypePropertyName;
2169 TSLiter = TypeSplitLength.find(typeiter->first);
2171 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2173 if (intTypeSeek == 0){
2178 TelTypeUI.Append(wxT(","));
2182 if (TypePropertyName == wxT("home")){
2184 PropType = PROPERTY_HOME;
2186 } else if (TypePropertyName == wxT("work")){
2188 PropType = PROPERTY_WORK;
2193 if (TypePropertyName == wxT("text")){
2195 TelTypeUI.Append(_("text"));
2198 } else if (TypePropertyName == wxT("voice")){
2200 TelTypeUI.Append(_("voice"));
2203 } else if (TypePropertyName == wxT("fax")){
2205 TelTypeUI.Append(_("fax"));
2208 } else if (TypePropertyName == wxT("cell")){
2210 TelTypeUI.Append(_("mobile"));
2213 } else if (TypePropertyName == wxT("video")){
2215 TelTypeUI.Append(_("video"));
2218 } else if (TypePropertyName == wxT("pager")){
2220 TelTypeUI.Append(_("pager"));
2223 } else if (TypePropertyName == wxT("textphone")){
2225 TelTypeUI.Append(_("textphone"));
2236 std::map<int, wxString> *TelephoneList = NULL;
2237 std::map<int, wxString> *TelephoneListType = NULL;
2238 std::map<int, wxString> *TelephoneListAltID = NULL;
2239 std::map<int, wxString> *TelephoneListPID = NULL;
2240 std::map<int, wxString> *TelephoneListTokens = NULL;
2241 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2242 std::map<int, int> *TelephoneListPref = NULL;
2246 TelephoneList = &GeneralTelephoneList;
2247 TelephoneListType = &GeneralTelephoneListType;
2248 TelephoneListAltID = &GeneralTelephoneListAltID;
2249 TelephoneListPID = &GeneralTelephoneListPID;
2250 TelephoneListTokens = &GeneralTelephoneListTokens;
2251 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2252 TelephoneListPref = &GeneralTelephoneListPref;
2255 TelephoneList = &HomeTelephoneList;
2256 TelephoneListType = &HomeTelephoneListType;
2257 TelephoneListAltID = &HomeTelephoneListAltID;
2258 TelephoneListPID = &HomeTelephoneListPID;
2259 TelephoneListTokens = &HomeTelephoneListTokens;
2260 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2261 TelephoneListPref = &HomeTelephoneListPref;
2264 TelephoneList = &BusinessTelephoneList;
2265 TelephoneListType = &BusinessTelephoneListType;
2266 TelephoneListAltID = &BusinessTelephoneListAltID;
2267 TelephoneListPID = &BusinessTelephoneListPID;
2268 TelephoneListTokens = &BusinessTelephoneListTokens;
2269 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2270 TelephoneListPref = &BusinessTelephoneListPref;
2274 // Process the properties.
2276 bool FirstToken = TRUE;
2279 SplitPoints.clear();
2280 SplitLength.clear();
2282 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2286 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2287 intiter != SplitPoints.end(); ++intiter){
2289 SLiter = SplitLength.find(intiter->first);
2291 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2293 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2294 PropertyName = PropertyElement.GetNextToken();
2295 PropertyValue = PropertyElement.GetNextToken();
2297 intPrevValue = intiter->second;
2299 CaptureString(&PropertyValue, FALSE);
2301 // Process properties.
2303 if (PropertyName == wxT("ALTID")){
2305 TelephoneListAltID->erase(*TelephoneCount);
2306 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2308 } else if (PropertyName == wxT("PID")){
2310 TelephoneListPID->erase(*TelephoneCount);
2311 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2313 } else if (PropertyName == wxT("PREF")){
2315 int PriorityNumber = 0;
2316 bool ValidNumber = TRUE;
2319 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2322 catch(std::invalid_argument &e){
2323 ValidNumber = FALSE;
2326 if (ValidNumber == TRUE){
2328 TelephoneListPref->erase(*TelephoneCount);
2329 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2335 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2337 if (FirstToken == TRUE){
2339 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2344 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2354 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2355 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2357 // Add the name token data.
2359 if (!PropertyTokens.IsEmpty()){
2361 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2367 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2369 std::map<int, int> SplitPoints;
2370 std::map<int, int> SplitLength;
2372 int intPrevValue = 6;
2375 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2379 PropertyType PropType = PROPERTY_NONE;
2381 // Look for type before continuing.
2383 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2385 std::map<int, wxString> *LanguageList = NULL;
2386 std::map<int, wxString> *LanguageListType = NULL;
2387 std::map<int, wxString> *LanguageListAltID = NULL;
2388 std::map<int, wxString> *LanguageListPID = NULL;
2389 std::map<int, wxString> *LanguageListTokens = NULL;
2390 std::map<int, int> *LanguageListPref = NULL;
2394 LanguageList = &GeneralLanguageList;
2395 LanguageListType = &GeneralLanguageListType;
2396 LanguageListAltID = &GeneralLanguageListAltID;
2397 LanguageListPID = &GeneralLanguageListPID;
2398 LanguageListTokens = &GeneralLanguageListTokens;
2399 LanguageListPref = &GeneralLanguageListPref;
2402 LanguageList = &HomeLanguageList;
2403 LanguageListType = &HomeLanguageListType;
2404 LanguageListAltID = &HomeLanguageListAltID;
2405 LanguageListPID = &HomeLanguageListPID;
2406 LanguageListTokens = &HomeLanguageListTokens;
2407 LanguageListPref = &HomeLanguageListPref;
2410 LanguageList = &BusinessLanguageList;
2411 LanguageListType = &BusinessLanguageListType;
2412 LanguageListAltID = &BusinessLanguageListAltID;
2413 LanguageListPID = &BusinessLanguageListPID;
2414 LanguageListTokens = &BusinessLanguageListTokens;
2415 LanguageListPref = &BusinessLanguageListPref;
2421 std::map<int,int>::iterator SLiter;
2422 wxString PropertyData;
2423 wxString PropertyName;
2424 wxString PropertyValue;
2425 wxString PropertyTokens;
2426 bool FirstToken = TRUE;
2428 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2429 intiter != SplitPoints.end(); ++intiter){
2431 SLiter = SplitLength.find(intiter->first);
2433 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2435 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2436 PropertyName = PropertyElement.GetNextToken();
2437 PropertyValue = PropertyElement.GetNextToken();
2439 intPrevValue = intiter->second;
2441 CaptureString(&PropertyValue, FALSE);
2443 // Process properties.
2445 if (PropertyName == wxT("ALTID")){
2447 LanguageListAltID->erase(*LanguageCount);
2448 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2450 } else if (PropertyName == wxT("PID")){
2452 LanguageListPID->erase(*LanguageCount);
2453 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2455 } else if (PropertyName == wxT("PREF")){
2457 int PriorityNumber = 0;
2458 bool ValidNumber = TRUE;
2461 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2464 catch(std::invalid_argument &e){
2465 ValidNumber = FALSE;
2468 if (ValidNumber == TRUE){
2470 LanguageListPref->erase(*LanguageCount);
2471 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2477 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2479 if (FirstToken == TRUE){
2481 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2486 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2496 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2498 // Add the name token data.
2500 if (!PropertyTokens.IsEmpty()){
2502 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2508 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2510 std::map<int, int> SplitPoints;
2511 std::map<int, int> SplitLength;
2513 int intPrevValue = 5;
2516 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2520 PropertyType PropType = PROPERTY_NONE;
2522 // Look for type before continuing.
2524 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2526 std::map<int, wxString> *GeopositionList = NULL;
2527 std::map<int, wxString> *GeopositionListType = NULL;
2528 std::map<int, wxString> *GeopositionListAltID = NULL;
2529 std::map<int, wxString> *GeopositionListPID = NULL;
2530 std::map<int, wxString> *GeopositionListTokens = NULL;
2531 std::map<int, wxString> *GeopositionListMediatype = NULL;
2532 std::map<int, int> *GeopositionListPref = NULL;
2536 GeopositionList = &GeneralGeographyList;
2537 GeopositionListType = &GeneralGeographyListType;
2538 GeopositionListAltID = &GeneralGeographyListAltID;
2539 GeopositionListPID = &GeneralGeographyListPID;
2540 GeopositionListTokens = &GeneralGeographyListTokens;
2541 GeopositionListMediatype = &GeneralGeographyListMediatype;
2542 GeopositionListPref = &GeneralGeographyListPref;
2545 GeopositionList = &HomeGeographyList;
2546 GeopositionListType = &HomeGeographyListType;
2547 GeopositionListAltID = &HomeGeographyListAltID;
2548 GeopositionListPID = &HomeGeographyListPID;
2549 GeopositionListTokens = &HomeGeographyListTokens;
2550 GeopositionListMediatype = &HomeGeographyListMediatype;
2551 GeopositionListPref = &HomeGeographyListPref;
2554 GeopositionList = &BusinessGeographyList;
2555 GeopositionListType = &BusinessGeographyListType;
2556 GeopositionListAltID = &BusinessGeographyListAltID;
2557 GeopositionListPID = &BusinessGeographyListPID;
2558 GeopositionListTokens = &BusinessGeographyListTokens;
2559 GeopositionListMediatype = &BusinessGeographyListMediatype;
2560 GeopositionListPref = &BusinessGeographyListPref;
2566 std::map<int,int>::iterator SLiter;
2567 wxString PropertyData;
2568 wxString PropertyName;
2569 wxString PropertyValue;
2570 wxString PropertyTokens;
2571 bool FirstToken = TRUE;
2573 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2574 intiter != SplitPoints.end(); ++intiter){
2576 SLiter = SplitLength.find(intiter->first);
2578 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2580 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2581 PropertyName = PropertyElement.GetNextToken();
2582 PropertyValue = PropertyElement.GetNextToken();
2584 intPrevValue = intiter->second;
2586 CaptureString(&PropertyValue, FALSE);
2588 // Process properties.
2590 if (PropertyName == wxT("ALTID")){
2592 GeopositionListAltID->erase(*GeographicCount);
2593 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2595 } else if (PropertyName == wxT("PID")){
2597 GeopositionListPID->erase(*GeographicCount);
2598 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2600 } else if (PropertyName == wxT("MEDIATYPE")){
2602 GeopositionListMediatype->erase(*GeographicCount);
2603 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2605 } else if (PropertyName == wxT("PREF")){
2607 int PriorityNumber = 0;
2608 bool ValidNumber = TRUE;
2611 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2614 catch(std::invalid_argument &e){
2615 ValidNumber = FALSE;
2618 if (ValidNumber == TRUE){
2620 GeopositionListPref->erase(*GeographicCount);
2621 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2627 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2629 if (FirstToken == TRUE){
2631 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2636 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2646 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2648 // Add the name token data.
2650 if (!PropertyTokens.IsEmpty()){
2652 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2658 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2660 size_t intPropertyLen = PropertySeg1.Len();
2661 std::map<int, int> SplitPoints;
2662 std::map<int, int> SplitLength;
2663 std::map<int, int>::iterator SLiter;
2664 wxString PropertyData;
2665 wxString PropertyName;
2666 wxString PropertyValue;
2667 wxString PropertyTokens;
2668 wxString RelatedType;
2669 wxString RelatedTypeOriginal;
2670 wxString RelatedName;
2671 bool FirstToken = TRUE;
2672 int intSplitsFound = 0;
2673 int intSplitSize = 0;
2674 int intPrevValue = 9;
2678 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2682 // Look for type before continuing.
2684 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2685 intiter != SplitPoints.end(); ++intiter){
2687 SLiter = SplitLength.find(intiter->first);
2689 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2691 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2692 PropertyName = PropertyElement.GetNextToken();
2693 PropertyValue = PropertyElement.GetNextToken();
2695 intPrevValue = intiter->second;
2699 RelatedTypeOriginal = PropertyValue;
2701 if (PropertyName == wxT("TYPE")){
2703 if (PropertyValue == wxT("contact")){
2705 RelatedType = _("Contact");
2707 } else if (PropertyValue == wxT("acquaintance")){
2709 RelatedType = _("Acquaintance");
2711 } else if (PropertyValue == wxT("friend")){
2713 RelatedType = _("Friend");
2715 } else if (PropertyValue == wxT("met")){
2717 RelatedType = _("Met");
2719 } else if (PropertyValue == wxT("co-worker")){
2721 RelatedType = _("Co-worker");
2723 } else if (PropertyValue == wxT("colleague")){
2725 RelatedType = _("Colleague");
2727 } else if (PropertyValue == wxT("co-resident")){
2729 RelatedType = _("Co-resident");
2731 } else if (PropertyValue == wxT("neighbor")){
2733 RelatedType = _("Neighbour");
2735 } else if (PropertyValue == wxT("child")){
2737 RelatedType = _("Child");
2739 } else if (PropertyValue == wxT("parent")){
2741 RelatedType = _("Parent");
2743 } else if (PropertyValue == wxT("sibling")){
2745 RelatedType = _("Sibling");
2747 } else if (PropertyValue == wxT("spouse")){
2749 RelatedType = _("Spouse");
2751 } else if (PropertyValue == wxT("kin")){
2753 RelatedType = _("Kin");
2755 } else if (PropertyValue == wxT("muse")){
2757 RelatedType = _("Muse");
2759 } else if (PropertyValue == wxT("crush")){
2761 RelatedType = _("Crush");
2763 } else if (PropertyValue == wxT("date")){
2765 RelatedType = _("Date");
2767 } else if (PropertyValue == wxT("sweetheart")){
2769 RelatedType = _("Sweetheart");
2771 } else if (PropertyValue == wxT("me")){
2773 RelatedType = _("Me");
2775 } else if (PropertyValue == wxT("agent")){
2777 RelatedType = _("Agent");
2779 } else if (PropertyValue == wxT("emergency")){
2781 RelatedType = _("Emergency");
2785 RelatedType = PropertyValue;
2795 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2796 intiter != SplitPoints.end(); ++intiter){
2798 SLiter = SplitLength.find(intiter->first);
2800 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2802 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2803 PropertyName = PropertyElement.GetNextToken();
2804 PropertyValue = PropertyElement.GetNextToken();
2806 intPrevValue = intiter->second;
2808 // Process properties.
2810 size_t intPropertyValueLen = PropertyValue.Len();
2812 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2814 PropertyValue.Trim();
2815 PropertyValue.RemoveLast();
2819 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2821 PropertyValue.Remove(0, 1);
2825 CaptureString(&PropertyValue, FALSE);
2827 if (PropertyName == wxT("ALTID")){
2829 GeneralRelatedListAltID.erase(*RelatedCount);
2830 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2832 } else if (PropertyName == wxT("PID")){
2834 GeneralRelatedListPID.erase(*RelatedCount);
2835 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2837 } else if (PropertyName == wxT("PREF")){
2839 int PriorityNumber = 0;
2840 bool ValidNumber = TRUE;
2843 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2846 catch(std::invalid_argument &e){
2847 ValidNumber = FALSE;
2850 if (ValidNumber == TRUE){
2852 GeneralRelatedListPref.erase(*RelatedCount);
2853 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2857 } else if (PropertyName == wxT("LANGUAGE")){
2859 GeneralRelatedListLanguage.erase(*RelatedCount);
2860 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2862 } else if (PropertyName != wxT("TYPE")) {
2864 // Something else we don't know about so append
2865 // to the tokens variable.
2867 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2869 if (FirstToken == TRUE){
2871 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2876 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2886 // Add the data to the General/Home/Work address variables.
2888 GeneralRelatedList.erase(*RelatedCount);
2889 GeneralRelatedListRelType.erase(*RelatedCount);
2890 GeneralRelatedListType.erase(*RelatedCount);
2891 GeneralRelatedListTokens.erase(*RelatedCount);
2892 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2893 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2894 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2895 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2899 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2901 std::map<int, int> SplitPoints;
2902 std::map<int, int> SplitLength;
2903 std::map<int, int>::iterator SLiter;
2904 wxString PropertyData;
2905 wxString PropertyName;
2906 wxString PropertyValue;
2907 wxString PropertyTokens;
2908 bool FirstToken = TRUE;
2909 int intPrevValue = 5;
2914 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2918 PropertyType PropType = PROPERTY_NONE;
2920 // Look for type before continuing.
2922 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2924 // Setup the pointers.
2926 std::map<int, wxString> *WebsiteList = NULL;
2927 std::map<int, wxString> *WebsiteListAltID = NULL;
2928 std::map<int, wxString> *WebsiteListPID = NULL;
2929 std::map<int, wxString> *WebsiteListType = NULL;
2930 std::map<int, wxString> *WebsiteListTokens = NULL;
2931 std::map<int, wxString> *WebsiteListMediatype = NULL;
2932 std::map<int, int> *WebsiteListPref = NULL;
2934 // Setup blank lines for later on.
2938 WebsiteList = &GeneralWebsiteList;
2939 WebsiteListType = &GeneralWebsiteListType;
2940 WebsiteListAltID = &GeneralWebsiteListAltID;
2941 WebsiteListPID = &GeneralWebsiteListPID;
2942 WebsiteListTokens = &GeneralWebsiteListTokens;
2943 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2944 WebsiteListPref = &GeneralWebsiteListPref;
2947 WebsiteList = &HomeWebsiteList;
2948 WebsiteListType = &HomeWebsiteListType;
2949 WebsiteListAltID = &HomeWebsiteListAltID;
2950 WebsiteListPID = &HomeWebsiteListPID;
2951 WebsiteListTokens = &HomeWebsiteListTokens;
2952 WebsiteListMediatype = &HomeWebsiteListMediatype;
2953 WebsiteListPref = &HomeWebsiteListPref;
2956 WebsiteList = &BusinessWebsiteList;
2957 WebsiteListType = &BusinessWebsiteListType;
2958 WebsiteListAltID = &BusinessWebsiteListAltID;
2959 WebsiteListPID = &BusinessWebsiteListPID;
2960 WebsiteListTokens = &BusinessWebsiteListTokens;
2961 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2962 WebsiteListPref = &BusinessWebsiteListPref;
2968 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2969 intiter != SplitPoints.end(); ++intiter){
2971 SLiter = SplitLength.find(intiter->first);
2973 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2975 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2976 PropertyName = PropertyElement.GetNextToken();
2977 PropertyValue = PropertyElement.GetNextToken();
2979 intPrevValue = intiter->second;
2981 // Process properties.
2983 size_t intPropertyValueLen = PropertyValue.Len();
2985 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2987 PropertyValue.Trim();
2988 PropertyValue.RemoveLast();
2992 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2994 PropertyValue.Remove(0, 1);
2998 CaptureString(&PropertyValue, FALSE);
3000 if (PropertyName == wxT("ALTID")){
3002 WebsiteListAltID->erase(*URLCount);
3003 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3005 } else if (PropertyName == wxT("PID")){
3007 WebsiteListPID->erase(*URLCount);
3008 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3010 } else if (PropertyName == wxT("PREF")){
3012 int PriorityNumber = 0;
3013 bool ValidNumber = TRUE;
3016 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3019 catch(std::invalid_argument &e){
3020 ValidNumber = FALSE;
3023 if (ValidNumber == TRUE){
3025 WebsiteListPref->erase(*URLCount);
3026 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3030 } else if (PropertyName == wxT("MEDIATYPE")){
3032 WebsiteListMediatype->erase(*URLCount);
3033 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3037 // Something else we don't know about so append
3038 // to the tokens variable.
3040 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3042 if (FirstToken == TRUE){
3044 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3049 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3059 // Add the data to the General/Home/Work address variables.
3061 CaptureString(&PropertySeg2, FALSE);
3063 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3065 if (!PropertyTokens.IsEmpty()){
3067 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3073 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3075 std::map<int, int> SplitPoints;
3076 std::map<int, int> SplitLength;
3077 std::map<int, int>::iterator SLiter;
3078 wxString PropertyData;
3079 wxString PropertyName;
3080 wxString PropertyValue;
3081 wxString PropertyTokens;
3082 bool FirstToken = TRUE;
3083 int intPrevValue = 7;
3088 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3092 PropertyType PropType = PROPERTY_NONE;
3094 // Look for type before continuing.
3096 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3098 // Setup the pointers.
3100 std::map<int, wxString> *TitleList = NULL;
3101 std::map<int, wxString> *TitleListAltID = NULL;
3102 std::map<int, wxString> *TitleListPID = NULL;
3103 std::map<int, wxString> *TitleListType = NULL;
3104 std::map<int, wxString> *TitleListTokens = NULL;
3105 std::map<int, wxString> *TitleListLanguage = NULL;
3106 std::map<int, int> *TitleListPref = NULL;
3108 // Setup blank lines for later on.
3112 TitleList = &GeneralTitleList;
3113 TitleListType = &GeneralTitleListType;
3114 TitleListAltID = &GeneralTitleListAltID;
3115 TitleListPID = &GeneralTitleListPID;
3116 TitleListTokens = &GeneralTitleListTokens;
3117 TitleListLanguage = &GeneralTitleListLanguage;
3118 TitleListPref = &GeneralTitleListPref;
3121 TitleList = &HomeTitleList;
3122 TitleListType = &HomeTitleListType;
3123 TitleListAltID = &HomeTitleListAltID;
3124 TitleListPID = &HomeTitleListPID;
3125 TitleListTokens = &HomeTitleListTokens;
3126 TitleListLanguage = &HomeTitleListLanguage;
3127 TitleListPref = &HomeTitleListPref;
3130 TitleList = &BusinessTitleList;
3131 TitleListType = &BusinessTitleListType;
3132 TitleListAltID = &BusinessTitleListAltID;
3133 TitleListPID = &BusinessTitleListPID;
3134 TitleListTokens = &BusinessTitleListTokens;
3135 TitleListLanguage = &BusinessTitleListLanguage;
3136 TitleListPref = &BusinessTitleListPref;
3142 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3143 intiter != SplitPoints.end(); ++intiter){
3145 SLiter = SplitLength.find(intiter->first);
3147 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3149 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3150 PropertyName = PropertyElement.GetNextToken();
3151 PropertyValue = PropertyElement.GetNextToken();
3153 intPrevValue = intiter->second;
3155 // Process properties.
3157 size_t intPropertyValueLen = PropertyValue.Len();
3159 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3161 PropertyValue.Trim();
3162 PropertyValue.RemoveLast();
3166 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3168 PropertyValue.Remove(0, 1);
3172 CaptureString(&PropertyValue, FALSE);
3174 if (PropertyName == wxT("ALTID")){
3176 TitleListAltID->erase(*TitleCount);
3177 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3179 } else if (PropertyName == wxT("PID")){
3181 TitleListPID->erase(*TitleCount);
3182 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3184 } else if (PropertyName == wxT("PREF")){
3186 int PriorityNumber = 0;
3187 bool ValidNumber = TRUE;
3190 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3193 catch(std::invalid_argument &e){
3194 ValidNumber = FALSE;
3197 if (ValidNumber == TRUE){
3199 TitleListPref->erase(*TitleCount);
3200 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3204 } else if (PropertyName == wxT("LANGUAGE")){
3206 TitleListLanguage->erase(*TitleCount);
3207 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3211 // Something else we don't know about so append
3212 // to the tokens variable.
3214 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3216 if (FirstToken == TRUE){
3218 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3223 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3233 // Add the data to the General/Home/Work address variables.
3235 CaptureString(&PropertySeg2, FALSE);
3237 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3239 if (!PropertyTokens.IsEmpty()){
3241 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3247 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3249 std::map<int, int> SplitPoints;
3250 std::map<int, int> SplitLength;
3251 std::map<int, int>::iterator SLiter;
3252 wxString PropertyData;
3253 wxString PropertyName;
3254 wxString PropertyValue;
3255 wxString PropertyTokens;
3256 bool FirstToken = TRUE;
3257 int intPrevValue = 6;
3262 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3266 PropertyType PropType = PROPERTY_NONE;
3268 // Look for type before continuing.
3270 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3272 // Setup the pointers.
3274 std::map<int, wxString> *RoleList = NULL;
3275 std::map<int, wxString> *RoleListAltID = NULL;
3276 std::map<int, wxString> *RoleListPID = NULL;
3277 std::map<int, wxString> *RoleListType = NULL;
3278 std::map<int, wxString> *RoleListTokens = NULL;
3279 std::map<int, wxString> *RoleListLanguage = NULL;
3280 std::map<int, int> *RoleListPref = NULL;
3282 // Setup blank lines for later on.
3286 RoleList = &GeneralRoleList;
3287 RoleListType = &GeneralRoleListType;
3288 RoleListAltID = &GeneralRoleListAltID;
3289 RoleListPID = &GeneralRoleListPID;
3290 RoleListTokens = &GeneralRoleListTokens;
3291 RoleListLanguage = &GeneralRoleListLanguage;
3292 RoleListPref = &GeneralRoleListPref;
3295 RoleList = &HomeRoleList;
3296 RoleListType = &HomeRoleListType;
3297 RoleListAltID = &HomeRoleListAltID;
3298 RoleListPID = &HomeRoleListPID;
3299 RoleListTokens = &HomeRoleListTokens;
3300 RoleListLanguage = &HomeRoleListLanguage;
3301 RoleListPref = &HomeRoleListPref;
3304 RoleList = &BusinessRoleList;
3305 RoleListType = &BusinessRoleListType;
3306 RoleListAltID = &BusinessRoleListAltID;
3307 RoleListPID = &BusinessRoleListPID;
3308 RoleListTokens = &BusinessRoleListTokens;
3309 RoleListLanguage = &BusinessRoleListLanguage;
3310 RoleListPref = &BusinessRoleListPref;
3316 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3317 intiter != SplitPoints.end(); ++intiter){
3319 SLiter = SplitLength.find(intiter->first);
3321 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3323 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3324 PropertyName = PropertyElement.GetNextToken();
3325 PropertyValue = PropertyElement.GetNextToken();
3327 intPrevValue = intiter->second;
3329 // Process properties.
3331 size_t intPropertyValueLen = PropertyValue.Len();
3333 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3335 PropertyValue.Trim();
3336 PropertyValue.RemoveLast();
3340 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3342 PropertyValue.Remove(0, 1);
3346 CaptureString(&PropertyValue, FALSE);
3348 if (PropertyName == wxT("ALTID")){
3350 RoleListAltID->erase(*RoleCount);
3351 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3353 } else if (PropertyName == wxT("PID")){
3355 RoleListPID->erase(*RoleCount);
3356 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3358 } else if (PropertyName == wxT("PREF")){
3360 int PriorityNumber = 0;
3361 bool ValidNumber = TRUE;
3364 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3367 catch(std::invalid_argument &e){
3368 ValidNumber = FALSE;
3371 if (ValidNumber == TRUE){
3373 RoleListPref->erase(*RoleCount);
3374 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3378 } else if (PropertyName == wxT("LANGUAGE")){
3380 RoleListLanguage->erase(*RoleCount);
3381 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3385 // Something else we don't know about so append
3386 // to the tokens variable.
3388 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3390 if (FirstToken == TRUE){
3392 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3397 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3407 // Add the data to the General/Home/Work address variables.
3409 CaptureString(&PropertySeg2, FALSE);
3411 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3413 if (!PropertyTokens.IsEmpty()){
3415 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3421 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3423 std::map<int, int> SplitPoints;
3424 std::map<int, int> SplitLength;
3425 std::map<int, int>::iterator SLiter;
3426 wxString PropertyData;
3427 wxString PropertyName;
3428 wxString PropertyValue;
3429 wxString PropertyTokens;
3430 bool FirstToken = TRUE;
3431 int intPrevValue = 5;
3436 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3440 PropertyType PropType = PROPERTY_NONE;
3442 // Look for type before continuing.
3444 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3446 // Setup the pointers.
3448 std::map<int, wxString> *OrganisationsList = NULL;
3449 std::map<int, wxString> *OrganisationsListAltID = NULL;
3450 std::map<int, wxString> *OrganisationsListPID = NULL;
3451 std::map<int, wxString> *OrganisationsListType = NULL;
3452 std::map<int, wxString> *OrganisationsListTokens = NULL;
3453 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3454 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3455 std::map<int, int> *OrganisationsListPref = NULL;
3457 // Setup blank lines for later on.
3461 OrganisationsList = &GeneralOrganisationsList;
3462 OrganisationsListType = &GeneralOrganisationsListType;
3463 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3464 OrganisationsListPID = &GeneralOrganisationsListPID;
3465 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3466 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3467 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3468 OrganisationsListPref = &GeneralOrganisationsListPref;
3471 OrganisationsList = &HomeOrganisationsList;
3472 OrganisationsListType = &HomeOrganisationsListType;
3473 OrganisationsListAltID = &HomeOrganisationsListAltID;
3474 OrganisationsListPID = &HomeOrganisationsListPID;
3475 OrganisationsListTokens = &HomeOrganisationsListTokens;
3476 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3477 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3478 OrganisationsListPref = &HomeOrganisationsListPref;
3481 OrganisationsList = &BusinessOrganisationsList;
3482 OrganisationsListType = &BusinessOrganisationsListType;
3483 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3484 OrganisationsListPID = &BusinessOrganisationsListPID;
3485 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3486 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3487 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3488 OrganisationsListPref = &BusinessOrganisationsListPref;
3494 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3495 intiter != SplitPoints.end(); ++intiter){
3497 SLiter = SplitLength.find(intiter->first);
3499 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3501 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3502 PropertyName = PropertyElement.GetNextToken();
3503 PropertyValue = PropertyElement.GetNextToken();
3505 intPrevValue = intiter->second;
3507 // Process properties.
3509 size_t intPropertyValueLen = PropertyValue.Len();
3511 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3513 PropertyValue.Trim();
3514 PropertyValue.RemoveLast();
3518 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3520 PropertyValue.Remove(0, 1);
3524 CaptureString(&PropertyValue, FALSE);
3526 if (PropertyName == wxT("ALTID")){
3528 OrganisationsListAltID->erase(*OrganisationCount);
3529 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3531 } else if (PropertyName == wxT("PID")){
3533 OrganisationsListPID->erase(*OrganisationCount);
3534 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3536 } else if (PropertyName == wxT("SORT-AS")){
3538 OrganisationsListSortAs->erase(*OrganisationCount);
3539 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3541 } else if (PropertyName == wxT("PREF")){
3543 int PriorityNumber = 0;
3544 bool ValidNumber = TRUE;
3547 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3550 catch(std::invalid_argument &e){
3551 ValidNumber = FALSE;
3554 if (ValidNumber == TRUE){
3556 OrganisationsListPref->erase(*OrganisationCount);
3557 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3561 } else if (PropertyName == wxT("LANGUAGE")){
3563 OrganisationsListLanguage->erase(*OrganisationCount);
3564 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3568 // Something else we don't know about so append
3569 // to the tokens variable.
3571 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3573 if (FirstToken == TRUE){
3575 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3580 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3590 // Add the data to the General/Home/Work address variables.
3592 CaptureString(&PropertySeg2, FALSE);
3594 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3596 if (!PropertyTokens.IsEmpty()){
3598 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3604 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3606 std::map<int, int> SplitPoints;
3607 std::map<int, int> SplitLength;
3608 std::map<int, int>::iterator SLiter;
3609 wxString PropertyData;
3610 wxString PropertyName;
3611 wxString PropertyValue;
3612 wxString PropertyTokens;
3613 bool FirstToken = TRUE;
3614 int intPrevValue = 6;
3619 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3623 PropertyType PropType = PROPERTY_NONE;
3625 // Look for type before continuing.
3627 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3629 // Setup the pointers.
3631 std::map<int, wxString> *NoteList = NULL;
3632 std::map<int, wxString> *NoteListAltID = NULL;
3633 std::map<int, wxString> *NoteListPID = NULL;
3634 std::map<int, wxString> *NoteListType = NULL;
3635 std::map<int, wxString> *NoteListTokens = NULL;
3636 std::map<int, wxString> *NoteListLanguage = NULL;
3637 std::map<int, int> *NoteListPref = NULL;
3639 // Setup blank lines for later on.
3643 NoteList = &GeneralNoteList;
3644 NoteListType = &GeneralNoteListType;
3645 NoteListAltID = &GeneralNoteListAltID;
3646 NoteListPID = &GeneralNoteListPID;
3647 NoteListTokens = &GeneralNoteListTokens;
3648 NoteListLanguage = &GeneralNoteListLanguage;
3649 NoteListPref = &GeneralNoteListPref;
3652 NoteList = &HomeNoteList;
3653 NoteListType = &HomeNoteListType;
3654 NoteListAltID = &HomeNoteListAltID;
3655 NoteListPID = &HomeNoteListPID;
3656 NoteListTokens = &HomeNoteListTokens;
3657 NoteListLanguage = &HomeNoteListLanguage;
3658 NoteListPref = &HomeNoteListPref;
3661 NoteList = &BusinessNoteList;
3662 NoteListType = &BusinessNoteListType;
3663 NoteListAltID = &BusinessNoteListAltID;
3664 NoteListPID = &BusinessNoteListPID;
3665 NoteListTokens = &BusinessNoteListTokens;
3666 NoteListLanguage = &BusinessNoteListLanguage;
3667 NoteListPref = &BusinessNoteListPref;
3673 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3674 intiter != SplitPoints.end(); ++intiter){
3676 SLiter = SplitLength.find(intiter->first);
3678 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3680 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3681 PropertyName = PropertyElement.GetNextToken();
3682 PropertyValue = PropertyElement.GetNextToken();
3684 intPrevValue = intiter->second;
3686 // Process properties.
3688 size_t intPropertyValueLen = PropertyValue.Len();
3690 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3692 PropertyValue.Trim();
3693 PropertyValue.RemoveLast();
3697 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3699 PropertyValue.Remove(0, 1);
3703 CaptureString(&PropertyValue, FALSE);
3705 if (PropertyName == wxT("ALTID")){
3707 NoteListAltID->erase(*NoteCount);
3708 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3710 } else if (PropertyName == wxT("PID")){
3712 NoteListPID->erase(*NoteCount);
3713 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3715 } else if (PropertyName == wxT("PREF")){
3717 int PriorityNumber = 0;
3718 bool ValidNumber = TRUE;
3721 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3724 catch(std::invalid_argument &e){
3725 ValidNumber = FALSE;
3728 if (ValidNumber == TRUE){
3730 NoteListPref->erase(*NoteCount);
3731 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3735 } else if (PropertyName == wxT("LANGUAGE")){
3737 NoteListLanguage->erase(*NoteCount);
3738 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3742 // Something else we don't know about so append
3743 // to the tokens variable.
3745 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3747 if (FirstToken == TRUE){
3749 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3754 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3764 // Add the data to the General/Home/Work address variables.
3766 CaptureString(&PropertySeg2, FALSE);
3768 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3770 if (!PropertyTokens.IsEmpty()){
3772 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3778 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3780 std::map<int, int> SplitPoints;
3781 std::map<int, int> SplitLength;
3782 std::map<int, int>::iterator SLiter;
3783 wxString PropertyData;
3784 wxString PropertyName;
3785 wxString PropertyValue;
3786 wxString PropertyTokens;
3787 bool FirstToken = TRUE;
3788 int intPrevValue = 12;
3793 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3797 PropertyType PropType = PROPERTY_NONE;
3799 // Look for type before continuing.
3801 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3803 // Setup blank lines for later on.
3809 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3812 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3818 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3819 intiter != SplitPoints.end(); ++intiter){
3821 SLiter = SplitLength.find(intiter->first);
3823 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3825 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3826 PropertyName = PropertyElement.GetNextToken();
3827 PropertyValue = PropertyElement.GetNextToken();
3829 intPrevValue = intiter->second;
3831 // Process properties.
3833 size_t intPropertyValueLen = PropertyValue.Len();
3835 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3837 PropertyValue.Trim();
3838 PropertyValue.RemoveLast();
3842 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3844 PropertyValue.Remove(0, 1);
3848 CaptureString(&PropertyValue, FALSE);
3850 if (PropertyName == wxT("ALTID")){
3852 CategoriesListAltID.erase(*CategoryCount);
3853 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3855 } else if (PropertyName == wxT("PID")){
3857 CategoriesListPID.erase(*CategoryCount);
3858 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3860 } else if (PropertyName == wxT("PREF")){
3862 int PriorityNumber = 0;
3863 bool ValidNumber = TRUE;
3866 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3869 catch(std::invalid_argument &e){
3870 ValidNumber = FALSE;
3873 if (ValidNumber == TRUE){
3875 CategoriesListPref.erase(*CategoryCount);
3876 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3880 } else if (PropertyName == wxT("LANGUAGE")){
3882 CategoriesListLanguage.erase(*CategoryCount);
3883 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3887 // Something else we don't know about so append
3888 // to the tokens variable.
3890 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3892 if (FirstToken == TRUE){
3894 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3899 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3909 // Deal with multiple categories.
3911 int intOrigCatCount = *CategoryCount;
3912 bool FirstCategoryProcessed = TRUE;
3913 bool AfterFirstToken = FALSE;
3914 int intSplitSize = 0;
3915 int intSplitsFound = 0;
3916 int intSplitSeek = 0;
3917 int intPropertyLen = PropertySeg2.Len();
3919 SplitPoints.clear();
3920 SplitLength.clear();
3923 for (int i = 0; i <= intPropertyLen; i++){
3925 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3933 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3935 if (AfterFirstToken == TRUE){
3937 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3938 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3942 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3943 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3944 AfterFirstToken = TRUE;
3956 if (SplitPoints.size() > 0){
3958 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3959 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3963 if (SplitPoints.size() == 0){
3965 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3967 if (!PropertyTokens.IsEmpty()){
3969 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3975 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3976 intiter != SplitPoints.end(); ++intiter){
3978 SLiter = SplitLength.find(intiter->first);
3980 intPrevValue = intiter->second;
3982 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3984 // Add the data to the General/Home/Work address variables.
3986 // Trim any whitespace from the start and end.
3988 PropertyData = PropertyData.Trim(FALSE);
3989 PropertyData = PropertyData.Trim(TRUE);
3991 CaptureString(&PropertyData, FALSE);
3993 if (FirstCategoryProcessed == TRUE){
3995 FirstCategoryProcessed = FALSE;
3997 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3999 if (!PropertyTokens.IsEmpty()){
4001 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4011 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4013 if (!PropertyTokens.IsEmpty()){
4015 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4021 // Copy the properties to each of the categories (if it exists).
4023 if (!PropertyTokens.IsEmpty()){
4025 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4029 // Check if ALTID was used.
4031 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4033 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4037 // Check if PID was used.
4039 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4041 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4045 // Check if PREF was used.
4047 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4049 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4053 // Check if LANGUAGE was used.
4055 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4057 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4061 // Check if TYPE was used.
4067 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4070 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4078 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4080 size_t intPropertyLen = PropertySeg1.Len();
4081 std::map<int, int> SplitPoints;
4082 std::map<int, int> SplitLength;
4083 std::map<int, int>::iterator SLiter;
4084 wxString PropertyData;
4085 wxString PropertyName;
4086 wxString PropertyValue;
4087 wxString PropertyTokens;
4088 bool FirstToken = TRUE;
4089 int intSplitsFound = 0;
4090 int intSplitSize = 0;
4091 int intPrevValue = 7;
4095 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4099 PropertyType PropType = PROPERTY_NONE;
4101 // Look for type before continuing.
4103 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4107 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4108 intiter != SplitPoints.end(); ++intiter){
4110 SLiter = SplitLength.find(intiter->first);
4112 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4114 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4115 PropertyName = PropertyElement.GetNextToken();
4116 PropertyValue = PropertyElement.GetNextToken();
4118 intPrevValue = intiter->second;
4120 // Process properties.
4122 size_t intPropertyValueLen = PropertyValue.Len();
4124 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4126 PropertyValue.Trim();
4127 PropertyValue.RemoveLast();
4131 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4133 PropertyValue.Remove(0, 1);
4137 CaptureString(&PropertyValue, FALSE);
4139 if (PropertyName == wxT("ALTID")){
4141 PicturesListAltID.erase(*PhotoCount);
4142 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4144 } else if (PropertyName == wxT("PID")){
4146 PicturesListPID.erase(*PhotoCount);
4147 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4149 } else if (PropertyName == wxT("PREF")){
4151 int PriorityNumber = 0;
4152 bool ValidNumber = TRUE;
4155 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4158 catch(std::invalid_argument &e){
4159 ValidNumber = FALSE;
4162 if (ValidNumber == TRUE){
4164 PicturesListPref.erase(*PhotoCount);
4165 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4169 } else if (PropertyName == wxT("MEDIATYPE")){
4171 PicturesListMediatype.erase(*PhotoCount);
4172 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4176 // Something else we don't know about so append
4177 // to the tokens variable.
4179 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4181 if (FirstToken == TRUE){
4183 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4188 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4198 intPropertyLen = PropertySeg2.Len();
4199 SplitPoints.clear();
4200 SplitLength.clear();
4205 CaptureString(&PropertySeg2, FALSE);
4207 for (int i = 0; i <= intPropertyLen; i++){
4211 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4214 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4216 if (intSplitsFound == 6){
4218 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4223 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4233 wxString wxSPhotoURI;
4234 wxString wxSPhotoMIME;
4235 wxString wxSPhotoEncoding;
4236 wxString wxSPhotoData;
4237 std::string base64enc;
4239 if (intSplitsFound == 0){
4243 std::map<int, int>::iterator striter;
4245 striter = SplitLength.find(1);
4247 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4249 while (wSTDataType.HasMoreTokens() == TRUE){
4251 wxSPhotoURI = wSTDataType.GetNextToken();
4252 wxSPhotoMIME = wSTDataType.GetNextToken();
4257 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4259 while (wSTDataInfo.HasMoreTokens() == TRUE){
4261 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4262 wxSPhotoData = wSTDataInfo.GetNextToken();
4263 base64enc = wxSPhotoData.mb_str();
4270 // Add the data to the General/Home/Work address variables.
4272 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4273 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4274 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4280 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4283 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4287 if (!PropertyTokens.IsEmpty()){
4289 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4295 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4297 size_t intPropertyLen = PropertySeg1.Len();
4298 std::map<int, int> SplitPoints;
4299 std::map<int, int> SplitLength;
4300 std::map<int, int>::iterator SLiter;
4301 wxString PropertyData;
4302 wxString PropertyName;
4303 wxString PropertyValue;
4304 wxString PropertyTokens;
4305 bool FirstToken = TRUE;
4306 int intSplitsFound = 0;
4307 int intSplitSize = 0;
4308 int intPrevValue = 6;
4312 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4316 PropertyType PropType = PROPERTY_NONE;
4318 // Look for type before continuing.
4320 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4324 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4325 intiter != SplitPoints.end(); ++intiter){
4327 SLiter = SplitLength.find(intiter->first);
4329 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4331 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4332 PropertyName = PropertyElement.GetNextToken();
4333 PropertyValue = PropertyElement.GetNextToken();
4335 intPrevValue = intiter->second;
4337 // Process properties.
4339 size_t intPropertyValueLen = PropertyValue.Len();
4341 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4343 PropertyValue.Trim();
4344 PropertyValue.RemoveLast();
4348 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4350 PropertyValue.Remove(0, 1);
4354 CaptureString(&PropertyValue, FALSE);
4356 if (PropertyName == wxT("ALTID")){
4358 LogosListAltID.erase(*LogoCount);
4359 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4361 } else if (PropertyName == wxT("PID")){
4363 LogosListPID.erase(*LogoCount);
4364 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4366 } else if (PropertyName == wxT("PREF")){
4368 int PriorityNumber = 0;
4369 bool ValidNumber = TRUE;
4372 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4375 catch(std::invalid_argument &e){
4376 ValidNumber = FALSE;
4379 if (ValidNumber == TRUE){
4381 LogosListPref.erase(*LogoCount);
4382 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4386 } else if (PropertyName == wxT("MEDIATYPE")){
4388 LogosListMediatype.erase(*LogoCount);
4389 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4393 // Something else we don't know about so append
4394 // to the tokens variable.
4396 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4398 if (FirstToken == TRUE){
4400 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4405 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4415 intPropertyLen = PropertySeg2.Len();
4416 SplitPoints.clear();
4417 SplitLength.clear();
4422 CaptureString(&PropertySeg2, FALSE);
4424 for (int i = 0; i <= intPropertyLen; i++){
4428 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4431 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4433 if (intSplitsFound == 6){
4435 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4440 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4450 wxString wxSPhotoURI;
4451 wxString wxSPhotoMIME;
4452 wxString wxSPhotoEncoding;
4453 wxString wxSPhotoData;
4454 std::string base64enc;
4456 if (intSplitsFound == 0){
4460 std::map<int, int>::iterator striter;
4462 striter = SplitLength.find(1);
4464 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4466 while (wSTDataType.HasMoreTokens() == TRUE){
4468 wxSPhotoURI = wSTDataType.GetNextToken();
4469 wxSPhotoMIME = wSTDataType.GetNextToken();
4474 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4476 while (wSTDataInfo.HasMoreTokens() == TRUE){
4478 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4479 wxSPhotoData = wSTDataInfo.GetNextToken();
4480 base64enc = wxSPhotoData.mb_str();
4487 // Add the data to the General/Home/Work address variables.
4489 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4490 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4491 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4497 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4500 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4504 if (!PropertyTokens.IsEmpty()){
4506 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4512 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4514 size_t intPropertyLen = PropertySeg1.Len();
4515 std::map<int, int> SplitPoints;
4516 std::map<int, int> SplitLength;
4517 std::map<int, int>::iterator SLiter;
4518 wxString PropertyData;
4519 wxString PropertyName;
4520 wxString PropertyValue;
4521 wxString PropertyTokens;
4522 bool FirstToken = TRUE;
4523 int intSplitsFound = 0;
4524 int intSplitSize = 0;
4525 int intPrevValue = 7;
4529 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4533 PropertyType PropType = PROPERTY_NONE;
4535 // Look for type before continuing.
4537 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4541 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4542 intiter != SplitPoints.end(); ++intiter){
4544 SLiter = SplitLength.find(intiter->first);
4546 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4548 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4549 PropertyName = PropertyElement.GetNextToken();
4550 PropertyValue = PropertyElement.GetNextToken();
4552 intPrevValue = intiter->second;
4554 // Process properties.
4556 size_t intPropertyValueLen = PropertyValue.Len();
4558 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4560 PropertyValue.Trim();
4561 PropertyValue.RemoveLast();
4565 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4567 PropertyValue.Remove(0, 1);
4571 CaptureString(&PropertyValue, FALSE);
4573 if (PropertyName == wxT("ALTID")){
4575 SoundsListAltID.erase(*SoundCount);
4576 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4578 } else if (PropertyName == wxT("PID")){
4580 SoundsListPID.erase(*SoundCount);
4581 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4583 } else if (PropertyName == wxT("PREF")){
4585 int PriorityNumber = 0;
4586 bool ValidNumber = TRUE;
4589 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4592 catch(std::invalid_argument &e){
4593 ValidNumber = FALSE;
4596 if (ValidNumber == TRUE){
4598 SoundsListPref.erase(*SoundCount);
4599 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4603 } else if (PropertyName == wxT("MEDIATYPE")){
4605 SoundsListMediatype.erase(*SoundCount);
4606 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4608 } else if (PropertyName == wxT("LANGUAGE")){
4610 SoundsListLanguage.erase(*SoundCount);
4611 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4615 // Something else we don't know about so append
4616 // to the tokens variable.
4618 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4620 if (FirstToken == TRUE){
4622 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4627 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4637 intPropertyLen = PropertySeg2.Len();
4638 SplitPoints.clear();
4639 SplitLength.clear();
4644 CaptureString(&PropertySeg2, FALSE);
4646 for (int i = 0; i <= intPropertyLen; i++){
4650 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4653 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4655 if (intSplitsFound == 6){
4657 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4662 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4672 wxString wxSSoundURI;
4673 wxString wxSSoundMIME;
4674 wxString wxSSoundEncoding;
4675 wxString wxSSoundData;
4676 std::string base64enc;
4678 if (intSplitsFound == 0){
4682 std::map<int, int>::iterator striter;
4684 striter = SplitLength.find(1);
4686 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4688 while (wSTDataType.HasMoreTokens() == TRUE){
4690 wxSSoundURI = wSTDataType.GetNextToken();
4691 wxSSoundMIME = wSTDataType.GetNextToken();
4696 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4698 while (wSTDataInfo.HasMoreTokens() == TRUE){
4700 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4701 wxSSoundData = wSTDataInfo.GetNextToken();
4702 base64enc = wxSSoundData.mb_str();
4709 // Add the data to the General/Home/Work address variables.
4715 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4718 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4722 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4723 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4724 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4726 if (!PropertyTokens.IsEmpty()){
4728 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4734 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4736 size_t intPropertyLen = PropertySeg1.Len();
4737 std::map<int, int> SplitPoints;
4738 std::map<int, int> SplitLength;
4739 std::map<int, int>::iterator SLiter;
4740 wxString PropertyData;
4741 wxString PropertyName;
4742 wxString PropertyValue;
4743 wxString PropertyTokens;
4744 bool FirstToken = TRUE;
4745 int intSplitsFound = 0;
4746 int intSplitSize = 0;
4747 int intPrevValue = 8;
4751 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4755 PropertyType PropType = PROPERTY_NONE;
4757 // Look for type before continuing.
4759 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4763 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4764 intiter != SplitPoints.end(); ++intiter){
4766 SLiter = SplitLength.find(intiter->first);
4768 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4770 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4771 PropertyName = PropertyElement.GetNextToken();
4772 PropertyValue = PropertyElement.GetNextToken();
4774 intPrevValue = intiter->second;
4776 // Process properties.
4778 size_t intPropertyValueLen = PropertyValue.Len();
4780 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4782 PropertyValue.Trim();
4783 PropertyValue.RemoveLast();
4787 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4789 PropertyValue.Remove(0, 1);
4793 CaptureString(&PropertyValue, FALSE);
4795 if (PropertyName == wxT("ALTID")){
4797 CalendarListAltID.erase(*CalURICount);
4798 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4800 } else if (PropertyName == wxT("PID")){
4802 CalendarListPID.erase(*CalURICount);
4803 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4805 } else if (PropertyName == wxT("PREF")){
4807 int PriorityNumber = 0;
4808 bool ValidNumber = TRUE;
4811 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4814 catch(std::invalid_argument &e){
4815 ValidNumber = FALSE;
4818 if (ValidNumber == TRUE){
4820 CalendarListPref.erase(*CalURICount);
4821 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
4825 } else if (PropertyName == wxT("MEDIATYPE")){
4827 CalendarListMediatype.erase(*CalURICount);
4828 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4832 // Something else we don't know about so append
4833 // to the tokens variable.
4835 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4837 if (FirstToken == TRUE){
4839 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4844 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4854 intPropertyLen = PropertySeg2.Len();
4855 SplitPoints.clear();
4856 SplitLength.clear();
4861 CaptureString(&PropertySeg2, FALSE);
4863 // Add the data to the General/Home/Work address variables.
4869 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4872 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4876 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4878 if (!PropertyTokens.IsEmpty()){
4880 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4886 void SplitValues(wxString *PropertyLine,
4887 std::map<int,int> *SplitPoints,
4888 std::map<int,int> *SplitLength,
4891 size_t intPropertyLen = PropertyLine->Len();
4892 int intSplitsFound = 0;
4893 int intSplitSize = 0;
4894 int intSplitSeek = 0;
4896 for (int i = intSize; i <= intPropertyLen; i++){
4900 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4901 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4903 if (intSplitsFound == 0){
4905 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4909 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4913 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4923 if (intSplitsFound == 0){
4925 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4926 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4930 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4931 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4937 void CheckType(wxString *PropertySeg1,
4938 std::map<int,int> *SplitPoints,
4939 std::map<int,int> *SplitLength,
4941 PropertyType *PropType){
4943 wxString PropertyData;
4944 wxString PropertyName;
4945 wxString PropertyValue;
4946 std::map<int,int>::iterator SLiter;
4948 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
4949 intiter != SplitPoints->end(); ++intiter){
4951 SLiter = SplitLength->find(intiter->first);
4953 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4955 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4956 PropertyName = PropertyElement.GetNextToken();
4957 PropertyValue = PropertyElement.GetNextToken();
4959 *intPrevValue = intiter->second;
4961 if (PropertyName == wxT("TYPE")){
4963 if (PropertyValue == wxT("work")){
4965 *PropType = PROPERTY_WORK;
4967 } else if (PropertyValue == wxT("home")){
4969 *PropType = PROPERTY_HOME;
4973 *PropType = PROPERTY_NONE;