1 // ContactDataObject.cpp - Client Data Object.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 int ContactLineLen = 0;
82 int QuoteBreakPoint = 0;
85 int NicknameCount = 0;
86 int TimeZoneCount = 0;
90 int TelephoneCount = 0;
91 int LanguageCount = 0;
92 int GeographicCount = 0;
97 int OrganisationCount = 0;
99 int CategoryCount = 0;
103 int CalendarCount = 0;
104 int CalendarAddressCount = 0;
105 wxString ContactLine;
106 wxString PropertyLine;
107 wxString PropertySeg1;
108 wxString PropertySeg2;
109 wxString PropertyNextLine;
112 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
113 iter != ContactFileLines.end(); ++iter){
115 ExtraLineSeek = TRUE;
121 PropertyLine.Clear();
122 PropertySeg1.Clear();
123 PropertySeg2.Clear();
126 ContactLine = iter->second;
128 while (ExtraLineSeek == TRUE){
130 // Check if there is extra data on the next line
131 // (indicated by space or tab at the start) and add data.
135 if (iter == ContactFileLines.end()){
142 PropertyNextLine = iter->second;
144 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
146 PropertyNextLine.Remove(0, 1);
147 ContactLine.Append(PropertyNextLine);
152 ExtraLineSeek = FALSE;
158 ContactLineLen = ContactLine.Len();
160 // Make sure we are not in quotation mode.
161 // Make sure colon does not have \ or \\ before it.
163 for (int i = 0; i <= ContactLineLen; i++){
165 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
167 PropertyFind = FALSE;
169 } else if (PropertyFind == TRUE){
171 Property.Append(ContactLine.Mid(i, 1));
175 if (ContactLine.Mid(i, 1) == wxT("\"")){
177 if (QuoteMode == TRUE){
189 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
198 // Split that line at the point into two variables (ignore the colon).
200 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
201 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
203 if (Property == wxT("KIND") && KindProcessed == FALSE){
205 ProcessKind(PropertySeg2);
207 } else if (Property == wxT("MEMBER")){
209 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
212 } else if (Property == wxT("FN")){
214 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
217 } else if (Property == wxT("N") && NameProcessed == FALSE){
219 ProcessN(PropertySeg1, PropertySeg2);
220 NameProcessed = TRUE;
222 } else if (Property == wxT("NICKNAME")){
224 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
227 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
229 ProcessGender(PropertySeg1, PropertySeg2);
230 GenderProcessed = TRUE;
232 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
234 ProcessBirthday(PropertySeg1, PropertySeg2);
235 BirthdayProcessed = TRUE;
237 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
239 ProcessAnniversary(PropertySeg1, PropertySeg2);
240 AnniversaryProcessed = TRUE;
242 } else if (Property == wxT("TZ")){
244 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
247 } else if (Property == wxT("ADR")){
249 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
252 } else if (Property == wxT("EMAIL")){
254 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
257 } else if (Property == wxT("IMPP")){
259 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
262 } else if (Property == wxT("TEL")){
264 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
267 } else if (Property == wxT("LANG")){
269 // See frmContactEditor-LoadLanguage.cpp
271 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
274 } else if (Property == wxT("GEO")){
276 // See frmContactEditor-LoadGeo.cpp
278 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
281 } else if (Property == wxT("RELATED")){
283 // See fromContactEditor-LoadRelated.cpp
285 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
288 } else if (Property == wxT("URL")){
290 // See frmContactEditor-LoadURL.cpp
292 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
295 } else if (Property == wxT("TITLE")) {
297 // See frmContactEditor-LoadTitle.cpp
299 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
302 } else if (Property == wxT("ROLE")) {
304 // See frmContactEditor-LoadTitle.cpp
306 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
309 } else if (Property == wxT("ORG")) {
311 // See frmContactEditor-LoadOrg.cpp
313 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
316 } else if (Property == wxT("NOTE")) {
318 // See frmContactEditor-LoadNote.cpp
320 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
323 } else if (Property == wxT("CATEGORIES")) {
325 // See frmContactEditor-LoadCategory.cpp
327 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
330 } else if (Property == wxT("PHOTO")) {
332 // See frmContactEditor-LoadPhoto.cpp
334 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
337 } else if (Property == wxT("LOGO")) {
339 // See frmContactEditor-LoadPhoto.cpp
341 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
344 } else if (Property == wxT("LOGO")) {
346 // See frmContactEditor-LoadPhoto.cpp
348 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
351 } else if (Property == wxT("SOUND")) {
353 // See frmContactEditor-LoadSound.cpp
355 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
358 } else if (Property == wxT("CALURI")){
360 // See frmContactEditor-LoadCalendar.cpp
362 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
365 } else if (Property == wxT("CALADRURI")){
367 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
368 CalendarAddressCount++;
374 return CONTACTLOAD_OK;
378 void ContactDataObject::ProcessKind(wxString KindType){
380 if (KindType == wxT("individual")){
382 ContactKind = CONTACTKIND_INDIVIDUAL;
384 } else if (KindType == wxT("group")){
386 ContactKind = CONTACTKIND_GROUP;
388 } else if (KindType == wxT("org")){
390 ContactKind = CONTACTKIND_ORGANISATION;
392 } else if (KindType == wxT("location")){
394 ContactKind = CONTACTKIND_LOCATION;
398 ContactKind = CONTACTKIND_NONE;
403 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
405 std::map<int, int> SplitPoints;
406 std::map<int, int> SplitLength;
408 int intPrevValue = 8;
412 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
416 wxString PropertyName;
417 wxString PropertyValue;
418 wxString PropertyData;
419 wxString PropertyTokens;
420 std::map<int,int>::iterator SLiter;
421 bool FirstToken = TRUE;
423 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
424 intiter != SplitPoints.end(); ++intiter){
426 SLiter = SplitLength.find(intiter->first);
428 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
430 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
431 PropertyName = PropertyElement.GetNextToken();
432 PropertyValue = PropertyElement.GetNextToken();
434 intPrevValue = intiter->second;
436 CaptureString(&PropertyValue, FALSE);
438 if (PropertyName == wxT("ALTID")){
440 GroupsListAltID.erase(*GroupCount);
441 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
443 } else if (PropertyName == wxT("PID")){
445 GroupsListPID.erase(*GroupCount);
446 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
448 } else if (PropertyName == wxT("PREF")){
450 int PriorityNumber = 0;
451 bool ValidNumber = TRUE;
454 PriorityNumber = std::stoi(PropertyValue.ToStdString());
457 catch(std::invalid_argument &e){
461 if (ValidNumber == TRUE){
463 GroupsListPref.erase(*GroupCount);
464 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
468 } else if (PropertyName == wxT("MEDIATYPE")){
470 GroupsListMediaType.erase(*GroupCount);
471 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
473 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
475 if (FirstToken == TRUE){
477 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
482 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
490 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
492 if (!PropertyTokens.IsEmpty()){
494 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
501 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
503 std::map<int, int> SplitPoints;
504 std::map<int, int> SplitLength;
506 int intPrevValue = 4;
510 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
514 wxString PropertyName;
515 wxString PropertyValue;
516 wxString PropertyData;
517 wxString PropertyTokens;
518 std::map<int,int>::iterator SLiter;
519 bool FirstToken = TRUE;
521 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
522 intiter != SplitPoints.end(); ++intiter){
524 SLiter = SplitLength.find(intiter->first);
526 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
528 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
529 PropertyName = PropertyElement.GetNextToken();
530 PropertyValue = PropertyElement.GetNextToken();
532 intPrevValue = intiter->second;
534 CaptureString(&PropertyValue, FALSE);
536 if (PropertyName == wxT("TYPE")){
538 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
539 PropertyValue == wxT("work") ){
541 FullNamesListType.erase(*FNCount);
542 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
546 } else if (PropertyName == wxT("LANGUAGE")){
548 FullNamesListLanguage.erase(*FNCount);
549 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
551 } else if (PropertyName == wxT("ALTID")){
553 FullNamesListAltID.erase(*FNCount);
554 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
556 } else if (PropertyName == wxT("PID")){
558 FullNamesListPID.erase(*FNCount);
559 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
561 } else if (PropertyName == wxT("PREF")){
563 int PriorityNumber = 0;
564 bool ValidNumber = TRUE;
567 PriorityNumber = std::stoi(PropertyValue.ToStdString());
570 catch(std::invalid_argument &e){
574 if (ValidNumber == TRUE){
576 FullNamesListPref.erase(*FNCount);
577 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
581 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
583 if (FirstToken == TRUE){
585 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
590 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
598 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
600 if (!PropertyTokens.IsEmpty()){
602 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
608 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
610 std::map<int, int> SplitPoints;
611 std::map<int, int> SplitLength;
613 int intPrevValue = 3;
617 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
621 wxString PropertyName;
622 wxString PropertyValue;
623 wxString PropertyData;
624 wxString PropertyTokens;
625 std::map<int,int>::iterator SLiter;
626 bool FirstToken = TRUE;
628 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
629 intiter != SplitPoints.end(); ++intiter){
631 SLiter = SplitLength.find(intiter->first);
633 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
635 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
636 PropertyName = PropertyElement.GetNextToken();
637 PropertyValue = PropertyElement.GetNextToken();
639 intPrevValue = intiter->second;
641 CaptureString(&PropertyValue, FALSE);
643 if (PropertyName == wxT("ALTID")){
645 NameAltID = PropertyValue;
647 } else if (PropertyName == wxT("LANGUAGE")){
649 NameLanguage = PropertyValue;
651 } else if (PropertyName == wxT("SORT-AS")){
653 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
654 PropertyValue.Len() >= 3){
655 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
658 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
660 if (FirstToken == TRUE){
662 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
667 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
675 // Split the name data.
677 int intSplitSeek = 0;
678 int intSplitsFound = 0;
679 int intSplitSize = 0;
680 int intPropertyLen = PropertySeg2.Len();
682 std::map<int,wxString> NameValues;
685 for (int i = 0; i <= intPropertyLen; i++){
687 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
689 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
694 if (intSplitsFound == 4){
696 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
710 // Split the data into several parts.
712 for (std::map<int, wxString>::iterator iter = NameValues.begin();
713 iter != NameValues.end(); ++iter){
715 if (iter->first == 1){
717 // Deal with family name.
719 NameSurname = iter->second;
721 } else if (iter->first == 2){
723 // Deal with given names.
725 NameForename = iter->second;
727 } else if (iter->first == 3){
729 // Deal with additional names.
731 NameOtherNames = iter->second;
733 } else if (iter->first == 4){
735 // Deal with honorifix prefixes and suffixes.
737 NameTitle = iter->second;
741 if (iter == NameValues.end()){
747 NameSuffix = iter->second;
753 // Add the name token data.
755 if (!PropertyTokens.IsEmpty()){
757 NameTokens = PropertyTokens;
763 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
765 std::map<int, int> SplitPoints;
766 std::map<int, int> SplitLength;
768 int intPrevValue = 10;
771 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
775 PropertyType PropType = PROPERTY_NONE;
777 // Look for type before continuing.
779 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
783 std::map<int, wxString> *NicknamesList = NULL;
784 std::map<int, wxString> *NicknamesListType = NULL;
785 std::map<int, wxString> *NicknamesListLanguage = NULL;
786 std::map<int, wxString> *NicknamesListAltID = NULL;
787 std::map<int, wxString> *NicknamesListPID = NULL;
788 std::map<int, wxString> *NicknamesListTokens = NULL;
789 std::map<int, int> *NicknamesListPref = NULL;
793 NicknamesList = &GeneralNicknamesList;
794 NicknamesListType = &GeneralNicknamesListType;
795 NicknamesListLanguage = &GeneralNicknamesListLanguage;
796 NicknamesListAltID = &GeneralNicknamesListAltID;
797 NicknamesListPID = &GeneralNicknamesListPID;
798 NicknamesListTokens = &GeneralNicknamesListTokens;
799 NicknamesListPref = &GeneralNicknamesListPref;
802 NicknamesList = &HomeNicknamesList;
803 NicknamesListType = &HomeNicknamesListType;
804 NicknamesListLanguage = &HomeNicknamesListLanguage;
805 NicknamesListAltID = &HomeNicknamesListAltID;
806 NicknamesListPID = &HomeNicknamesListPID;
807 NicknamesListTokens = &HomeNicknamesListTokens;
808 NicknamesListPref = &HomeNicknamesListPref;
811 NicknamesList = &BusinessNicknamesList;
812 NicknamesListType = &BusinessNicknamesListType;
813 NicknamesListLanguage = &BusinessNicknamesListLanguage;
814 NicknamesListAltID = &BusinessNicknamesListAltID;
815 NicknamesListPID = &BusinessNicknamesListPID;
816 NicknamesListTokens = &BusinessNicknamesListTokens;
817 NicknamesListPref = &BusinessNicknamesListPref;
821 std::map<int, int>::iterator SLiter;
822 wxString PropertyData;
823 wxString PropertyName;
824 wxString PropertyValue;
825 wxString PropertyTokens;
826 bool FirstToken = TRUE;
828 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
829 intiter != SplitPoints.end(); ++intiter){
831 SLiter = SplitLength.find(intiter->first);
833 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
835 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
836 PropertyName = PropertyElement.GetNextToken();
837 PropertyValue = PropertyElement.GetNextToken();
839 intPrevValue = intiter->second;
841 CaptureString(&PropertyValue, FALSE);
843 if (PropertyName == wxT("ALTID")){
845 NicknamesListAltID->erase(*NicknameCount);
846 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
848 } else if (PropertyName == wxT("PID")){
850 NicknamesListPID->erase(*NicknameCount);
851 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
853 } else if (PropertyName == wxT("PREF")){
855 int PriorityNumber = 0;
856 bool ValidNumber = TRUE;
859 PriorityNumber = std::stoi(PropertyValue.ToStdString());
862 catch(std::invalid_argument &e){
866 if (ValidNumber == TRUE){
868 NicknamesListPref->erase(*NicknameCount);
869 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
873 } else if (PropertyName == wxT("LANGUAGE")){
875 NicknamesListLanguage->erase(*NicknameCount);
876 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
880 // Something else we don't know about so append
881 // to the tokens variable.
883 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
885 if (FirstToken == TRUE){
887 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
892 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
902 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
904 // Add the name token data.
906 if (!PropertyTokens.IsEmpty()){
908 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
914 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
916 std::map<int, int> SplitPoints;
917 std::map<int, int> SplitLength;
918 std::map<int, int>::iterator SLiter;
919 wxString PropertyData;
920 wxString PropertyName;
921 wxString PropertyValue;
922 wxString PropertyTokens;
923 bool FirstToken = TRUE;
924 int intPrevValue = 8;
926 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
930 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
931 intiter != SplitPoints.end(); ++intiter){
933 SLiter = SplitLength.find(intiter->first);
935 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
937 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
938 PropertyName = PropertyElement.GetNextToken();
939 PropertyValue = PropertyElement.GetNextToken();
941 intPrevValue = intiter->second;
943 // Process properties.
945 size_t intPropertyValueLen = PropertyValue.Len();
947 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
949 PropertyValue.Trim();
950 PropertyValue.RemoveLast();
954 if (PropertyValue.Mid(0, 1) == wxT("\"")){
956 PropertyValue.Remove(0, 1);
960 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
962 if (FirstToken == TRUE){
964 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
969 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
977 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
979 wxString GenderComponent;
981 if (GenderData.CountTokens() >= 2){
983 Gender = GenderData.GetNextToken();
984 GenderDetails = GenderData.GetString();
986 CaptureString(&GenderDetails, FALSE);
990 Gender = GenderData.GetNextToken();
994 if (!PropertyTokens.IsEmpty()){
996 GenderTokens = PropertyTokens;
1002 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1004 // Process date. Preserve the remainder in the string.
1006 std::map<int, int> SplitPoints;
1007 std::map<int, int> SplitLength;
1008 std::map<int, int>::iterator SLiter;
1009 wxString PropertyData;
1010 wxString PropertyName;
1011 wxString PropertyValue;
1012 wxString PropertyTokens;
1013 bool BirthdayText = FALSE;
1014 int intPrevValue = 6;
1016 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1020 // Look for type before continuing.
1022 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1023 intiter != SplitPoints.end(); ++intiter){
1025 SLiter = SplitLength.find(intiter->first);
1027 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1029 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1030 PropertyName = PropertyElement.GetNextToken();
1031 PropertyValue = PropertyElement.GetNextToken();
1033 intPrevValue = intiter->second;
1035 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1037 CaptureString(&PropertySeg2, FALSE);
1038 Birthday = PropertySeg2;
1039 BirthdayText = TRUE;
1045 // Setup blank lines for later on.
1048 bool FirstToken = TRUE;
1050 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1051 intiter != SplitPoints.end(); ++intiter){
1053 SLiter = SplitLength.find(intiter->first);
1055 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1057 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1058 PropertyName = PropertyElement.GetNextToken();
1059 PropertyValue = PropertyElement.GetNextToken();
1061 intPrevValue = intiter->second;
1063 // Process properties.
1065 CaptureString(&PropertyValue, FALSE);
1067 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1069 PropertyValue.Trim();
1070 PropertyValue.RemoveLast();
1074 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1076 PropertyValue.Remove(0, 1);
1080 if (PropertyName == wxT("ALTID")){
1082 BirthdayAltID = PropertyValue;
1084 } else if (PropertyName == wxT("CALSCALE")){
1086 BirthdayCalScale = PropertyValue;
1088 } else if (PropertyName != wxT("VALUE")) {
1090 // Something else we don't know about so append
1091 // to the tokens variable.
1093 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1095 if (FirstToken == TRUE){
1097 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1102 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1112 // Add the data to the variables and form.
1114 if (BirthdayText == FALSE){
1116 Birthday = PropertySeg2;
1120 if (!PropertyTokens.IsEmpty()){
1122 BirthdayTokens = PropertyTokens;
1128 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1130 // Process date. Preserve the remainder in the string.
1132 std::map<int, int> SplitPoints;
1133 std::map<int, int> SplitLength;
1134 std::map<int, int>::iterator SLiter;
1135 wxString PropertyData;
1136 wxString PropertyName;
1137 wxString PropertyValue;
1138 wxString PropertyTokens;
1139 bool AnniversaryText = FALSE;
1140 int intPrevValue = 13;
1142 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1146 // Look for type before continuing.
1148 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1149 intiter != SplitPoints.end(); ++intiter){
1151 SLiter = SplitLength.find(intiter->first);
1153 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1155 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1156 PropertyName = PropertyElement.GetNextToken();
1157 PropertyValue = PropertyElement.GetNextToken();
1159 intPrevValue = intiter->second;
1161 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1163 CaptureString(&PropertySeg2, FALSE);
1164 Anniversary = PropertySeg2;
1165 AnniversaryText = TRUE;
1171 // Setup blank lines for later on.
1174 bool FirstToken = TRUE;
1176 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1177 intiter != SplitPoints.end(); ++intiter){
1179 SLiter = SplitLength.find(intiter->first);
1181 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1183 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1184 PropertyName = PropertyElement.GetNextToken();
1185 PropertyValue = PropertyElement.GetNextToken();
1187 intPrevValue = intiter->second;
1189 // Process properties.
1191 CaptureString(&PropertyValue, FALSE);
1193 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1195 PropertyValue.Trim();
1196 PropertyValue.RemoveLast();
1200 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1202 PropertyValue.Remove(0, 1);
1206 if (PropertyName == wxT("ALTID")){
1208 AnniversaryAltID = PropertyValue;
1210 } else if (PropertyName == wxT("CALSCALE")){
1212 AnniversaryCalScale = PropertyValue;
1214 } else if (PropertyName != wxT("VALUE")) {
1216 // Something else we don't know about so append
1217 // to the tokens variable.
1219 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1221 if (FirstToken == TRUE){
1223 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1228 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1238 // Add the data to the variables and form.
1240 if (AnniversaryText == FALSE){
1242 Anniversary = PropertySeg2;
1246 if (!PropertyTokens.IsEmpty()){
1248 AnniversaryTokens = PropertyTokens;
1254 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1256 std::map<int, int> SplitPoints;
1257 std::map<int, int> SplitLength;
1259 int intPrevValue = 4;
1262 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1266 PropertyType PropType = PROPERTY_NONE;
1268 // Look for type before continuing.
1270 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1274 std::map<int, wxString> *TZList = NULL;
1275 std::map<int, wxString> *TZListType = NULL;
1276 std::map<int, wxString> *TZListMediatype = NULL;
1277 std::map<int, wxString> *TZListAltID = NULL;
1278 std::map<int, wxString> *TZListPID = NULL;
1279 std::map<int, wxString> *TZListTokens = NULL;
1280 std::map<int, int> *TZListPref = NULL;
1284 TZList = &GeneralTZList;
1285 TZListType = &GeneralTZListType;
1286 TZListMediatype = &GeneralTZListMediatype;
1287 TZListAltID = &GeneralTZListAltID;
1288 TZListPID = &GeneralTZListPID;
1289 TZListTokens = &GeneralTZListTokens;
1290 TZListPref = &GeneralTZListPref;
1293 TZList = &HomeTZList;
1294 TZListType = &HomeTZListType;
1295 TZListMediatype = &HomeTZListMediatype;
1296 TZListAltID = &HomeTZListAltID;
1297 TZListPID = &HomeTZListPID;
1298 TZListTokens = &HomeTZListTokens;
1299 TZListPref = &HomeTZListPref;
1302 TZList = &BusinessTZList;
1303 TZListType = &BusinessTZListType;
1304 TZListMediatype = &BusinessTZListMediatype;
1305 TZListAltID = &BusinessTZListAltID;
1306 TZListPID = &BusinessTZListPID;
1307 TZListTokens = &BusinessTZListTokens;
1308 TZListPref = &BusinessTZListPref;
1312 std::map<int, int>::iterator SLiter;
1313 wxString PropertyData;
1314 wxString PropertyName;
1315 wxString PropertyValue;
1316 wxString PropertyTokens;
1317 bool FirstToken = TRUE;
1319 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1320 intiter != SplitPoints.end(); ++intiter){
1322 SLiter = SplitLength.find(intiter->first);
1324 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1326 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1327 PropertyName = PropertyElement.GetNextToken();
1328 PropertyValue = PropertyElement.GetNextToken();
1330 intPrevValue = intiter->second;
1332 CaptureString(&PropertyValue, FALSE);
1334 if (PropertyName == wxT("ALTID")){
1336 TZListAltID->erase(*TimeZoneCount);
1337 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1339 } else if (PropertyName == wxT("PID")){
1341 TZListPID->erase(*TimeZoneCount);
1342 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1344 } else if (PropertyName == wxT("PREF")){
1346 int PriorityNumber = 0;
1347 bool ValidNumber = TRUE;
1350 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1353 catch(std::invalid_argument &e){
1354 ValidNumber = FALSE;
1357 if (ValidNumber == TRUE){
1359 TZListPref->erase(*TimeZoneCount);
1360 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1364 } else if (PropertyName == wxT("MEDIATYPE")){
1366 TZListMediatype->erase(*TimeZoneCount);
1367 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1371 // Something else we don't know about so append
1372 // to the tokens variable.
1374 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1376 if (FirstToken == TRUE){
1378 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1383 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1393 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1395 // Add the name token data.
1397 if (!PropertyTokens.IsEmpty()){
1399 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1406 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1408 size_t intPropertyLen = PropertySeg1.Len();
1409 std::map<int, int> SplitPoints;
1410 std::map<int, int> SplitLength;
1411 std::map<int, int>::iterator SLiter;
1412 wxString PropertyData;
1413 wxString PropertyName;
1414 wxString PropertyValue;
1415 wxString PropertyTokens;
1416 wxString AddressLabel;
1417 wxString AddressLang;
1418 wxString AddressAltID;
1419 wxString AddressPID;
1420 wxString AddressTokens;
1421 wxString AddressGeo;
1422 wxString AddressTimezone;
1423 wxString AddressType;
1424 wxString AddressMediatype;
1425 wxString AddressPOBox;
1426 wxString AddressExtended;
1427 wxString AddressStreet;
1428 wxString AddressLocality;
1429 wxString AddressCity;
1430 wxString AddressRegion;
1431 wxString AddressPostalCode;
1432 wxString AddressCountry;
1433 bool FirstToken = TRUE;
1434 int intSplitsFound = 0;
1435 int intSplitSize = 0;
1436 int intPrevValue = 5;
1441 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1445 PropertyType PropType = PROPERTY_NONE;
1447 // Look for type before continuing.
1449 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1453 std::map<int, wxString> *AddressList = NULL;
1454 std::map<int, wxString> *AddressListTown = NULL;
1455 std::map<int, wxString> *AddressListCounty = NULL;
1456 std::map<int, wxString> *AddressListPostCode = NULL;
1457 std::map<int, wxString> *AddressListCountry = NULL;
1458 std::map<int, wxString> *AddressListLabel = NULL;
1459 std::map<int, wxString> *AddressListLang = NULL;
1460 std::map<int, wxString> *AddressListAltID = NULL;
1461 std::map<int, wxString> *AddressListPID = NULL;
1462 std::map<int, wxString> *AddressListTokens = NULL;
1463 std::map<int, wxString> *AddressListGeo = NULL;
1464 std::map<int, wxString> *AddressListTimezone = NULL;
1465 std::map<int, wxString> *AddressListType = NULL;
1466 std::map<int, wxString> *AddressListMediatype = NULL;
1467 std::map<int, int> *AddressListPref = NULL;
1471 AddressList = &GeneralAddressList;
1472 AddressListTown = &GeneralAddressListTown;
1473 AddressListCounty = &GeneralAddressListCounty;
1474 AddressListPostCode = &GeneralAddressListPostCode;
1475 AddressListCountry = &GeneralAddressListCountry;
1476 AddressListLabel = &GeneralAddressListLabel;
1477 AddressListLang = &GeneralAddressListLang;
1478 AddressListAltID = &GeneralAddressListAltID;
1479 AddressListPID = &GeneralAddressListPID;
1480 AddressListTokens = &GeneralAddressListTokens;
1481 AddressListGeo = &GeneralAddressListGeo;
1482 AddressListTimezone = &GeneralAddressListTimezone;
1483 AddressListType = &GeneralAddressListType;
1484 AddressListMediatype = &GeneralAddressListMediatype;
1485 AddressListPref = &GeneralAddressListPref;
1488 AddressList = &HomeAddressList;
1489 AddressListTown = &HomeAddressListTown;
1490 AddressListCounty = &HomeAddressListCounty;
1491 AddressListPostCode = &HomeAddressListPostCode;
1492 AddressListCountry = &HomeAddressListCountry;
1493 AddressListLabel = &HomeAddressListLabel;
1494 AddressListLang = &HomeAddressListLang;
1495 AddressListAltID = &HomeAddressListAltID;
1496 AddressListPID = &HomeAddressListPID;
1497 AddressListTokens = &HomeAddressListTokens;
1498 AddressListGeo = &HomeAddressListGeo;
1499 AddressListTimezone = &HomeAddressListTimezone;
1500 AddressListType = &HomeAddressListType;
1501 AddressListMediatype = &HomeAddressListMediatype;
1502 AddressListPref = &HomeAddressListPref;
1505 AddressList = &BusinessAddressList;
1506 AddressListTown = &BusinessAddressListTown;
1507 AddressListCounty = &BusinessAddressListCounty;
1508 AddressListPostCode = &BusinessAddressListPostCode;
1509 AddressListCountry = &BusinessAddressListCountry;
1510 AddressListLabel = &BusinessAddressListLabel;
1511 AddressListLang = &BusinessAddressListLang;
1512 AddressListAltID = &BusinessAddressListAltID;
1513 AddressListPID = &BusinessAddressListPID;
1514 AddressListTokens = &BusinessAddressListTokens;
1515 AddressListGeo = &BusinessAddressListGeo;
1516 AddressListTimezone = &BusinessAddressListTimezone;
1517 AddressListType = &BusinessAddressListType;
1518 AddressListMediatype = &BusinessAddressListMediatype;
1519 AddressListPref = &BusinessAddressListPref;
1525 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1526 intiter != SplitPoints.end(); ++intiter){
1528 SLiter = SplitLength.find(intiter->first);
1530 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1532 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1533 PropertyName = PropertyElement.GetNextToken();
1534 PropertyValue = PropertyElement.GetNextToken();
1536 intPrevValue = intiter->second;
1538 CaptureString(&PropertyValue, FALSE);
1540 // Process properties.
1542 if (PropertyName == wxT("LABEL")){
1544 AddressListLabel->erase(*AddressCount);
1545 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1547 } else if (PropertyName == wxT("LANGUAGE")){
1549 AddressListLang->erase(*AddressCount);
1550 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1552 } else if (PropertyName == wxT("ALTID")){
1554 AddressListAltID->erase(*AddressCount);
1555 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1557 } else if (PropertyName == wxT("PID")){
1559 AddressListPID->erase(*AddressCount);
1560 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1562 } else if (PropertyName == wxT("GEO")){
1564 AddressListGeo->erase(*AddressCount);
1565 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1567 } else if (PropertyName == wxT("TZ")){
1569 AddressListTimezone->erase(*AddressCount);
1570 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1572 } else if (PropertyName == wxT("MEDIATYPE")){
1574 AddressListMediatype->erase(*AddressCount);
1575 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1577 } else if (PropertyName == wxT("PREF")){
1579 int PriorityNumber = 0;
1580 bool ValidNumber = TRUE;
1583 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1586 catch(std::invalid_argument &e){
1587 ValidNumber = FALSE;
1590 if (ValidNumber == TRUE){
1592 AddressListPref->erase(*AddressCount);
1593 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1599 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1601 if (FirstToken == TRUE){
1603 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1608 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1618 // Split the address.
1620 //std::map<int, int>::iterator SLiter;
1621 intPropertyLen = PropertySeg2.Len();
1622 SplitPoints.clear();
1623 SplitLength.clear();
1628 for (int i = 0; i <= intPropertyLen; i++){
1632 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1635 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1637 if (intSplitsFound == 6){
1639 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1644 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1654 // Split the data into several parts.
1656 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1657 intiter != SplitPoints.end(); ++intiter){
1659 if (intiter->first == 1){
1661 // Deal with PO Box.
1663 SLiter = SplitLength.find(1);
1665 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1666 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1667 intPrevValue = intiter->second;
1669 } else if (intiter->first == 2){
1671 // Deal with extended address.
1673 SLiter = SplitLength.find(2);
1675 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1676 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1677 intPrevValue = intiter->second;
1679 } else if (intiter->first == 3){
1681 // Deal with street address.
1683 SLiter = SplitLength.find(3);
1685 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1686 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1687 intPrevValue = intiter->second;
1689 } else if (intiter->first == 4){
1691 // Deal with locality
1693 SLiter = SplitLength.find(4);
1695 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1696 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1697 intPrevValue = intiter->second;
1699 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1701 } else if (intiter->first == 5){
1703 // Deal with region.
1705 SLiter = SplitLength.find(5);
1707 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1708 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1709 intPrevValue = intiter->second;
1711 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1713 } else if (intiter->first == 6){
1715 // Deal with post code.
1717 SLiter = SplitLength.find(6);
1719 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1720 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1721 intPrevValue = intiter->second;
1723 // Deal with country.
1725 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1726 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1734 // Add the data to the General/Home/Work address variables.
1736 CaptureString(&AddressStreet, FALSE);
1737 CaptureString(&AddressLocality, FALSE);
1738 CaptureString(&AddressRegion, FALSE);
1739 CaptureString(&AddressPostalCode, FALSE);
1740 CaptureString(&AddressCountry, FALSE);
1742 if (!PropertyTokens.IsEmpty()){
1744 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1748 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1749 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1750 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1751 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1752 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1756 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1759 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1762 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1766 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1770 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1772 std::map<int, int> SplitPoints;
1773 std::map<int, int> SplitLength;
1775 int intPrevValue = 7;
1778 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1782 PropertyType PropType = PROPERTY_NONE;
1784 // Look for type before continuing.
1786 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1788 std::map<int, wxString> *EmailList = NULL;
1789 std::map<int, wxString> *EmailListType = NULL;
1790 std::map<int, wxString> *EmailListAltID = NULL;
1791 std::map<int, wxString> *EmailListPID = NULL;
1792 std::map<int, wxString> *EmailListTokens = NULL;
1793 std::map<int, int> *EmailListPref = NULL;
1797 EmailList = &GeneralEmailList;
1798 EmailListType = &GeneralEmailListType;
1799 EmailListAltID = &GeneralEmailListAltID;
1800 EmailListPID = &GeneralEmailListPID;
1801 EmailListTokens = &GeneralEmailListTokens;
1802 EmailListPref = &GeneralEmailListPref;
1805 EmailList = &HomeEmailList;
1806 EmailListType = &HomeEmailListType;
1807 EmailListAltID = &HomeEmailListAltID;
1808 EmailListPID = &HomeEmailListPID;
1809 EmailListTokens = &HomeEmailListTokens;
1810 EmailListPref = &HomeEmailListPref;
1813 EmailList = &BusinessEmailList;
1814 EmailListType = &BusinessEmailListType;
1815 EmailListAltID = &BusinessEmailListAltID;
1816 EmailListPID = &BusinessEmailListPID;
1817 EmailListTokens = &BusinessEmailListTokens;
1818 EmailListPref = &BusinessEmailListPref;
1824 std::map<int,int>::iterator SLiter;
1825 wxString PropertyData;
1826 wxString PropertyName;
1827 wxString PropertyValue;
1828 wxString PropertyTokens;
1829 bool FirstToken = TRUE;
1831 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1832 intiter != SplitPoints.end(); ++intiter){
1834 SLiter = SplitLength.find(intiter->first);
1836 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1838 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1839 PropertyName = PropertyElement.GetNextToken();
1840 PropertyValue = PropertyElement.GetNextToken();
1842 intPrevValue = intiter->second;
1844 CaptureString(&PropertyValue, FALSE);
1846 // Process properties.
1848 if (PropertyName == wxT("ALTID")){
1850 EmailListAltID->erase(*EmailCount);
1851 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1853 } else if (PropertyName == wxT("PID")){
1855 EmailListPID->erase(*EmailCount);
1856 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1858 } else if (PropertyName == wxT("PREF")){
1860 int PriorityNumber = 0;
1861 bool ValidNumber = TRUE;
1864 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1867 catch(std::invalid_argument &e){
1868 ValidNumber = FALSE;
1871 if (ValidNumber == TRUE){
1873 EmailListPref->erase(*EmailCount);
1874 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1880 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1882 if (FirstToken == TRUE){
1884 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1889 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1899 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1901 // Add the name token data.
1903 if (!PropertyTokens.IsEmpty()){
1905 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1912 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1914 std::map<int, int> SplitPoints;
1915 std::map<int, int> SplitLength;
1917 int intPrevValue = 6;
1920 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1924 PropertyType PropType = PROPERTY_NONE;
1926 // Look for type before continuing.
1928 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1930 std::map<int, wxString> *IMList = NULL;
1931 std::map<int, wxString> *IMListType = NULL;
1932 std::map<int, wxString> *IMListAltID = NULL;
1933 std::map<int, wxString> *IMListPID = NULL;
1934 std::map<int, wxString> *IMListTokens = NULL;
1935 std::map<int, wxString> *IMListMediatype = NULL;
1936 std::map<int, int> *IMListPref = NULL;
1940 IMList = &GeneralIMList;
1941 IMListType = &GeneralIMListType;
1942 IMListAltID = &GeneralIMListAltID;
1943 IMListPID = &GeneralIMListPID;
1944 IMListTokens = &GeneralIMListTokens;
1945 IMListMediatype = &GeneralIMListMediatype;
1946 IMListPref = &GeneralIMListPref;
1949 IMList = &HomeIMList;
1950 IMListType = &HomeIMListType;
1951 IMListAltID = &HomeIMListAltID;
1952 IMListPID = &HomeIMListPID;
1953 IMListTokens = &HomeIMListTokens;
1954 IMListMediatype = &HomeIMListMediatype;
1955 IMListPref = &HomeIMListPref;
1958 IMList = &BusinessIMList;
1959 IMListType = &BusinessIMListType;
1960 IMListAltID = &BusinessIMListAltID;
1961 IMListPID = &BusinessIMListPID;
1962 IMListTokens = &BusinessIMListTokens;
1963 IMListMediatype = &BusinessIMListMediatype;
1964 IMListPref = &BusinessIMListPref;
1970 std::map<int,int>::iterator SLiter;
1971 wxString PropertyData;
1972 wxString PropertyName;
1973 wxString PropertyValue;
1974 wxString PropertyTokens;
1975 bool FirstToken = TRUE;
1977 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1978 intiter != SplitPoints.end(); ++intiter){
1980 SLiter = SplitLength.find(intiter->first);
1982 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1984 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1985 PropertyName = PropertyElement.GetNextToken();
1986 PropertyValue = PropertyElement.GetNextToken();
1988 intPrevValue = intiter->second;
1990 CaptureString(&PropertyValue, FALSE);
1992 // Process properties.
1994 if (PropertyName == wxT("ALTID")){
1996 IMListAltID->erase(*IMCount);
1997 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1999 } else if (PropertyName == wxT("PID")){
2001 IMListPID->erase(*IMCount);
2002 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2004 } else if (PropertyName == wxT("MEDIATYPE")){
2006 IMListMediatype->erase(*IMCount);
2007 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2009 } else if (PropertyName == wxT("PREF")){
2011 int PriorityNumber = 0;
2012 bool ValidNumber = TRUE;
2015 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2018 catch(std::invalid_argument &e){
2019 ValidNumber = FALSE;
2022 if (ValidNumber == TRUE){
2024 IMListPref->erase(*IMCount);
2025 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2031 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2033 if (FirstToken == TRUE){
2035 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2040 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2050 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2052 // Add the name token data.
2054 if (!PropertyTokens.IsEmpty()){
2056 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2062 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2064 std::map<int, int> SplitPoints;
2065 std::map<int, int> SplitLength;
2066 std::map<int, int>::iterator SLiter;
2070 PropertyType PropType = PROPERTY_NONE;
2072 // Look for type before continuing.
2075 wxString TelTypeDetail;
2076 wxString PropertyData;
2077 wxString PropertyName;
2078 wxString PropertyValue;
2079 wxString PropertyTokens;
2081 std::map<int,int> TypeSplitPoints;
2082 std::map<int,int> TypeSplitLength;
2083 std::map<int,int>::iterator TSLiter;
2085 int intSplitSize = 0;
2086 int intSplitsFound = 0;
2087 int intSplitPoint = 0;
2089 int intPrevValue = 5;
2091 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2095 // Look for type before continuing.
2097 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2098 intiter != SplitPoints.end(); ++intiter){
2100 SLiter = SplitLength.find(intiter->first);
2102 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2104 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2105 PropertyName = PropertyElement.GetNextToken();
2106 PropertyValue = PropertyElement.GetNextToken();
2108 intPrevValue = intiter->second;
2110 if (PropertyName == wxT("TYPE")){
2112 // Process each value in type and translate each
2115 // Strip out the quotes if they are there.
2117 size_t intPropertyValueLen = PropertyValue.Len();
2119 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2121 PropertyValue.Trim();
2122 PropertyValue.RemoveLast();
2126 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2128 PropertyValue.Remove(0, 1);
2132 TelTypeDetail = PropertyValue;
2138 for (int i = 0; i <= intPropertyValueLen; i++){
2142 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2144 if (intSplitsFound == 0){
2146 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2147 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2151 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2152 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2165 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2166 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2168 int intTypeSeek = 0;
2170 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2171 typeiter != TypeSplitPoints.end(); ++typeiter){
2173 wxString TypePropertyName;
2175 TSLiter = TypeSplitLength.find(typeiter->first);
2177 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2179 if (intTypeSeek == 0){
2184 TelTypeUI.Append(wxT(","));
2188 if (TypePropertyName == wxT("home")){
2190 PropType = PROPERTY_HOME;
2192 } else if (TypePropertyName == wxT("work")){
2194 PropType = PROPERTY_WORK;
2199 if (TypePropertyName == wxT("text")){
2201 TelTypeUI.Append(_("text"));
2204 } else if (TypePropertyName == wxT("voice")){
2206 TelTypeUI.Append(_("voice"));
2209 } else if (TypePropertyName == wxT("fax")){
2211 TelTypeUI.Append(_("fax"));
2214 } else if (TypePropertyName == wxT("cell")){
2216 TelTypeUI.Append(_("mobile"));
2219 } else if (TypePropertyName == wxT("video")){
2221 TelTypeUI.Append(_("video"));
2224 } else if (TypePropertyName == wxT("pager")){
2226 TelTypeUI.Append(_("pager"));
2229 } else if (TypePropertyName == wxT("textphone")){
2231 TelTypeUI.Append(_("textphone"));
2242 std::map<int, wxString> *TelephoneList = NULL;
2243 std::map<int, wxString> *TelephoneListType = NULL;
2244 std::map<int, wxString> *TelephoneListAltID = NULL;
2245 std::map<int, wxString> *TelephoneListPID = NULL;
2246 std::map<int, wxString> *TelephoneListTokens = NULL;
2247 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2248 std::map<int, int> *TelephoneListPref = NULL;
2252 TelephoneList = &GeneralTelephoneList;
2253 TelephoneListType = &GeneralTelephoneListType;
2254 TelephoneListAltID = &GeneralTelephoneListAltID;
2255 TelephoneListPID = &GeneralTelephoneListPID;
2256 TelephoneListTokens = &GeneralTelephoneListTokens;
2257 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2258 TelephoneListPref = &GeneralTelephoneListPref;
2261 TelephoneList = &HomeTelephoneList;
2262 TelephoneListType = &HomeTelephoneListType;
2263 TelephoneListAltID = &HomeTelephoneListAltID;
2264 TelephoneListPID = &HomeTelephoneListPID;
2265 TelephoneListTokens = &HomeTelephoneListTokens;
2266 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2267 TelephoneListPref = &HomeTelephoneListPref;
2270 TelephoneList = &BusinessTelephoneList;
2271 TelephoneListType = &BusinessTelephoneListType;
2272 TelephoneListAltID = &BusinessTelephoneListAltID;
2273 TelephoneListPID = &BusinessTelephoneListPID;
2274 TelephoneListTokens = &BusinessTelephoneListTokens;
2275 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2276 TelephoneListPref = &BusinessTelephoneListPref;
2280 // Process the properties.
2282 bool FirstToken = TRUE;
2285 SplitPoints.clear();
2286 SplitLength.clear();
2288 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2292 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2293 intiter != SplitPoints.end(); ++intiter){
2295 SLiter = SplitLength.find(intiter->first);
2297 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2299 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2300 PropertyName = PropertyElement.GetNextToken();
2301 PropertyValue = PropertyElement.GetNextToken();
2303 intPrevValue = intiter->second;
2305 CaptureString(&PropertyValue, FALSE);
2307 // Process properties.
2309 if (PropertyName == wxT("ALTID")){
2311 TelephoneListAltID->erase(*TelephoneCount);
2312 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2314 } else if (PropertyName == wxT("PID")){
2316 TelephoneListPID->erase(*TelephoneCount);
2317 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2319 } else if (PropertyName == wxT("PREF")){
2321 int PriorityNumber = 0;
2322 bool ValidNumber = TRUE;
2325 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2328 catch(std::invalid_argument &e){
2329 ValidNumber = FALSE;
2332 if (ValidNumber == TRUE){
2334 TelephoneListPref->erase(*TelephoneCount);
2335 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2341 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2343 if (FirstToken == TRUE){
2345 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2350 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2360 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2361 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2363 // Add the name token data.
2365 if (!PropertyTokens.IsEmpty()){
2367 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2373 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2375 std::map<int, int> SplitPoints;
2376 std::map<int, int> SplitLength;
2378 int intPrevValue = 6;
2381 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2385 PropertyType PropType = PROPERTY_NONE;
2387 // Look for type before continuing.
2389 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2391 std::map<int, wxString> *LanguageList = NULL;
2392 std::map<int, wxString> *LanguageListType = NULL;
2393 std::map<int, wxString> *LanguageListAltID = NULL;
2394 std::map<int, wxString> *LanguageListPID = NULL;
2395 std::map<int, wxString> *LanguageListTokens = NULL;
2396 std::map<int, int> *LanguageListPref = NULL;
2400 LanguageList = &GeneralLanguageList;
2401 LanguageListType = &GeneralLanguageListType;
2402 LanguageListAltID = &GeneralLanguageListAltID;
2403 LanguageListPID = &GeneralLanguageListPID;
2404 LanguageListTokens = &GeneralLanguageListTokens;
2405 LanguageListPref = &GeneralLanguageListPref;
2408 LanguageList = &HomeLanguageList;
2409 LanguageListType = &HomeLanguageListType;
2410 LanguageListAltID = &HomeLanguageListAltID;
2411 LanguageListPID = &HomeLanguageListPID;
2412 LanguageListTokens = &HomeLanguageListTokens;
2413 LanguageListPref = &HomeLanguageListPref;
2416 LanguageList = &BusinessLanguageList;
2417 LanguageListType = &BusinessLanguageListType;
2418 LanguageListAltID = &BusinessLanguageListAltID;
2419 LanguageListPID = &BusinessLanguageListPID;
2420 LanguageListTokens = &BusinessLanguageListTokens;
2421 LanguageListPref = &BusinessLanguageListPref;
2427 std::map<int,int>::iterator SLiter;
2428 wxString PropertyData;
2429 wxString PropertyName;
2430 wxString PropertyValue;
2431 wxString PropertyTokens;
2432 bool FirstToken = TRUE;
2434 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2435 intiter != SplitPoints.end(); ++intiter){
2437 SLiter = SplitLength.find(intiter->first);
2439 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2441 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2442 PropertyName = PropertyElement.GetNextToken();
2443 PropertyValue = PropertyElement.GetNextToken();
2445 intPrevValue = intiter->second;
2447 CaptureString(&PropertyValue, FALSE);
2449 // Process properties.
2451 if (PropertyName == wxT("ALTID")){
2453 LanguageListAltID->erase(*LanguageCount);
2454 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2456 } else if (PropertyName == wxT("PID")){
2458 LanguageListPID->erase(*LanguageCount);
2459 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2461 } else if (PropertyName == wxT("PREF")){
2463 int PriorityNumber = 0;
2464 bool ValidNumber = TRUE;
2467 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2470 catch(std::invalid_argument &e){
2471 ValidNumber = FALSE;
2474 if (ValidNumber == TRUE){
2476 LanguageListPref->erase(*LanguageCount);
2477 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2483 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2485 if (FirstToken == TRUE){
2487 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2492 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2502 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2504 // Add the name token data.
2506 if (!PropertyTokens.IsEmpty()){
2508 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2514 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2516 std::map<int, int> SplitPoints;
2517 std::map<int, int> SplitLength;
2519 int intPrevValue = 5;
2522 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2526 PropertyType PropType = PROPERTY_NONE;
2528 // Look for type before continuing.
2530 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2532 std::map<int, wxString> *GeopositionList = NULL;
2533 std::map<int, wxString> *GeopositionListType = NULL;
2534 std::map<int, wxString> *GeopositionListAltID = NULL;
2535 std::map<int, wxString> *GeopositionListPID = NULL;
2536 std::map<int, wxString> *GeopositionListTokens = NULL;
2537 std::map<int, wxString> *GeopositionListMediatype = NULL;
2538 std::map<int, int> *GeopositionListPref = NULL;
2542 GeopositionList = &GeneralGeographyList;
2543 GeopositionListType = &GeneralGeographyListType;
2544 GeopositionListAltID = &GeneralGeographyListAltID;
2545 GeopositionListPID = &GeneralGeographyListPID;
2546 GeopositionListTokens = &GeneralGeographyListTokens;
2547 GeopositionListMediatype = &GeneralGeographyListMediatype;
2548 GeopositionListPref = &GeneralGeographyListPref;
2551 GeopositionList = &HomeGeographyList;
2552 GeopositionListType = &HomeGeographyListType;
2553 GeopositionListAltID = &HomeGeographyListAltID;
2554 GeopositionListPID = &HomeGeographyListPID;
2555 GeopositionListTokens = &HomeGeographyListTokens;
2556 GeopositionListMediatype = &HomeGeographyListMediatype;
2557 GeopositionListPref = &HomeGeographyListPref;
2560 GeopositionList = &BusinessGeographyList;
2561 GeopositionListType = &BusinessGeographyListType;
2562 GeopositionListAltID = &BusinessGeographyListAltID;
2563 GeopositionListPID = &BusinessGeographyListPID;
2564 GeopositionListTokens = &BusinessGeographyListTokens;
2565 GeopositionListMediatype = &BusinessGeographyListMediatype;
2566 GeopositionListPref = &BusinessGeographyListPref;
2572 std::map<int,int>::iterator SLiter;
2573 wxString PropertyData;
2574 wxString PropertyName;
2575 wxString PropertyValue;
2576 wxString PropertyTokens;
2577 bool FirstToken = TRUE;
2579 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2580 intiter != SplitPoints.end(); ++intiter){
2582 SLiter = SplitLength.find(intiter->first);
2584 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2586 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2587 PropertyName = PropertyElement.GetNextToken();
2588 PropertyValue = PropertyElement.GetNextToken();
2590 intPrevValue = intiter->second;
2592 CaptureString(&PropertyValue, FALSE);
2594 // Process properties.
2596 if (PropertyName == wxT("ALTID")){
2598 GeopositionListAltID->erase(*GeographicCount);
2599 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2601 } else if (PropertyName == wxT("PID")){
2603 GeopositionListPID->erase(*GeographicCount);
2604 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2606 } else if (PropertyName == wxT("MEDIATYPE")){
2608 GeopositionListMediatype->erase(*GeographicCount);
2609 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2611 } else if (PropertyName == wxT("PREF")){
2613 int PriorityNumber = 0;
2614 bool ValidNumber = TRUE;
2617 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2620 catch(std::invalid_argument &e){
2621 ValidNumber = FALSE;
2624 if (ValidNumber == TRUE){
2626 GeopositionListPref->erase(*GeographicCount);
2627 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2633 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2635 if (FirstToken == TRUE){
2637 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2642 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2652 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2654 // Add the name token data.
2656 if (!PropertyTokens.IsEmpty()){
2658 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2664 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2666 size_t intPropertyLen = PropertySeg1.Len();
2667 std::map<int, int> SplitPoints;
2668 std::map<int, int> SplitLength;
2669 std::map<int, int>::iterator SLiter;
2670 wxString PropertyData;
2671 wxString PropertyName;
2672 wxString PropertyValue;
2673 wxString PropertyTokens;
2674 wxString RelatedType;
2675 wxString RelatedTypeOriginal;
2676 wxString RelatedName;
2677 bool FirstToken = TRUE;
2678 int intSplitsFound = 0;
2679 int intSplitSize = 0;
2680 int intPrevValue = 9;
2684 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2688 // Look for type before continuing.
2690 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2691 intiter != SplitPoints.end(); ++intiter){
2693 SLiter = SplitLength.find(intiter->first);
2695 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2697 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2698 PropertyName = PropertyElement.GetNextToken();
2699 PropertyValue = PropertyElement.GetNextToken();
2701 intPrevValue = intiter->second;
2705 RelatedTypeOriginal = PropertyValue;
2707 if (PropertyName == wxT("TYPE")){
2709 if (PropertyValue == wxT("contact")){
2711 RelatedType = _("Contact");
2713 } else if (PropertyValue == wxT("acquaintance")){
2715 RelatedType = _("Acquaintance");
2717 } else if (PropertyValue == wxT("friend")){
2719 RelatedType = _("Friend");
2721 } else if (PropertyValue == wxT("met")){
2723 RelatedType = _("Met");
2725 } else if (PropertyValue == wxT("co-worker")){
2727 RelatedType = _("Co-worker");
2729 } else if (PropertyValue == wxT("colleague")){
2731 RelatedType = _("Colleague");
2733 } else if (PropertyValue == wxT("co-resident")){
2735 RelatedType = _("Co-resident");
2737 } else if (PropertyValue == wxT("neighbor")){
2739 RelatedType = _("Neighbour");
2741 } else if (PropertyValue == wxT("child")){
2743 RelatedType = _("Child");
2745 } else if (PropertyValue == wxT("parent")){
2747 RelatedType = _("Parent");
2749 } else if (PropertyValue == wxT("sibling")){
2751 RelatedType = _("Sibling");
2753 } else if (PropertyValue == wxT("spouse")){
2755 RelatedType = _("Spouse");
2757 } else if (PropertyValue == wxT("kin")){
2759 RelatedType = _("Kin");
2761 } else if (PropertyValue == wxT("muse")){
2763 RelatedType = _("Muse");
2765 } else if (PropertyValue == wxT("crush")){
2767 RelatedType = _("Crush");
2769 } else if (PropertyValue == wxT("date")){
2771 RelatedType = _("Date");
2773 } else if (PropertyValue == wxT("sweetheart")){
2775 RelatedType = _("Sweetheart");
2777 } else if (PropertyValue == wxT("me")){
2779 RelatedType = _("Me");
2781 } else if (PropertyValue == wxT("agent")){
2783 RelatedType = _("Agent");
2785 } else if (PropertyValue == wxT("emergency")){
2787 RelatedType = _("Emergency");
2791 RelatedType = PropertyValue;
2801 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2802 intiter != SplitPoints.end(); ++intiter){
2804 SLiter = SplitLength.find(intiter->first);
2806 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2808 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2809 PropertyName = PropertyElement.GetNextToken();
2810 PropertyValue = PropertyElement.GetNextToken();
2812 intPrevValue = intiter->second;
2814 // Process properties.
2816 size_t intPropertyValueLen = PropertyValue.Len();
2818 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2820 PropertyValue.Trim();
2821 PropertyValue.RemoveLast();
2825 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2827 PropertyValue.Remove(0, 1);
2831 CaptureString(&PropertyValue, FALSE);
2833 if (PropertyName == wxT("ALTID")){
2835 GeneralRelatedListAltID.erase(*RelatedCount);
2836 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2838 } else if (PropertyName == wxT("PID")){
2840 GeneralRelatedListPID.erase(*RelatedCount);
2841 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2843 } else if (PropertyName == wxT("PREF")){
2845 int PriorityNumber = 0;
2846 bool ValidNumber = TRUE;
2849 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2852 catch(std::invalid_argument &e){
2853 ValidNumber = FALSE;
2856 if (ValidNumber == TRUE){
2858 GeneralRelatedListPref.erase(*RelatedCount);
2859 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2863 } else if (PropertyName == wxT("LANGUAGE")){
2865 GeneralRelatedListLanguage.erase(*RelatedCount);
2866 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2868 } else if (PropertyName != wxT("TYPE")) {
2870 // Something else we don't know about so append
2871 // to the tokens variable.
2873 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2875 if (FirstToken == TRUE){
2877 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2882 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2892 // Add the data to the General/Home/Work address variables.
2894 GeneralRelatedList.erase(*RelatedCount);
2895 GeneralRelatedListRelType.erase(*RelatedCount);
2896 GeneralRelatedListType.erase(*RelatedCount);
2897 GeneralRelatedListTokens.erase(*RelatedCount);
2898 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2899 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2900 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2901 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2905 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2907 std::map<int, int> SplitPoints;
2908 std::map<int, int> SplitLength;
2909 std::map<int, int>::iterator SLiter;
2910 wxString PropertyData;
2911 wxString PropertyName;
2912 wxString PropertyValue;
2913 wxString PropertyTokens;
2914 bool FirstToken = TRUE;
2915 int intPrevValue = 5;
2920 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2924 PropertyType PropType = PROPERTY_NONE;
2926 // Look for type before continuing.
2928 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2930 // Setup the pointers.
2932 std::map<int, wxString> *WebsiteList = NULL;
2933 std::map<int, wxString> *WebsiteListAltID = NULL;
2934 std::map<int, wxString> *WebsiteListPID = NULL;
2935 std::map<int, wxString> *WebsiteListType = NULL;
2936 std::map<int, wxString> *WebsiteListTokens = NULL;
2937 std::map<int, wxString> *WebsiteListMediatype = NULL;
2938 std::map<int, int> *WebsiteListPref = NULL;
2940 // Setup blank lines for later on.
2944 WebsiteList = &GeneralWebsiteList;
2945 WebsiteListType = &GeneralWebsiteListType;
2946 WebsiteListAltID = &GeneralWebsiteListAltID;
2947 WebsiteListPID = &GeneralWebsiteListPID;
2948 WebsiteListTokens = &GeneralWebsiteListTokens;
2949 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2950 WebsiteListPref = &GeneralWebsiteListPref;
2953 WebsiteList = &HomeWebsiteList;
2954 WebsiteListType = &HomeWebsiteListType;
2955 WebsiteListAltID = &HomeWebsiteListAltID;
2956 WebsiteListPID = &HomeWebsiteListPID;
2957 WebsiteListTokens = &HomeWebsiteListTokens;
2958 WebsiteListMediatype = &HomeWebsiteListMediatype;
2959 WebsiteListPref = &HomeWebsiteListPref;
2962 WebsiteList = &BusinessWebsiteList;
2963 WebsiteListType = &BusinessWebsiteListType;
2964 WebsiteListAltID = &BusinessWebsiteListAltID;
2965 WebsiteListPID = &BusinessWebsiteListPID;
2966 WebsiteListTokens = &BusinessWebsiteListTokens;
2967 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2968 WebsiteListPref = &BusinessWebsiteListPref;
2974 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2975 intiter != SplitPoints.end(); ++intiter){
2977 SLiter = SplitLength.find(intiter->first);
2979 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2981 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2982 PropertyName = PropertyElement.GetNextToken();
2983 PropertyValue = PropertyElement.GetNextToken();
2985 intPrevValue = intiter->second;
2987 // Process properties.
2989 size_t intPropertyValueLen = PropertyValue.Len();
2991 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2993 PropertyValue.Trim();
2994 PropertyValue.RemoveLast();
2998 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3000 PropertyValue.Remove(0, 1);
3004 CaptureString(&PropertyValue, FALSE);
3006 if (PropertyName == wxT("ALTID")){
3008 WebsiteListAltID->erase(*URLCount);
3009 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3011 } else if (PropertyName == wxT("PID")){
3013 WebsiteListPID->erase(*URLCount);
3014 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3016 } else if (PropertyName == wxT("PREF")){
3018 int PriorityNumber = 0;
3019 bool ValidNumber = TRUE;
3022 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3025 catch(std::invalid_argument &e){
3026 ValidNumber = FALSE;
3029 if (ValidNumber == TRUE){
3031 WebsiteListPref->erase(*URLCount);
3032 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3036 } else if (PropertyName == wxT("MEDIATYPE")){
3038 WebsiteListMediatype->erase(*URLCount);
3039 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3043 // Something else we don't know about so append
3044 // to the tokens variable.
3046 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3048 if (FirstToken == TRUE){
3050 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3055 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3065 // Add the data to the General/Home/Work address variables.
3067 CaptureString(&PropertySeg2, FALSE);
3069 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3071 if (!PropertyTokens.IsEmpty()){
3073 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3079 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3081 std::map<int, int> SplitPoints;
3082 std::map<int, int> SplitLength;
3083 std::map<int, int>::iterator SLiter;
3084 wxString PropertyData;
3085 wxString PropertyName;
3086 wxString PropertyValue;
3087 wxString PropertyTokens;
3088 bool FirstToken = TRUE;
3089 int intPrevValue = 7;
3094 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3098 PropertyType PropType = PROPERTY_NONE;
3100 // Look for type before continuing.
3102 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3104 // Setup the pointers.
3106 std::map<int, wxString> *TitleList = NULL;
3107 std::map<int, wxString> *TitleListAltID = NULL;
3108 std::map<int, wxString> *TitleListPID = NULL;
3109 std::map<int, wxString> *TitleListType = NULL;
3110 std::map<int, wxString> *TitleListTokens = NULL;
3111 std::map<int, wxString> *TitleListLanguage = NULL;
3112 std::map<int, int> *TitleListPref = NULL;
3114 // Setup blank lines for later on.
3118 TitleList = &GeneralTitleList;
3119 TitleListType = &GeneralTitleListType;
3120 TitleListAltID = &GeneralTitleListAltID;
3121 TitleListPID = &GeneralTitleListPID;
3122 TitleListTokens = &GeneralTitleListTokens;
3123 TitleListLanguage = &GeneralTitleListLanguage;
3124 TitleListPref = &GeneralTitleListPref;
3127 TitleList = &HomeTitleList;
3128 TitleListType = &HomeTitleListType;
3129 TitleListAltID = &HomeTitleListAltID;
3130 TitleListPID = &HomeTitleListPID;
3131 TitleListTokens = &HomeTitleListTokens;
3132 TitleListLanguage = &HomeTitleListLanguage;
3133 TitleListPref = &HomeTitleListPref;
3136 TitleList = &BusinessTitleList;
3137 TitleListType = &BusinessTitleListType;
3138 TitleListAltID = &BusinessTitleListAltID;
3139 TitleListPID = &BusinessTitleListPID;
3140 TitleListTokens = &BusinessTitleListTokens;
3141 TitleListLanguage = &BusinessTitleListLanguage;
3142 TitleListPref = &BusinessTitleListPref;
3148 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3149 intiter != SplitPoints.end(); ++intiter){
3151 SLiter = SplitLength.find(intiter->first);
3153 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3155 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3156 PropertyName = PropertyElement.GetNextToken();
3157 PropertyValue = PropertyElement.GetNextToken();
3159 intPrevValue = intiter->second;
3161 // Process properties.
3163 size_t intPropertyValueLen = PropertyValue.Len();
3165 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3167 PropertyValue.Trim();
3168 PropertyValue.RemoveLast();
3172 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3174 PropertyValue.Remove(0, 1);
3178 CaptureString(&PropertyValue, FALSE);
3180 if (PropertyName == wxT("ALTID")){
3182 TitleListAltID->erase(*TitleCount);
3183 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3185 } else if (PropertyName == wxT("PID")){
3187 TitleListPID->erase(*TitleCount);
3188 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3190 } else if (PropertyName == wxT("PREF")){
3192 int PriorityNumber = 0;
3193 bool ValidNumber = TRUE;
3196 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3199 catch(std::invalid_argument &e){
3200 ValidNumber = FALSE;
3203 if (ValidNumber == TRUE){
3205 TitleListPref->erase(*TitleCount);
3206 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3210 } else if (PropertyName == wxT("LANGUAGE")){
3212 TitleListLanguage->erase(*TitleCount);
3213 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3217 // Something else we don't know about so append
3218 // to the tokens variable.
3220 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3222 if (FirstToken == TRUE){
3224 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3229 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3239 // Add the data to the General/Home/Work address variables.
3241 CaptureString(&PropertySeg2, FALSE);
3243 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3245 if (!PropertyTokens.IsEmpty()){
3247 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3253 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3255 std::map<int, int> SplitPoints;
3256 std::map<int, int> SplitLength;
3257 std::map<int, int>::iterator SLiter;
3258 wxString PropertyData;
3259 wxString PropertyName;
3260 wxString PropertyValue;
3261 wxString PropertyTokens;
3262 bool FirstToken = TRUE;
3263 int intPrevValue = 6;
3268 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3272 PropertyType PropType = PROPERTY_NONE;
3274 // Look for type before continuing.
3276 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3278 // Setup the pointers.
3280 std::map<int, wxString> *RoleList = NULL;
3281 std::map<int, wxString> *RoleListAltID = NULL;
3282 std::map<int, wxString> *RoleListPID = NULL;
3283 std::map<int, wxString> *RoleListType = NULL;
3284 std::map<int, wxString> *RoleListTokens = NULL;
3285 std::map<int, wxString> *RoleListLanguage = NULL;
3286 std::map<int, int> *RoleListPref = NULL;
3288 // Setup blank lines for later on.
3292 RoleList = &GeneralRoleList;
3293 RoleListType = &GeneralRoleListType;
3294 RoleListAltID = &GeneralRoleListAltID;
3295 RoleListPID = &GeneralRoleListPID;
3296 RoleListTokens = &GeneralRoleListTokens;
3297 RoleListLanguage = &GeneralRoleListLanguage;
3298 RoleListPref = &GeneralRoleListPref;
3301 RoleList = &HomeRoleList;
3302 RoleListType = &HomeRoleListType;
3303 RoleListAltID = &HomeRoleListAltID;
3304 RoleListPID = &HomeRoleListPID;
3305 RoleListTokens = &HomeRoleListTokens;
3306 RoleListLanguage = &HomeRoleListLanguage;
3307 RoleListPref = &HomeRoleListPref;
3310 RoleList = &BusinessRoleList;
3311 RoleListType = &BusinessRoleListType;
3312 RoleListAltID = &BusinessRoleListAltID;
3313 RoleListPID = &BusinessRoleListPID;
3314 RoleListTokens = &BusinessRoleListTokens;
3315 RoleListLanguage = &BusinessRoleListLanguage;
3316 RoleListPref = &BusinessRoleListPref;
3322 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3323 intiter != SplitPoints.end(); ++intiter){
3325 SLiter = SplitLength.find(intiter->first);
3327 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3329 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3330 PropertyName = PropertyElement.GetNextToken();
3331 PropertyValue = PropertyElement.GetNextToken();
3333 intPrevValue = intiter->second;
3335 // Process properties.
3337 size_t intPropertyValueLen = PropertyValue.Len();
3339 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3341 PropertyValue.Trim();
3342 PropertyValue.RemoveLast();
3346 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3348 PropertyValue.Remove(0, 1);
3352 CaptureString(&PropertyValue, FALSE);
3354 if (PropertyName == wxT("ALTID")){
3356 RoleListAltID->erase(*RoleCount);
3357 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3359 } else if (PropertyName == wxT("PID")){
3361 RoleListPID->erase(*RoleCount);
3362 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3364 } else if (PropertyName == wxT("PREF")){
3366 int PriorityNumber = 0;
3367 bool ValidNumber = TRUE;
3370 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3373 catch(std::invalid_argument &e){
3374 ValidNumber = FALSE;
3377 if (ValidNumber == TRUE){
3379 RoleListPref->erase(*RoleCount);
3380 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3384 } else if (PropertyName == wxT("LANGUAGE")){
3386 RoleListLanguage->erase(*RoleCount);
3387 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3391 // Something else we don't know about so append
3392 // to the tokens variable.
3394 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3396 if (FirstToken == TRUE){
3398 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3403 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3413 // Add the data to the General/Home/Work address variables.
3415 CaptureString(&PropertySeg2, FALSE);
3417 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3419 if (!PropertyTokens.IsEmpty()){
3421 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3427 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3429 std::map<int, int> SplitPoints;
3430 std::map<int, int> SplitLength;
3431 std::map<int, int>::iterator SLiter;
3432 wxString PropertyData;
3433 wxString PropertyName;
3434 wxString PropertyValue;
3435 wxString PropertyTokens;
3436 bool FirstToken = TRUE;
3437 int intPrevValue = 5;
3442 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3446 PropertyType PropType = PROPERTY_NONE;
3448 // Look for type before continuing.
3450 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3452 // Setup the pointers.
3454 std::map<int, wxString> *OrganisationsList = NULL;
3455 std::map<int, wxString> *OrganisationsListAltID = NULL;
3456 std::map<int, wxString> *OrganisationsListPID = NULL;
3457 std::map<int, wxString> *OrganisationsListType = NULL;
3458 std::map<int, wxString> *OrganisationsListTokens = NULL;
3459 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3460 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3461 std::map<int, int> *OrganisationsListPref = NULL;
3463 // Setup blank lines for later on.
3467 OrganisationsList = &GeneralOrganisationsList;
3468 OrganisationsListType = &GeneralOrganisationsListType;
3469 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3470 OrganisationsListPID = &GeneralOrganisationsListPID;
3471 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3472 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3473 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3474 OrganisationsListPref = &GeneralOrganisationsListPref;
3477 OrganisationsList = &HomeOrganisationsList;
3478 OrganisationsListType = &HomeOrganisationsListType;
3479 OrganisationsListAltID = &HomeOrganisationsListAltID;
3480 OrganisationsListPID = &HomeOrganisationsListPID;
3481 OrganisationsListTokens = &HomeOrganisationsListTokens;
3482 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3483 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3484 OrganisationsListPref = &HomeOrganisationsListPref;
3487 OrganisationsList = &BusinessOrganisationsList;
3488 OrganisationsListType = &BusinessOrganisationsListType;
3489 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3490 OrganisationsListPID = &BusinessOrganisationsListPID;
3491 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3492 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3493 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3494 OrganisationsListPref = &BusinessOrganisationsListPref;
3500 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3501 intiter != SplitPoints.end(); ++intiter){
3503 SLiter = SplitLength.find(intiter->first);
3505 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3507 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3508 PropertyName = PropertyElement.GetNextToken();
3509 PropertyValue = PropertyElement.GetNextToken();
3511 intPrevValue = intiter->second;
3513 // Process properties.
3515 size_t intPropertyValueLen = PropertyValue.Len();
3517 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3519 PropertyValue.Trim();
3520 PropertyValue.RemoveLast();
3524 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3526 PropertyValue.Remove(0, 1);
3530 CaptureString(&PropertyValue, FALSE);
3532 if (PropertyName == wxT("ALTID")){
3534 OrganisationsListAltID->erase(*OrganisationCount);
3535 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3537 } else if (PropertyName == wxT("PID")){
3539 OrganisationsListPID->erase(*OrganisationCount);
3540 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3542 } else if (PropertyName == wxT("SORT-AS")){
3544 OrganisationsListSortAs->erase(*OrganisationCount);
3545 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3547 } else if (PropertyName == wxT("PREF")){
3549 int PriorityNumber = 0;
3550 bool ValidNumber = TRUE;
3553 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3556 catch(std::invalid_argument &e){
3557 ValidNumber = FALSE;
3560 if (ValidNumber == TRUE){
3562 OrganisationsListPref->erase(*OrganisationCount);
3563 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3567 } else if (PropertyName == wxT("LANGUAGE")){
3569 OrganisationsListLanguage->erase(*OrganisationCount);
3570 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3574 // Something else we don't know about so append
3575 // to the tokens variable.
3577 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3579 if (FirstToken == TRUE){
3581 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3586 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3596 // Add the data to the General/Home/Work address variables.
3598 CaptureString(&PropertySeg2, FALSE);
3600 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3602 if (!PropertyTokens.IsEmpty()){
3604 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3610 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3612 std::map<int, int> SplitPoints;
3613 std::map<int, int> SplitLength;
3614 std::map<int, int>::iterator SLiter;
3615 wxString PropertyData;
3616 wxString PropertyName;
3617 wxString PropertyValue;
3618 wxString PropertyTokens;
3619 bool FirstToken = TRUE;
3620 int intPrevValue = 6;
3625 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3629 PropertyType PropType = PROPERTY_NONE;
3631 // Look for type before continuing.
3633 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3635 // Setup the pointers.
3637 std::map<int, wxString> *NoteList = NULL;
3638 std::map<int, wxString> *NoteListAltID = NULL;
3639 std::map<int, wxString> *NoteListPID = NULL;
3640 std::map<int, wxString> *NoteListType = NULL;
3641 std::map<int, wxString> *NoteListTokens = NULL;
3642 std::map<int, wxString> *NoteListLanguage = NULL;
3643 std::map<int, int> *NoteListPref = NULL;
3645 // Setup blank lines for later on.
3649 NoteList = &GeneralNoteList;
3650 NoteListType = &GeneralNoteListType;
3651 NoteListAltID = &GeneralNoteListAltID;
3652 NoteListPID = &GeneralNoteListPID;
3653 NoteListTokens = &GeneralNoteListTokens;
3654 NoteListLanguage = &GeneralNoteListLanguage;
3655 NoteListPref = &GeneralNoteListPref;
3658 NoteList = &HomeNoteList;
3659 NoteListType = &HomeNoteListType;
3660 NoteListAltID = &HomeNoteListAltID;
3661 NoteListPID = &HomeNoteListPID;
3662 NoteListTokens = &HomeNoteListTokens;
3663 NoteListLanguage = &HomeNoteListLanguage;
3664 NoteListPref = &HomeNoteListPref;
3667 NoteList = &BusinessNoteList;
3668 NoteListType = &BusinessNoteListType;
3669 NoteListAltID = &BusinessNoteListAltID;
3670 NoteListPID = &BusinessNoteListPID;
3671 NoteListTokens = &BusinessNoteListTokens;
3672 NoteListLanguage = &BusinessNoteListLanguage;
3673 NoteListPref = &BusinessNoteListPref;
3679 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3680 intiter != SplitPoints.end(); ++intiter){
3682 SLiter = SplitLength.find(intiter->first);
3684 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3686 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3687 PropertyName = PropertyElement.GetNextToken();
3688 PropertyValue = PropertyElement.GetNextToken();
3690 intPrevValue = intiter->second;
3692 // Process properties.
3694 size_t intPropertyValueLen = PropertyValue.Len();
3696 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3698 PropertyValue.Trim();
3699 PropertyValue.RemoveLast();
3703 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3705 PropertyValue.Remove(0, 1);
3709 CaptureString(&PropertyValue, FALSE);
3711 if (PropertyName == wxT("ALTID")){
3713 NoteListAltID->erase(*NoteCount);
3714 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3716 } else if (PropertyName == wxT("PID")){
3718 NoteListPID->erase(*NoteCount);
3719 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3721 } else if (PropertyName == wxT("PREF")){
3723 int PriorityNumber = 0;
3724 bool ValidNumber = TRUE;
3727 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3730 catch(std::invalid_argument &e){
3731 ValidNumber = FALSE;
3734 if (ValidNumber == TRUE){
3736 NoteListPref->erase(*NoteCount);
3737 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3741 } else if (PropertyName == wxT("LANGUAGE")){
3743 NoteListLanguage->erase(*NoteCount);
3744 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3748 // Something else we don't know about so append
3749 // to the tokens variable.
3751 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3753 if (FirstToken == TRUE){
3755 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3760 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3770 // Add the data to the General/Home/Work address variables.
3772 CaptureString(&PropertySeg2, FALSE);
3774 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3776 if (!PropertyTokens.IsEmpty()){
3778 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3784 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3786 std::map<int, int> SplitPoints;
3787 std::map<int, int> SplitLength;
3788 std::map<int, int>::iterator SLiter;
3789 wxString PropertyData;
3790 wxString PropertyName;
3791 wxString PropertyValue;
3792 wxString PropertyTokens;
3793 bool FirstToken = TRUE;
3794 int intPrevValue = 12;
3799 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3803 PropertyType PropType = PROPERTY_NONE;
3805 // Look for type before continuing.
3807 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3809 // Setup blank lines for later on.
3815 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3818 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3824 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3825 intiter != SplitPoints.end(); ++intiter){
3827 SLiter = SplitLength.find(intiter->first);
3829 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3831 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3832 PropertyName = PropertyElement.GetNextToken();
3833 PropertyValue = PropertyElement.GetNextToken();
3835 intPrevValue = intiter->second;
3837 // Process properties.
3839 size_t intPropertyValueLen = PropertyValue.Len();
3841 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3843 PropertyValue.Trim();
3844 PropertyValue.RemoveLast();
3848 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3850 PropertyValue.Remove(0, 1);
3854 CaptureString(&PropertyValue, FALSE);
3856 if (PropertyName == wxT("ALTID")){
3858 CategoriesListAltID.erase(*CategoryCount);
3859 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3861 } else if (PropertyName == wxT("PID")){
3863 CategoriesListPID.erase(*CategoryCount);
3864 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3866 } else if (PropertyName == wxT("PREF")){
3868 int PriorityNumber = 0;
3869 bool ValidNumber = TRUE;
3872 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3875 catch(std::invalid_argument &e){
3876 ValidNumber = FALSE;
3879 if (ValidNumber == TRUE){
3881 CategoriesListPref.erase(*CategoryCount);
3882 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3886 } else if (PropertyName == wxT("LANGUAGE")){
3888 CategoriesListLanguage.erase(*CategoryCount);
3889 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3893 // Something else we don't know about so append
3894 // to the tokens variable.
3896 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3898 if (FirstToken == TRUE){
3900 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3905 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3915 // Deal with multiple categories.
3917 int intOrigCatCount = *CategoryCount;
3918 bool FirstCategoryProcessed = TRUE;
3919 bool AfterFirstToken = FALSE;
3920 int intSplitSize = 0;
3921 int intSplitsFound = 0;
3922 int intSplitSeek = 0;
3923 int intPropertyLen = PropertySeg2.Len();
3925 SplitPoints.clear();
3926 SplitLength.clear();
3929 for (int i = 0; i <= intPropertyLen; i++){
3931 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3939 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3941 if (AfterFirstToken == TRUE){
3943 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3944 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3948 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3949 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3950 AfterFirstToken = TRUE;
3962 if (SplitPoints.size() > 0){
3964 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3965 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3969 if (SplitPoints.size() == 0){
3971 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3973 if (!PropertyTokens.IsEmpty()){
3975 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3981 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3982 intiter != SplitPoints.end(); ++intiter){
3984 SLiter = SplitLength.find(intiter->first);
3986 intPrevValue = intiter->second;
3988 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3990 // Add the data to the General/Home/Work address variables.
3992 // Trim any whitespace from the start and end.
3994 PropertyData = PropertyData.Trim(FALSE);
3995 PropertyData = PropertyData.Trim(TRUE);
3997 CaptureString(&PropertyData, FALSE);
3999 if (FirstCategoryProcessed == TRUE){
4001 FirstCategoryProcessed = FALSE;
4003 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4005 if (!PropertyTokens.IsEmpty()){
4007 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4017 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4019 if (!PropertyTokens.IsEmpty()){
4021 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4027 // Copy the properties to each of the categories (if it exists).
4029 if (!PropertyTokens.IsEmpty()){
4031 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4035 // Check if ALTID was used.
4037 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4039 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4043 // Check if PID was used.
4045 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4047 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4051 // Check if PREF was used.
4053 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4055 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4059 // Check if LANGUAGE was used.
4061 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4063 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4067 // Check if TYPE was used.
4073 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4076 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4084 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4086 size_t intPropertyLen = PropertySeg1.Len();
4087 std::map<int, int> SplitPoints;
4088 std::map<int, int> SplitLength;
4089 std::map<int, int>::iterator SLiter;
4090 wxString PropertyData;
4091 wxString PropertyName;
4092 wxString PropertyValue;
4093 wxString PropertyTokens;
4094 bool FirstToken = TRUE;
4095 int intSplitsFound = 0;
4096 int intSplitSize = 0;
4097 int intPrevValue = 7;
4101 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4105 PropertyType PropType = PROPERTY_NONE;
4107 // Look for type before continuing.
4109 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4113 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4114 intiter != SplitPoints.end(); ++intiter){
4116 SLiter = SplitLength.find(intiter->first);
4118 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4120 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4121 PropertyName = PropertyElement.GetNextToken();
4122 PropertyValue = PropertyElement.GetNextToken();
4124 intPrevValue = intiter->second;
4126 // Process properties.
4128 size_t intPropertyValueLen = PropertyValue.Len();
4130 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4132 PropertyValue.Trim();
4133 PropertyValue.RemoveLast();
4137 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4139 PropertyValue.Remove(0, 1);
4143 CaptureString(&PropertyValue, FALSE);
4145 if (PropertyName == wxT("ALTID")){
4147 PicturesListAltID.erase(*PhotoCount);
4148 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4150 } else if (PropertyName == wxT("PID")){
4152 PicturesListPID.erase(*PhotoCount);
4153 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4155 } else if (PropertyName == wxT("PREF")){
4157 int PriorityNumber = 0;
4158 bool ValidNumber = TRUE;
4161 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4164 catch(std::invalid_argument &e){
4165 ValidNumber = FALSE;
4168 if (ValidNumber == TRUE){
4170 PicturesListPref.erase(*PhotoCount);
4171 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4175 } else if (PropertyName == wxT("MEDIATYPE")){
4177 PicturesListMediatype.erase(*PhotoCount);
4178 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4182 // Something else we don't know about so append
4183 // to the tokens variable.
4185 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4187 if (FirstToken == TRUE){
4189 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4194 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4204 intPropertyLen = PropertySeg2.Len();
4205 SplitPoints.clear();
4206 SplitLength.clear();
4211 CaptureString(&PropertySeg2, FALSE);
4213 for (int i = 0; i <= intPropertyLen; i++){
4217 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4220 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4222 if (intSplitsFound == 6){
4224 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4229 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4239 wxString wxSPhotoURI;
4240 wxString wxSPhotoMIME;
4241 wxString wxSPhotoEncoding;
4242 wxString wxSPhotoData;
4243 std::string base64enc;
4245 if (intSplitsFound == 0){
4249 std::map<int, int>::iterator striter;
4251 striter = SplitLength.find(1);
4253 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4255 while (wSTDataType.HasMoreTokens() == TRUE){
4257 wxSPhotoURI = wSTDataType.GetNextToken();
4258 wxSPhotoMIME = wSTDataType.GetNextToken();
4263 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4265 while (wSTDataInfo.HasMoreTokens() == TRUE){
4267 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4268 wxSPhotoData = wSTDataInfo.GetNextToken();
4269 base64enc = wxSPhotoData.mb_str();
4276 // Add the data to the General/Home/Work address variables.
4278 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4279 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4280 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4286 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4289 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4293 if (!PropertyTokens.IsEmpty()){
4295 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4301 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4303 size_t intPropertyLen = PropertySeg1.Len();
4304 std::map<int, int> SplitPoints;
4305 std::map<int, int> SplitLength;
4306 std::map<int, int>::iterator SLiter;
4307 wxString PropertyData;
4308 wxString PropertyName;
4309 wxString PropertyValue;
4310 wxString PropertyTokens;
4311 bool FirstToken = TRUE;
4312 int intSplitsFound = 0;
4313 int intSplitSize = 0;
4314 int intPrevValue = 6;
4318 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4322 PropertyType PropType = PROPERTY_NONE;
4324 // Look for type before continuing.
4326 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4330 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4331 intiter != SplitPoints.end(); ++intiter){
4333 SLiter = SplitLength.find(intiter->first);
4335 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4337 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4338 PropertyName = PropertyElement.GetNextToken();
4339 PropertyValue = PropertyElement.GetNextToken();
4341 intPrevValue = intiter->second;
4343 // Process properties.
4345 size_t intPropertyValueLen = PropertyValue.Len();
4347 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4349 PropertyValue.Trim();
4350 PropertyValue.RemoveLast();
4354 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4356 PropertyValue.Remove(0, 1);
4360 CaptureString(&PropertyValue, FALSE);
4362 if (PropertyName == wxT("ALTID")){
4364 LogosListAltID.erase(*LogoCount);
4365 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4367 } else if (PropertyName == wxT("PID")){
4369 LogosListPID.erase(*LogoCount);
4370 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4372 } else if (PropertyName == wxT("PREF")){
4374 int PriorityNumber = 0;
4375 bool ValidNumber = TRUE;
4378 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4381 catch(std::invalid_argument &e){
4382 ValidNumber = FALSE;
4385 if (ValidNumber == TRUE){
4387 LogosListPref.erase(*LogoCount);
4388 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4392 } else if (PropertyName == wxT("MEDIATYPE")){
4394 LogosListMediatype.erase(*LogoCount);
4395 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4399 // Something else we don't know about so append
4400 // to the tokens variable.
4402 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4404 if (FirstToken == TRUE){
4406 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4411 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4421 intPropertyLen = PropertySeg2.Len();
4422 SplitPoints.clear();
4423 SplitLength.clear();
4428 CaptureString(&PropertySeg2, FALSE);
4430 for (int i = 0; i <= intPropertyLen; i++){
4434 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4437 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4439 if (intSplitsFound == 6){
4441 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4446 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4456 wxString wxSPhotoURI;
4457 wxString wxSPhotoMIME;
4458 wxString wxSPhotoEncoding;
4459 wxString wxSPhotoData;
4460 std::string base64enc;
4462 if (intSplitsFound == 0){
4466 std::map<int, int>::iterator striter;
4468 striter = SplitLength.find(1);
4470 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4472 while (wSTDataType.HasMoreTokens() == TRUE){
4474 wxSPhotoURI = wSTDataType.GetNextToken();
4475 wxSPhotoMIME = wSTDataType.GetNextToken();
4480 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4482 while (wSTDataInfo.HasMoreTokens() == TRUE){
4484 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4485 wxSPhotoData = wSTDataInfo.GetNextToken();
4486 base64enc = wxSPhotoData.mb_str();
4493 // Add the data to the General/Home/Work address variables.
4495 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4496 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4497 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4503 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4506 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4510 if (!PropertyTokens.IsEmpty()){
4512 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4518 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4520 size_t intPropertyLen = PropertySeg1.Len();
4521 std::map<int, int> SplitPoints;
4522 std::map<int, int> SplitLength;
4523 std::map<int, int>::iterator SLiter;
4524 wxString PropertyData;
4525 wxString PropertyName;
4526 wxString PropertyValue;
4527 wxString PropertyTokens;
4528 bool FirstToken = TRUE;
4529 int intSplitsFound = 0;
4530 int intSplitSize = 0;
4531 int intPrevValue = 7;
4535 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4539 PropertyType PropType = PROPERTY_NONE;
4541 // Look for type before continuing.
4543 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4547 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4548 intiter != SplitPoints.end(); ++intiter){
4550 SLiter = SplitLength.find(intiter->first);
4552 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4554 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4555 PropertyName = PropertyElement.GetNextToken();
4556 PropertyValue = PropertyElement.GetNextToken();
4558 intPrevValue = intiter->second;
4560 // Process properties.
4562 size_t intPropertyValueLen = PropertyValue.Len();
4564 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4566 PropertyValue.Trim();
4567 PropertyValue.RemoveLast();
4571 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4573 PropertyValue.Remove(0, 1);
4577 CaptureString(&PropertyValue, FALSE);
4579 if (PropertyName == wxT("ALTID")){
4581 SoundsListAltID.erase(*SoundCount);
4582 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4584 } else if (PropertyName == wxT("PID")){
4586 SoundsListPID.erase(*SoundCount);
4587 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4589 } else if (PropertyName == wxT("PREF")){
4591 int PriorityNumber = 0;
4592 bool ValidNumber = TRUE;
4595 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4598 catch(std::invalid_argument &e){
4599 ValidNumber = FALSE;
4602 if (ValidNumber == TRUE){
4604 SoundsListPref.erase(*SoundCount);
4605 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4609 } else if (PropertyName == wxT("MEDIATYPE")){
4611 SoundsListMediatype.erase(*SoundCount);
4612 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4614 } else if (PropertyName == wxT("LANGUAGE")){
4616 SoundsListLanguage.erase(*SoundCount);
4617 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4621 // Something else we don't know about so append
4622 // to the tokens variable.
4624 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4626 if (FirstToken == TRUE){
4628 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4633 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4643 intPropertyLen = PropertySeg2.Len();
4644 SplitPoints.clear();
4645 SplitLength.clear();
4650 CaptureString(&PropertySeg2, FALSE);
4652 for (int i = 0; i <= intPropertyLen; i++){
4656 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4659 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4661 if (intSplitsFound == 6){
4663 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4668 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4678 wxString wxSSoundURI;
4679 wxString wxSSoundMIME;
4680 wxString wxSSoundEncoding;
4681 wxString wxSSoundData;
4682 std::string base64enc;
4684 if (intSplitsFound == 0){
4688 std::map<int, int>::iterator striter;
4690 striter = SplitLength.find(1);
4692 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4694 while (wSTDataType.HasMoreTokens() == TRUE){
4696 wxSSoundURI = wSTDataType.GetNextToken();
4697 wxSSoundMIME = wSTDataType.GetNextToken();
4702 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4704 while (wSTDataInfo.HasMoreTokens() == TRUE){
4706 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4707 wxSSoundData = wSTDataInfo.GetNextToken();
4708 base64enc = wxSSoundData.mb_str();
4715 // Add the data to the General/Home/Work address variables.
4721 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4724 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4728 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4729 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4730 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4732 if (!PropertyTokens.IsEmpty()){
4734 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4740 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4742 size_t intPropertyLen = PropertySeg1.Len();
4743 std::map<int, int> SplitPoints;
4744 std::map<int, int> SplitLength;
4745 std::map<int, int>::iterator SLiter;
4746 wxString PropertyData;
4747 wxString PropertyName;
4748 wxString PropertyValue;
4749 wxString PropertyTokens;
4750 bool FirstToken = TRUE;
4751 int intSplitsFound = 0;
4752 int intSplitSize = 0;
4753 int intPrevValue = 8;
4757 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4761 PropertyType PropType = PROPERTY_NONE;
4763 // Look for type before continuing.
4765 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4769 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4770 intiter != SplitPoints.end(); ++intiter){
4772 SLiter = SplitLength.find(intiter->first);
4774 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4776 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4777 PropertyName = PropertyElement.GetNextToken();
4778 PropertyValue = PropertyElement.GetNextToken();
4780 intPrevValue = intiter->second;
4782 // Process properties.
4784 size_t intPropertyValueLen = PropertyValue.Len();
4786 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4788 PropertyValue.Trim();
4789 PropertyValue.RemoveLast();
4793 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4795 PropertyValue.Remove(0, 1);
4799 CaptureString(&PropertyValue, FALSE);
4801 if (PropertyName == wxT("ALTID")){
4803 CalendarListAltID.erase(*CalURICount);
4804 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4806 } else if (PropertyName == wxT("PID")){
4808 CalendarListPID.erase(*CalURICount);
4809 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4811 } else if (PropertyName == wxT("PREF")){
4813 int PriorityNumber = 0;
4814 bool ValidNumber = TRUE;
4817 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4820 catch(std::invalid_argument &e){
4821 ValidNumber = FALSE;
4824 if (ValidNumber == TRUE){
4826 CalendarListPref.erase(*CalURICount);
4827 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
4831 } else if (PropertyName == wxT("MEDIATYPE")){
4833 CalendarListMediatype.erase(*CalURICount);
4834 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4838 // Something else we don't know about so append
4839 // to the tokens variable.
4841 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4843 if (FirstToken == TRUE){
4845 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4850 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4860 intPropertyLen = PropertySeg2.Len();
4861 SplitPoints.clear();
4862 SplitLength.clear();
4867 CaptureString(&PropertySeg2, FALSE);
4869 // Add the data to the General/Home/Work address variables.
4875 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4878 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4882 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4884 if (!PropertyTokens.IsEmpty()){
4886 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4892 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4894 size_t intPropertyLen = PropertySeg1.Len();
4895 std::map<int, int> SplitPoints;
4896 std::map<int, int> SplitLength;
4897 std::map<int, int>::iterator SLiter;
4898 wxString PropertyData;
4899 wxString PropertyName;
4900 wxString PropertyValue;
4901 wxString PropertyTokens;
4902 bool FirstToken = TRUE;
4903 int intSplitsFound = 0;
4904 int intSplitSize = 0;
4905 int intPrevValue = 8;
4909 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4913 PropertyType PropType = PROPERTY_NONE;
4915 // Look for type before continuing.
4917 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4921 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4922 intiter != SplitPoints.end(); ++intiter){
4924 SLiter = SplitLength.find(intiter->first);
4926 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4928 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4929 PropertyName = PropertyElement.GetNextToken();
4930 PropertyValue = PropertyElement.GetNextToken();
4932 intPrevValue = intiter->second;
4934 // Process properties.
4936 size_t intPropertyValueLen = PropertyValue.Len();
4938 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4940 PropertyValue.Trim();
4941 PropertyValue.RemoveLast();
4945 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4947 PropertyValue.Remove(0, 1);
4951 CaptureString(&PropertyValue, FALSE);
4953 if (PropertyName == wxT("ALTID")){
4955 CalendarRequestListAltID.erase(*CalAdrURICount);
4956 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4958 } else if (PropertyName == wxT("PID")){
4960 CalendarRequestListPID.erase(*CalAdrURICount);
4961 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4963 } else if (PropertyName == wxT("PREF")){
4965 int PriorityNumber = 0;
4966 bool ValidNumber = TRUE;
4969 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4972 catch(std::invalid_argument &e){
4973 ValidNumber = FALSE;
4976 if (ValidNumber == TRUE){
4978 CalendarRequestListPref.erase(*CalAdrURICount);
4979 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
4983 } else if (PropertyName == wxT("MEDIATYPE")){
4985 CalendarRequestListMediatype.erase(*CalAdrURICount);
4986 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4990 // Something else we don't know about so append
4991 // to the tokens variable.
4993 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4995 if (FirstToken == TRUE){
4997 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5002 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5012 intPropertyLen = PropertySeg2.Len();
5013 SplitPoints.clear();
5014 SplitLength.clear();
5019 CaptureString(&PropertySeg2, FALSE);
5021 // Add the data to the General/Home/Work address variables.
5027 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5030 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5034 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5036 if (!PropertyTokens.IsEmpty()){
5038 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5044 void SplitValues(wxString *PropertyLine,
5045 std::map<int,int> *SplitPoints,
5046 std::map<int,int> *SplitLength,
5049 size_t intPropertyLen = PropertyLine->Len();
5050 int intSplitsFound = 0;
5051 int intSplitSize = 0;
5052 int intSplitSeek = 0;
5054 for (int i = intSize; i <= intPropertyLen; i++){
5058 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5059 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5061 if (intSplitsFound == 0){
5063 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5067 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5071 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5081 if (intSplitsFound == 0){
5083 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5084 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5088 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5089 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5095 void CheckType(wxString *PropertySeg1,
5096 std::map<int,int> *SplitPoints,
5097 std::map<int,int> *SplitLength,
5099 PropertyType *PropType){
5101 wxString PropertyData;
5102 wxString PropertyName;
5103 wxString PropertyValue;
5104 std::map<int,int>::iterator SLiter;
5106 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5107 intiter != SplitPoints->end(); ++intiter){
5109 SLiter = SplitLength->find(intiter->first);
5111 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5113 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5114 PropertyName = PropertyElement.GetNextToken();
5115 PropertyValue = PropertyElement.GetNextToken();
5117 *intPrevValue = intiter->second;
5119 if (PropertyName == wxT("TYPE")){
5121 if (PropertyValue == wxT("work")){
5123 *PropType = PROPERTY_WORK;
5125 } else if (PropertyValue == wxT("home")){
5127 *PropType = PROPERTY_HOME;
5131 *PropType = PROPERTY_NONE;