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;
102 wxString ContactLine;
103 wxString PropertyLine;
104 wxString PropertySeg1;
105 wxString PropertySeg2;
106 wxString PropertyNextLine;
109 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
110 iter != ContactFileLines.end(); ++iter){
112 ExtraLineSeek = TRUE;
118 PropertyLine.Clear();
119 PropertySeg1.Clear();
120 PropertySeg2.Clear();
123 ContactLine = iter->second;
125 while (ExtraLineSeek == TRUE){
127 // Check if there is extra data on the next line
128 // (indicated by space or tab at the start) and add data.
132 if (iter == ContactFileLines.end()){
139 PropertyNextLine = iter->second;
141 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
143 PropertyNextLine.Remove(0, 1);
144 ContactLine.Append(PropertyNextLine);
149 ExtraLineSeek = FALSE;
155 ContactLineLen = ContactLine.Len();
157 // Make sure we are not in quotation mode.
158 // Make sure colon does not have \ or \\ before it.
160 for (int i = 0; i <= ContactLineLen; i++){
162 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
164 PropertyFind = FALSE;
166 } else if (PropertyFind == TRUE){
168 Property.Append(ContactLine.Mid(i, 1));
172 if (ContactLine.Mid(i, 1) == wxT("\"")){
174 if (QuoteMode == TRUE){
186 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
195 // Split that line at the point into two variables (ignore the colon).
197 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
198 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
200 if (Property == wxT("KIND") && KindProcessed == FALSE){
202 ProcessKind(PropertySeg2);
204 } else if (Property == wxT("MEMBER")){
206 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
209 } else if (Property == wxT("FN")){
211 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
214 } else if (Property == wxT("N") && NameProcessed == FALSE){
216 ProcessN(PropertySeg1, PropertySeg2);
217 NameProcessed = TRUE;
219 } else if (Property == wxT("NICKNAME")){
221 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
224 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
226 ProcessGender(PropertySeg1, PropertySeg2);
227 GenderProcessed = TRUE;
229 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
231 ProcessBirthday(PropertySeg1, PropertySeg2);
232 BirthdayProcessed = TRUE;
234 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
236 ProcessAnniversary(PropertySeg1, PropertySeg2);
237 AnniversaryProcessed = TRUE;
239 } else if (Property == wxT("TZ")){
241 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
244 } else if (Property == wxT("ADR")){
246 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
249 } else if (Property == wxT("EMAIL")){
251 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
254 } else if (Property == wxT("IMPP")){
256 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
259 } else if (Property == wxT("TEL")){
261 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
264 } else if (Property == wxT("LANG")){
266 // See frmContactEditor-LoadLanguage.cpp
268 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
271 } else if (Property == wxT("GEO")){
273 // See frmContactEditor-LoadGeo.cpp
275 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
278 } else if (Property == wxT("RELATED")){
280 // See fromContactEditor-LoadRelated.cpp
282 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
285 } else if (Property == wxT("URL")){
287 // See frmContactEditor-LoadURL.cpp
289 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
292 } else if (Property == wxT("TITLE")) {
294 // See frmContactEditor-LoadTitle.cpp
296 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
299 } else if (Property == wxT("ROLE")) {
301 // See frmContactEditor-LoadTitle.cpp
303 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
306 } else if (Property == wxT("ORG")) {
308 // See frmContactEditor-LoadOrg.cpp
310 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
313 } else if (Property == wxT("NOTE")) {
315 // See frmContactEditor-LoadNote.cpp
317 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
320 } else if (Property == wxT("CATEGORIES")) {
322 // See frmContactEditor-LoadCategory.cpp
324 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
327 } else if (Property == wxT("PHOTO")) {
329 // See frmContactEditor-LoadPhoto.cpp
331 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
334 } else if (Property == wxT("LOGO")) {
336 // See frmContactEditor-LoadPhoto.cpp
338 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
345 return CONTACTLOAD_OK;
349 void ContactDataObject::ProcessKind(wxString KindType){
351 if (KindType == wxT("individual")){
353 ContactKind = CONTACTKIND_INDIVIDUAL;
355 } else if (KindType == wxT("group")){
357 ContactKind = CONTACTKIND_GROUP;
359 } else if (KindType == wxT("org")){
361 ContactKind = CONTACTKIND_ORGANISATION;
363 } else if (KindType == wxT("location")){
365 ContactKind = CONTACTKIND_LOCATION;
369 ContactKind = CONTACTKIND_NONE;
374 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
376 std::map<int, int> SplitPoints;
377 std::map<int, int> SplitLength;
379 int intPrevValue = 8;
383 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
387 wxString PropertyName;
388 wxString PropertyValue;
389 wxString PropertyData;
390 wxString PropertyTokens;
391 std::map<int,int>::iterator SLiter;
392 bool FirstToken = TRUE;
394 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
395 intiter != SplitPoints.end(); ++intiter){
397 SLiter = SplitLength.find(intiter->first);
399 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
401 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
402 PropertyName = PropertyElement.GetNextToken();
403 PropertyValue = PropertyElement.GetNextToken();
405 intPrevValue = intiter->second;
407 CaptureString(&PropertyValue, FALSE);
409 if (PropertyName == wxT("ALTID")){
411 GroupsListAltID.erase(*GroupCount);
412 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
414 } else if (PropertyName == wxT("PID")){
416 GroupsListPID.erase(*GroupCount);
417 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
419 } else if (PropertyName == wxT("PREF")){
421 int PriorityNumber = 0;
422 bool ValidNumber = TRUE;
425 PriorityNumber = std::stoi(PropertyValue.ToStdString());
428 catch(std::invalid_argument &e){
432 if (ValidNumber == TRUE){
434 GroupsListPref.erase(*GroupCount);
435 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
439 } else if (PropertyName == wxT("MEDIATYPE")){
441 GroupsListMediaType.erase(*GroupCount);
442 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
444 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
446 if (FirstToken == TRUE){
448 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
453 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
461 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
463 if (!PropertyTokens.IsEmpty()){
465 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
472 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
474 std::map<int, int> SplitPoints;
475 std::map<int, int> SplitLength;
477 int intPrevValue = 4;
481 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
485 wxString PropertyName;
486 wxString PropertyValue;
487 wxString PropertyData;
488 wxString PropertyTokens;
489 std::map<int,int>::iterator SLiter;
490 bool FirstToken = TRUE;
492 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
493 intiter != SplitPoints.end(); ++intiter){
495 SLiter = SplitLength.find(intiter->first);
497 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
499 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
500 PropertyName = PropertyElement.GetNextToken();
501 PropertyValue = PropertyElement.GetNextToken();
503 intPrevValue = intiter->second;
505 CaptureString(&PropertyValue, FALSE);
507 if (PropertyName == wxT("TYPE")){
509 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
510 PropertyValue == wxT("work") ){
512 FullNamesListType.erase(*FNCount);
513 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
517 } else if (PropertyName == wxT("LANGUAGE")){
519 FullNamesListLanguage.erase(*FNCount);
520 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
522 } else if (PropertyName == wxT("ALTID")){
524 FullNamesListAltID.erase(*FNCount);
525 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
527 } else if (PropertyName == wxT("PID")){
529 FullNamesListPID.erase(*FNCount);
530 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
532 } else if (PropertyName == wxT("PREF")){
534 int PriorityNumber = 0;
535 bool ValidNumber = TRUE;
538 PriorityNumber = std::stoi(PropertyValue.ToStdString());
541 catch(std::invalid_argument &e){
545 if (ValidNumber == TRUE){
547 FullNamesListPref.erase(*FNCount);
548 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
552 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
554 if (FirstToken == TRUE){
556 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
561 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
569 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
571 if (!PropertyTokens.IsEmpty()){
573 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
579 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
581 std::map<int, int> SplitPoints;
582 std::map<int, int> SplitLength;
584 int intPrevValue = 3;
588 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
592 wxString PropertyName;
593 wxString PropertyValue;
594 wxString PropertyData;
595 wxString PropertyTokens;
596 std::map<int,int>::iterator SLiter;
597 bool FirstToken = TRUE;
599 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
600 intiter != SplitPoints.end(); ++intiter){
602 SLiter = SplitLength.find(intiter->first);
604 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
606 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
607 PropertyName = PropertyElement.GetNextToken();
608 PropertyValue = PropertyElement.GetNextToken();
610 intPrevValue = intiter->second;
612 CaptureString(&PropertyValue, FALSE);
614 if (PropertyName == wxT("ALTID")){
616 NameAltID = PropertyValue;
618 } else if (PropertyName == wxT("LANGUAGE")){
620 NameLanguage = PropertyValue;
622 } else if (PropertyName == wxT("SORT-AS")){
624 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
625 PropertyValue.Len() >= 3){
626 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
629 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
631 if (FirstToken == TRUE){
633 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
638 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
646 // Split the name data.
648 int intSplitSeek = 0;
649 int intSplitsFound = 0;
650 int intSplitSize = 0;
651 int intPropertyLen = PropertySeg2.Len();
653 std::map<int,wxString> NameValues;
656 for (int i = 0; i <= intPropertyLen; i++){
658 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
660 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
665 if (intSplitsFound == 4){
667 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
681 // Split the data into several parts.
683 for (std::map<int, wxString>::iterator iter = NameValues.begin();
684 iter != NameValues.end(); ++iter){
686 if (iter->first == 1){
688 // Deal with family name.
690 NameSurname = iter->second;
692 } else if (iter->first == 2){
694 // Deal with given names.
696 NameForename = iter->second;
698 } else if (iter->first == 3){
700 // Deal with additional names.
702 NameOtherNames = iter->second;
704 } else if (iter->first == 4){
706 // Deal with honorifix prefixes and suffixes.
708 NameTitle = iter->second;
712 if (iter == NameValues.end()){
718 NameSuffix = iter->second;
724 // Add the name token data.
726 if (!PropertyTokens.IsEmpty()){
728 NameTokens = PropertyTokens;
734 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
736 std::map<int, int> SplitPoints;
737 std::map<int, int> SplitLength;
739 int intPrevValue = 10;
742 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
746 PropertyType PropType = PROPERTY_NONE;
748 // Look for type before continuing.
750 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
754 std::map<int, wxString> *NicknamesList = NULL;
755 std::map<int, wxString> *NicknamesListType = NULL;
756 std::map<int, wxString> *NicknamesListLanguage = NULL;
757 std::map<int, wxString> *NicknamesListAltID = NULL;
758 std::map<int, wxString> *NicknamesListPID = NULL;
759 std::map<int, wxString> *NicknamesListTokens = NULL;
760 std::map<int, int> *NicknamesListPref = NULL;
764 NicknamesList = &GeneralNicknamesList;
765 NicknamesListType = &GeneralNicknamesListType;
766 NicknamesListLanguage = &GeneralNicknamesListLanguage;
767 NicknamesListAltID = &GeneralNicknamesListAltID;
768 NicknamesListPID = &GeneralNicknamesListPID;
769 NicknamesListTokens = &GeneralNicknamesListTokens;
770 NicknamesListPref = &GeneralNicknamesListPref;
773 NicknamesList = &HomeNicknamesList;
774 NicknamesListType = &HomeNicknamesListType;
775 NicknamesListLanguage = &HomeNicknamesListLanguage;
776 NicknamesListAltID = &HomeNicknamesListAltID;
777 NicknamesListPID = &HomeNicknamesListPID;
778 NicknamesListTokens = &HomeNicknamesListTokens;
779 NicknamesListPref = &HomeNicknamesListPref;
782 NicknamesList = &BusinessNicknamesList;
783 NicknamesListType = &BusinessNicknamesListType;
784 NicknamesListLanguage = &BusinessNicknamesListLanguage;
785 NicknamesListAltID = &BusinessNicknamesListAltID;
786 NicknamesListPID = &BusinessNicknamesListPID;
787 NicknamesListTokens = &BusinessNicknamesListTokens;
788 NicknamesListPref = &BusinessNicknamesListPref;
792 std::map<int, int>::iterator SLiter;
793 wxString PropertyData;
794 wxString PropertyName;
795 wxString PropertyValue;
796 wxString PropertyTokens;
797 bool FirstToken = TRUE;
799 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
800 intiter != SplitPoints.end(); ++intiter){
802 SLiter = SplitLength.find(intiter->first);
804 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
806 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
807 PropertyName = PropertyElement.GetNextToken();
808 PropertyValue = PropertyElement.GetNextToken();
810 intPrevValue = intiter->second;
812 CaptureString(&PropertyValue, FALSE);
814 if (PropertyName == wxT("ALTID")){
816 NicknamesListAltID->erase(*NicknameCount);
817 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
819 } else if (PropertyName == wxT("PID")){
821 NicknamesListPID->erase(*NicknameCount);
822 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
824 } else if (PropertyName == wxT("PREF")){
826 int PriorityNumber = 0;
827 bool ValidNumber = TRUE;
830 PriorityNumber = std::stoi(PropertyValue.ToStdString());
833 catch(std::invalid_argument &e){
837 if (ValidNumber == TRUE){
839 NicknamesListPref->erase(*NicknameCount);
840 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
844 } else if (PropertyName == wxT("LANGUAGE")){
846 NicknamesListLanguage->erase(*NicknameCount);
847 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
851 // Something else we don't know about so append
852 // to the tokens variable.
854 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
856 if (FirstToken == TRUE){
858 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
863 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
873 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
875 // Add the name token data.
877 if (!PropertyTokens.IsEmpty()){
879 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
885 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
887 std::map<int, int> SplitPoints;
888 std::map<int, int> SplitLength;
889 std::map<int, int>::iterator SLiter;
890 wxString PropertyData;
891 wxString PropertyName;
892 wxString PropertyValue;
893 wxString PropertyTokens;
894 bool FirstToken = TRUE;
895 int intPrevValue = 8;
897 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
901 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
902 intiter != SplitPoints.end(); ++intiter){
904 SLiter = SplitLength.find(intiter->first);
906 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
908 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
909 PropertyName = PropertyElement.GetNextToken();
910 PropertyValue = PropertyElement.GetNextToken();
912 intPrevValue = intiter->second;
914 // Process properties.
916 size_t intPropertyValueLen = PropertyValue.Len();
918 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
920 PropertyValue.Trim();
921 PropertyValue.RemoveLast();
925 if (PropertyValue.Mid(0, 1) == wxT("\"")){
927 PropertyValue.Remove(0, 1);
931 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
933 if (FirstToken == TRUE){
935 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
940 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
948 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
950 wxString GenderComponent;
952 if (GenderData.CountTokens() >= 2){
954 Gender = GenderData.GetNextToken();
955 GenderDetails = GenderData.GetString();
957 CaptureString(&GenderDetails, FALSE);
961 Gender = GenderData.GetNextToken();
965 if (!PropertyTokens.IsEmpty()){
967 GenderTokens = PropertyTokens;
973 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
975 // Process date. Preserve the remainder in the string.
977 std::map<int, int> SplitPoints;
978 std::map<int, int> SplitLength;
979 std::map<int, int>::iterator SLiter;
980 wxString PropertyData;
981 wxString PropertyName;
982 wxString PropertyValue;
983 wxString PropertyTokens;
984 bool BirthdayText = FALSE;
985 int intPrevValue = 6;
987 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
991 // Look for type before continuing.
993 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
994 intiter != SplitPoints.end(); ++intiter){
996 SLiter = SplitLength.find(intiter->first);
998 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1000 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1001 PropertyName = PropertyElement.GetNextToken();
1002 PropertyValue = PropertyElement.GetNextToken();
1004 intPrevValue = intiter->second;
1006 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1008 CaptureString(&PropertySeg2, FALSE);
1009 Birthday = PropertySeg2;
1010 BirthdayText = TRUE;
1016 // Setup blank lines for later on.
1019 bool FirstToken = TRUE;
1021 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1022 intiter != SplitPoints.end(); ++intiter){
1024 SLiter = SplitLength.find(intiter->first);
1026 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1028 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1029 PropertyName = PropertyElement.GetNextToken();
1030 PropertyValue = PropertyElement.GetNextToken();
1032 intPrevValue = intiter->second;
1034 // Process properties.
1036 CaptureString(&PropertyValue, FALSE);
1038 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1040 PropertyValue.Trim();
1041 PropertyValue.RemoveLast();
1045 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1047 PropertyValue.Remove(0, 1);
1051 if (PropertyName == wxT("ALTID")){
1053 BirthdayAltID = PropertyValue;
1055 } else if (PropertyName == wxT("CALSCALE")){
1057 BirthdayCalScale = PropertyValue;
1059 } else if (PropertyName != wxT("VALUE")) {
1061 // Something else we don't know about so append
1062 // to the tokens variable.
1064 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1066 if (FirstToken == TRUE){
1068 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1073 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1083 // Add the data to the variables and form.
1085 if (BirthdayText == FALSE){
1087 Birthday = PropertySeg2;
1091 if (!PropertyTokens.IsEmpty()){
1093 BirthdayTokens = PropertyTokens;
1099 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1101 // Process date. Preserve the remainder in the string.
1103 std::map<int, int> SplitPoints;
1104 std::map<int, int> SplitLength;
1105 std::map<int, int>::iterator SLiter;
1106 wxString PropertyData;
1107 wxString PropertyName;
1108 wxString PropertyValue;
1109 wxString PropertyTokens;
1110 bool AnniversaryText = FALSE;
1111 int intPrevValue = 13;
1113 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1117 // Look for type before continuing.
1119 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1120 intiter != SplitPoints.end(); ++intiter){
1122 SLiter = SplitLength.find(intiter->first);
1124 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1126 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1127 PropertyName = PropertyElement.GetNextToken();
1128 PropertyValue = PropertyElement.GetNextToken();
1130 intPrevValue = intiter->second;
1132 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1134 CaptureString(&PropertySeg2, FALSE);
1135 Anniversary = PropertySeg2;
1136 AnniversaryText = TRUE;
1142 // Setup blank lines for later on.
1145 bool FirstToken = TRUE;
1147 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1148 intiter != SplitPoints.end(); ++intiter){
1150 SLiter = SplitLength.find(intiter->first);
1152 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1154 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1155 PropertyName = PropertyElement.GetNextToken();
1156 PropertyValue = PropertyElement.GetNextToken();
1158 intPrevValue = intiter->second;
1160 // Process properties.
1162 CaptureString(&PropertyValue, FALSE);
1164 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1166 PropertyValue.Trim();
1167 PropertyValue.RemoveLast();
1171 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1173 PropertyValue.Remove(0, 1);
1177 if (PropertyName == wxT("ALTID")){
1179 AnniversaryAltID = PropertyValue;
1181 } else if (PropertyName == wxT("CALSCALE")){
1183 AnniversaryCalScale = PropertyValue;
1185 } else if (PropertyName != wxT("VALUE")) {
1187 // Something else we don't know about so append
1188 // to the tokens variable.
1190 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1192 if (FirstToken == TRUE){
1194 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1199 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1209 // Add the data to the variables and form.
1211 if (AnniversaryText == FALSE){
1213 Anniversary = PropertySeg2;
1217 if (!PropertyTokens.IsEmpty()){
1219 AnniversaryTokens = PropertyTokens;
1225 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1227 std::map<int, int> SplitPoints;
1228 std::map<int, int> SplitLength;
1230 int intPrevValue = 4;
1233 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1237 PropertyType PropType = PROPERTY_NONE;
1239 // Look for type before continuing.
1241 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1245 std::map<int, wxString> *TZList = NULL;
1246 std::map<int, wxString> *TZListType = NULL;
1247 std::map<int, wxString> *TZListMediatype = NULL;
1248 std::map<int, wxString> *TZListAltID = NULL;
1249 std::map<int, wxString> *TZListPID = NULL;
1250 std::map<int, wxString> *TZListTokens = NULL;
1251 std::map<int, int> *TZListPref = NULL;
1255 TZList = &GeneralTZList;
1256 TZListType = &GeneralTZListType;
1257 TZListMediatype = &GeneralTZListMediatype;
1258 TZListAltID = &GeneralTZListAltID;
1259 TZListPID = &GeneralTZListPID;
1260 TZListTokens = &GeneralTZListTokens;
1261 TZListPref = &GeneralTZListPref;
1264 TZList = &HomeTZList;
1265 TZListType = &HomeTZListType;
1266 TZListMediatype = &HomeTZListMediatype;
1267 TZListAltID = &HomeTZListAltID;
1268 TZListPID = &HomeTZListPID;
1269 TZListTokens = &HomeTZListTokens;
1270 TZListPref = &HomeTZListPref;
1273 TZList = &BusinessTZList;
1274 TZListType = &BusinessTZListType;
1275 TZListMediatype = &BusinessTZListMediatype;
1276 TZListAltID = &BusinessTZListAltID;
1277 TZListPID = &BusinessTZListPID;
1278 TZListTokens = &BusinessTZListTokens;
1279 TZListPref = &BusinessTZListPref;
1283 std::map<int, int>::iterator SLiter;
1284 wxString PropertyData;
1285 wxString PropertyName;
1286 wxString PropertyValue;
1287 wxString PropertyTokens;
1288 bool FirstToken = TRUE;
1290 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1291 intiter != SplitPoints.end(); ++intiter){
1293 SLiter = SplitLength.find(intiter->first);
1295 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1297 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1298 PropertyName = PropertyElement.GetNextToken();
1299 PropertyValue = PropertyElement.GetNextToken();
1301 intPrevValue = intiter->second;
1303 CaptureString(&PropertyValue, FALSE);
1305 if (PropertyName == wxT("ALTID")){
1307 TZListAltID->erase(*TimeZoneCount);
1308 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1310 } else if (PropertyName == wxT("PID")){
1312 TZListPID->erase(*TimeZoneCount);
1313 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1315 } else if (PropertyName == wxT("PREF")){
1317 int PriorityNumber = 0;
1318 bool ValidNumber = TRUE;
1321 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1324 catch(std::invalid_argument &e){
1325 ValidNumber = FALSE;
1328 if (ValidNumber == TRUE){
1330 TZListPref->erase(*TimeZoneCount);
1331 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1335 } else if (PropertyName == wxT("MEDIATYPE")){
1337 TZListMediatype->erase(*TimeZoneCount);
1338 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1342 // Something else we don't know about so append
1343 // to the tokens variable.
1345 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1347 if (FirstToken == TRUE){
1349 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1354 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1364 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1366 // Add the name token data.
1368 if (!PropertyTokens.IsEmpty()){
1370 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1377 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1379 size_t intPropertyLen = PropertySeg1.Len();
1380 std::map<int, int> SplitPoints;
1381 std::map<int, int> SplitLength;
1382 std::map<int, int>::iterator SLiter;
1383 wxString PropertyData;
1384 wxString PropertyName;
1385 wxString PropertyValue;
1386 wxString PropertyTokens;
1387 wxString AddressLabel;
1388 wxString AddressLang;
1389 wxString AddressAltID;
1390 wxString AddressPID;
1391 wxString AddressTokens;
1392 wxString AddressGeo;
1393 wxString AddressTimezone;
1394 wxString AddressType;
1395 wxString AddressMediatype;
1396 wxString AddressPOBox;
1397 wxString AddressExtended;
1398 wxString AddressStreet;
1399 wxString AddressLocality;
1400 wxString AddressCity;
1401 wxString AddressRegion;
1402 wxString AddressPostalCode;
1403 wxString AddressCountry;
1404 bool FirstToken = TRUE;
1405 int intSplitsFound = 0;
1406 int intSplitSize = 0;
1407 int intPrevValue = 5;
1412 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1416 PropertyType PropType = PROPERTY_NONE;
1418 // Look for type before continuing.
1420 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1424 std::map<int, wxString> *AddressList = NULL;
1425 std::map<int, wxString> *AddressListTown = NULL;
1426 std::map<int, wxString> *AddressListCounty = NULL;
1427 std::map<int, wxString> *AddressListPostCode = NULL;
1428 std::map<int, wxString> *AddressListCountry = NULL;
1429 std::map<int, wxString> *AddressListLabel = NULL;
1430 std::map<int, wxString> *AddressListLang = NULL;
1431 std::map<int, wxString> *AddressListAltID = NULL;
1432 std::map<int, wxString> *AddressListPID = NULL;
1433 std::map<int, wxString> *AddressListTokens = NULL;
1434 std::map<int, wxString> *AddressListGeo = NULL;
1435 std::map<int, wxString> *AddressListTimezone = NULL;
1436 std::map<int, wxString> *AddressListType = NULL;
1437 std::map<int, wxString> *AddressListMediatype = NULL;
1438 std::map<int, int> *AddressListPref = NULL;
1442 AddressList = &GeneralAddressList;
1443 AddressListTown = &GeneralAddressListTown;
1444 AddressListCounty = &GeneralAddressListCounty;
1445 AddressListPostCode = &GeneralAddressListPostCode;
1446 AddressListCountry = &GeneralAddressListCountry;
1447 AddressListLabel = &GeneralAddressListLabel;
1448 AddressListLang = &GeneralAddressListLang;
1449 AddressListAltID = &GeneralAddressListAltID;
1450 AddressListPID = &GeneralAddressListPID;
1451 AddressListTokens = &GeneralAddressListTokens;
1452 AddressListGeo = &GeneralAddressListGeo;
1453 AddressListTimezone = &GeneralAddressListTimezone;
1454 AddressListType = &GeneralAddressListType;
1455 AddressListMediatype = &GeneralAddressListMediatype;
1456 AddressListPref = &GeneralAddressListPref;
1459 AddressList = &HomeAddressList;
1460 AddressListTown = &HomeAddressListTown;
1461 AddressListCounty = &HomeAddressListCounty;
1462 AddressListPostCode = &HomeAddressListPostCode;
1463 AddressListCountry = &HomeAddressListCountry;
1464 AddressListLabel = &HomeAddressListLabel;
1465 AddressListLang = &HomeAddressListLang;
1466 AddressListAltID = &HomeAddressListAltID;
1467 AddressListPID = &HomeAddressListPID;
1468 AddressListTokens = &HomeAddressListTokens;
1469 AddressListGeo = &HomeAddressListGeo;
1470 AddressListTimezone = &HomeAddressListTimezone;
1471 AddressListType = &HomeAddressListType;
1472 AddressListMediatype = &HomeAddressListMediatype;
1473 AddressListPref = &HomeAddressListPref;
1476 AddressList = &BusinessAddressList;
1477 AddressListTown = &BusinessAddressListTown;
1478 AddressListCounty = &BusinessAddressListCounty;
1479 AddressListPostCode = &BusinessAddressListPostCode;
1480 AddressListCountry = &BusinessAddressListCountry;
1481 AddressListLabel = &BusinessAddressListLabel;
1482 AddressListLang = &BusinessAddressListLang;
1483 AddressListAltID = &BusinessAddressListAltID;
1484 AddressListPID = &BusinessAddressListPID;
1485 AddressListTokens = &BusinessAddressListTokens;
1486 AddressListGeo = &BusinessAddressListGeo;
1487 AddressListTimezone = &BusinessAddressListTimezone;
1488 AddressListType = &BusinessAddressListType;
1489 AddressListMediatype = &BusinessAddressListMediatype;
1490 AddressListPref = &BusinessAddressListPref;
1496 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1497 intiter != SplitPoints.end(); ++intiter){
1499 SLiter = SplitLength.find(intiter->first);
1501 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1503 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1504 PropertyName = PropertyElement.GetNextToken();
1505 PropertyValue = PropertyElement.GetNextToken();
1507 intPrevValue = intiter->second;
1509 CaptureString(&PropertyValue, FALSE);
1511 // Process properties.
1513 if (PropertyName == wxT("LABEL")){
1515 AddressListLabel->erase(*AddressCount);
1516 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1518 } else if (PropertyName == wxT("LANGUAGE")){
1520 AddressListLang->erase(*AddressCount);
1521 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1523 } else if (PropertyName == wxT("ALTID")){
1525 AddressListAltID->erase(*AddressCount);
1526 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1528 } else if (PropertyName == wxT("PID")){
1530 AddressListPID->erase(*AddressCount);
1531 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1533 } else if (PropertyName == wxT("GEO")){
1535 AddressListGeo->erase(*AddressCount);
1536 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1538 } else if (PropertyName == wxT("TZ")){
1540 AddressListTimezone->erase(*AddressCount);
1541 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1543 } else if (PropertyName == wxT("MEDIATYPE")){
1545 AddressListMediatype->erase(*AddressCount);
1546 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1548 } else if (PropertyName == wxT("PREF")){
1550 int PriorityNumber = 0;
1551 bool ValidNumber = TRUE;
1554 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1557 catch(std::invalid_argument &e){
1558 ValidNumber = FALSE;
1561 if (ValidNumber == TRUE){
1563 AddressListPref->erase(*AddressCount);
1564 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1570 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1572 if (FirstToken == TRUE){
1574 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1579 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1589 // Split the address.
1591 //std::map<int, int>::iterator SLiter;
1592 intPropertyLen = PropertySeg2.Len();
1593 SplitPoints.clear();
1594 SplitLength.clear();
1599 for (int i = 0; i <= intPropertyLen; i++){
1603 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1606 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1608 if (intSplitsFound == 6){
1610 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1615 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1625 // Split the data into several parts.
1627 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1628 intiter != SplitPoints.end(); ++intiter){
1630 if (intiter->first == 1){
1632 // Deal with PO Box.
1634 SLiter = SplitLength.find(1);
1636 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1637 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1638 intPrevValue = intiter->second;
1640 } else if (intiter->first == 2){
1642 // Deal with extended address.
1644 SLiter = SplitLength.find(2);
1646 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1647 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1648 intPrevValue = intiter->second;
1650 } else if (intiter->first == 3){
1652 // Deal with street address.
1654 SLiter = SplitLength.find(3);
1656 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1657 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1658 intPrevValue = intiter->second;
1660 } else if (intiter->first == 4){
1662 // Deal with locality
1664 SLiter = SplitLength.find(4);
1666 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1667 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1668 intPrevValue = intiter->second;
1670 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1672 } else if (intiter->first == 5){
1674 // Deal with region.
1676 SLiter = SplitLength.find(5);
1678 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1679 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1680 intPrevValue = intiter->second;
1682 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1684 } else if (intiter->first == 6){
1686 // Deal with post code.
1688 SLiter = SplitLength.find(6);
1690 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1691 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1692 intPrevValue = intiter->second;
1694 // Deal with country.
1696 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1697 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1705 // Add the data to the General/Home/Work address variables.
1707 CaptureString(&AddressStreet, FALSE);
1708 CaptureString(&AddressLocality, FALSE);
1709 CaptureString(&AddressRegion, FALSE);
1710 CaptureString(&AddressPostalCode, FALSE);
1711 CaptureString(&AddressCountry, FALSE);
1713 if (!PropertyTokens.IsEmpty()){
1715 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1719 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1720 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1721 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1722 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1723 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1727 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1730 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1733 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1737 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1741 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1743 std::map<int, int> SplitPoints;
1744 std::map<int, int> SplitLength;
1746 int intPrevValue = 7;
1749 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1753 PropertyType PropType = PROPERTY_NONE;
1755 // Look for type before continuing.
1757 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1759 std::map<int, wxString> *EmailList = NULL;
1760 std::map<int, wxString> *EmailListType = NULL;
1761 std::map<int, wxString> *EmailListAltID = NULL;
1762 std::map<int, wxString> *EmailListPID = NULL;
1763 std::map<int, wxString> *EmailListTokens = NULL;
1764 std::map<int, int> *EmailListPref = NULL;
1768 EmailList = &GeneralEmailList;
1769 EmailListType = &GeneralEmailListType;
1770 EmailListAltID = &GeneralEmailListAltID;
1771 EmailListPID = &GeneralEmailListPID;
1772 EmailListTokens = &GeneralEmailListTokens;
1773 EmailListPref = &GeneralEmailListPref;
1776 EmailList = &HomeEmailList;
1777 EmailListType = &HomeEmailListType;
1778 EmailListAltID = &HomeEmailListAltID;
1779 EmailListPID = &HomeEmailListPID;
1780 EmailListTokens = &HomeEmailListTokens;
1781 EmailListPref = &HomeEmailListPref;
1784 EmailList = &BusinessEmailList;
1785 EmailListType = &BusinessEmailListType;
1786 EmailListAltID = &BusinessEmailListAltID;
1787 EmailListPID = &BusinessEmailListPID;
1788 EmailListTokens = &BusinessEmailListTokens;
1789 EmailListPref = &BusinessEmailListPref;
1795 std::map<int,int>::iterator SLiter;
1796 wxString PropertyData;
1797 wxString PropertyName;
1798 wxString PropertyValue;
1799 wxString PropertyTokens;
1800 bool FirstToken = TRUE;
1802 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1803 intiter != SplitPoints.end(); ++intiter){
1805 SLiter = SplitLength.find(intiter->first);
1807 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1809 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1810 PropertyName = PropertyElement.GetNextToken();
1811 PropertyValue = PropertyElement.GetNextToken();
1813 intPrevValue = intiter->second;
1815 CaptureString(&PropertyValue, FALSE);
1817 // Process properties.
1819 if (PropertyName == wxT("ALTID")){
1821 EmailListAltID->erase(*EmailCount);
1822 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1824 } else if (PropertyName == wxT("PID")){
1826 EmailListPID->erase(*EmailCount);
1827 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1829 } else if (PropertyName == wxT("PREF")){
1831 int PriorityNumber = 0;
1832 bool ValidNumber = TRUE;
1835 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1838 catch(std::invalid_argument &e){
1839 ValidNumber = FALSE;
1842 if (ValidNumber == TRUE){
1844 EmailListPref->erase(*EmailCount);
1845 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1851 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1853 if (FirstToken == TRUE){
1855 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1860 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1870 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1872 // Add the name token data.
1874 if (!PropertyTokens.IsEmpty()){
1876 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1883 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1885 std::map<int, int> SplitPoints;
1886 std::map<int, int> SplitLength;
1888 int intPrevValue = 6;
1891 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1895 PropertyType PropType = PROPERTY_NONE;
1897 // Look for type before continuing.
1899 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1901 std::map<int, wxString> *IMList = NULL;
1902 std::map<int, wxString> *IMListType = NULL;
1903 std::map<int, wxString> *IMListAltID = NULL;
1904 std::map<int, wxString> *IMListPID = NULL;
1905 std::map<int, wxString> *IMListTokens = NULL;
1906 std::map<int, wxString> *IMListMediatype = NULL;
1907 std::map<int, int> *IMListPref = NULL;
1911 IMList = &GeneralIMList;
1912 IMListType = &GeneralIMListType;
1913 IMListAltID = &GeneralIMListAltID;
1914 IMListPID = &GeneralIMListPID;
1915 IMListTokens = &GeneralIMListTokens;
1916 IMListMediatype = &GeneralIMListMediatype;
1917 IMListPref = &GeneralIMListPref;
1920 IMList = &HomeIMList;
1921 IMListType = &HomeIMListType;
1922 IMListAltID = &HomeIMListAltID;
1923 IMListPID = &HomeIMListPID;
1924 IMListTokens = &HomeIMListTokens;
1925 IMListMediatype = &HomeIMListMediatype;
1926 IMListPref = &HomeIMListPref;
1929 IMList = &BusinessIMList;
1930 IMListType = &BusinessIMListType;
1931 IMListAltID = &BusinessIMListAltID;
1932 IMListPID = &BusinessIMListPID;
1933 IMListTokens = &BusinessIMListTokens;
1934 IMListMediatype = &BusinessIMListMediatype;
1935 IMListPref = &BusinessIMListPref;
1941 std::map<int,int>::iterator SLiter;
1942 wxString PropertyData;
1943 wxString PropertyName;
1944 wxString PropertyValue;
1945 wxString PropertyTokens;
1946 bool FirstToken = TRUE;
1948 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1949 intiter != SplitPoints.end(); ++intiter){
1951 SLiter = SplitLength.find(intiter->first);
1953 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1955 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1956 PropertyName = PropertyElement.GetNextToken();
1957 PropertyValue = PropertyElement.GetNextToken();
1959 intPrevValue = intiter->second;
1961 CaptureString(&PropertyValue, FALSE);
1963 // Process properties.
1965 if (PropertyName == wxT("ALTID")){
1967 IMListAltID->erase(*IMCount);
1968 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1970 } else if (PropertyName == wxT("PID")){
1972 IMListPID->erase(*IMCount);
1973 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1975 } else if (PropertyName == wxT("MEDIATYPE")){
1977 IMListMediatype->erase(*IMCount);
1978 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1980 } else if (PropertyName == wxT("PREF")){
1982 int PriorityNumber = 0;
1983 bool ValidNumber = TRUE;
1986 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1989 catch(std::invalid_argument &e){
1990 ValidNumber = FALSE;
1993 if (ValidNumber == TRUE){
1995 IMListPref->erase(*IMCount);
1996 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2002 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2004 if (FirstToken == TRUE){
2006 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2011 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2021 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2023 // Add the name token data.
2025 if (!PropertyTokens.IsEmpty()){
2027 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2033 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2035 std::map<int, int> SplitPoints;
2036 std::map<int, int> SplitLength;
2037 std::map<int, int>::iterator SLiter;
2041 PropertyType PropType = PROPERTY_NONE;
2043 // Look for type before continuing.
2046 wxString TelTypeDetail;
2047 wxString PropertyData;
2048 wxString PropertyName;
2049 wxString PropertyValue;
2050 wxString PropertyTokens;
2052 std::map<int,int> TypeSplitPoints;
2053 std::map<int,int> TypeSplitLength;
2054 std::map<int,int>::iterator TSLiter;
2056 int intSplitSize = 0;
2057 int intSplitsFound = 0;
2058 int intSplitPoint = 0;
2060 int intPrevValue = 5;
2062 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2066 // Look for type before continuing.
2068 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2069 intiter != SplitPoints.end(); ++intiter){
2071 SLiter = SplitLength.find(intiter->first);
2073 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2075 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2076 PropertyName = PropertyElement.GetNextToken();
2077 PropertyValue = PropertyElement.GetNextToken();
2079 intPrevValue = intiter->second;
2081 if (PropertyName == wxT("TYPE")){
2083 // Process each value in type and translate each
2086 // Strip out the quotes if they are there.
2088 size_t intPropertyValueLen = PropertyValue.Len();
2090 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2092 PropertyValue.Trim();
2093 PropertyValue.RemoveLast();
2097 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2099 PropertyValue.Remove(0, 1);
2103 TelTypeDetail = PropertyValue;
2109 for (int i = 0; i <= intPropertyValueLen; i++){
2113 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2115 if (intSplitsFound == 0){
2117 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2118 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2122 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2123 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2136 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2137 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2139 int intTypeSeek = 0;
2141 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2142 typeiter != TypeSplitPoints.end(); ++typeiter){
2144 wxString TypePropertyName;
2146 TSLiter = TypeSplitLength.find(typeiter->first);
2148 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2150 if (intTypeSeek == 0){
2155 TelTypeUI.Append(wxT(","));
2159 if (TypePropertyName == wxT("home")){
2161 PropType = PROPERTY_HOME;
2163 } else if (TypePropertyName == wxT("work")){
2165 PropType = PROPERTY_WORK;
2170 if (TypePropertyName == wxT("text")){
2172 TelTypeUI.Append(_("text"));
2175 } else if (TypePropertyName == wxT("voice")){
2177 TelTypeUI.Append(_("voice"));
2180 } else if (TypePropertyName == wxT("fax")){
2182 TelTypeUI.Append(_("fax"));
2185 } else if (TypePropertyName == wxT("cell")){
2187 TelTypeUI.Append(_("mobile"));
2190 } else if (TypePropertyName == wxT("video")){
2192 TelTypeUI.Append(_("video"));
2195 } else if (TypePropertyName == wxT("pager")){
2197 TelTypeUI.Append(_("pager"));
2200 } else if (TypePropertyName == wxT("textphone")){
2202 TelTypeUI.Append(_("textphone"));
2213 std::map<int, wxString> *TelephoneList = NULL;
2214 std::map<int, wxString> *TelephoneListType = NULL;
2215 std::map<int, wxString> *TelephoneListAltID = NULL;
2216 std::map<int, wxString> *TelephoneListPID = NULL;
2217 std::map<int, wxString> *TelephoneListTokens = NULL;
2218 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2219 std::map<int, int> *TelephoneListPref = NULL;
2223 TelephoneList = &GeneralTelephoneList;
2224 TelephoneListType = &GeneralTelephoneListType;
2225 TelephoneListAltID = &GeneralTelephoneListAltID;
2226 TelephoneListPID = &GeneralTelephoneListPID;
2227 TelephoneListTokens = &GeneralTelephoneListTokens;
2228 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2229 TelephoneListPref = &GeneralTelephoneListPref;
2232 TelephoneList = &HomeTelephoneList;
2233 TelephoneListType = &HomeTelephoneListType;
2234 TelephoneListAltID = &HomeTelephoneListAltID;
2235 TelephoneListPID = &HomeTelephoneListPID;
2236 TelephoneListTokens = &HomeTelephoneListTokens;
2237 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2238 TelephoneListPref = &HomeTelephoneListPref;
2241 TelephoneList = &BusinessTelephoneList;
2242 TelephoneListType = &BusinessTelephoneListType;
2243 TelephoneListAltID = &BusinessTelephoneListAltID;
2244 TelephoneListPID = &BusinessTelephoneListPID;
2245 TelephoneListTokens = &BusinessTelephoneListTokens;
2246 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2247 TelephoneListPref = &BusinessTelephoneListPref;
2251 // Process the properties.
2253 bool FirstToken = TRUE;
2256 SplitPoints.clear();
2257 SplitLength.clear();
2259 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2263 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2264 intiter != SplitPoints.end(); ++intiter){
2266 SLiter = SplitLength.find(intiter->first);
2268 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2270 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2271 PropertyName = PropertyElement.GetNextToken();
2272 PropertyValue = PropertyElement.GetNextToken();
2274 intPrevValue = intiter->second;
2276 CaptureString(&PropertyValue, FALSE);
2278 // Process properties.
2280 if (PropertyName == wxT("ALTID")){
2282 TelephoneListAltID->erase(*TelephoneCount);
2283 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2285 } else if (PropertyName == wxT("PID")){
2287 TelephoneListPID->erase(*TelephoneCount);
2288 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2290 } else if (PropertyName == wxT("PREF")){
2292 int PriorityNumber = 0;
2293 bool ValidNumber = TRUE;
2296 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2299 catch(std::invalid_argument &e){
2300 ValidNumber = FALSE;
2303 if (ValidNumber == TRUE){
2305 TelephoneListPref->erase(*TelephoneCount);
2306 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2312 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2314 if (FirstToken == TRUE){
2316 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2321 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2331 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2332 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2334 // Add the name token data.
2336 if (!PropertyTokens.IsEmpty()){
2338 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2344 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2346 std::map<int, int> SplitPoints;
2347 std::map<int, int> SplitLength;
2349 int intPrevValue = 6;
2352 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2356 PropertyType PropType = PROPERTY_NONE;
2358 // Look for type before continuing.
2360 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2362 std::map<int, wxString> *LanguageList = NULL;
2363 std::map<int, wxString> *LanguageListType = NULL;
2364 std::map<int, wxString> *LanguageListAltID = NULL;
2365 std::map<int, wxString> *LanguageListPID = NULL;
2366 std::map<int, wxString> *LanguageListTokens = NULL;
2367 std::map<int, int> *LanguageListPref = NULL;
2371 LanguageList = &GeneralLanguageList;
2372 LanguageListType = &GeneralLanguageListType;
2373 LanguageListAltID = &GeneralLanguageListAltID;
2374 LanguageListPID = &GeneralLanguageListPID;
2375 LanguageListTokens = &GeneralLanguageListTokens;
2376 LanguageListPref = &GeneralLanguageListPref;
2379 LanguageList = &HomeLanguageList;
2380 LanguageListType = &HomeLanguageListType;
2381 LanguageListAltID = &HomeLanguageListAltID;
2382 LanguageListPID = &HomeLanguageListPID;
2383 LanguageListTokens = &HomeLanguageListTokens;
2384 LanguageListPref = &HomeLanguageListPref;
2387 LanguageList = &BusinessLanguageList;
2388 LanguageListType = &BusinessLanguageListType;
2389 LanguageListAltID = &BusinessLanguageListAltID;
2390 LanguageListPID = &BusinessLanguageListPID;
2391 LanguageListTokens = &BusinessLanguageListTokens;
2392 LanguageListPref = &BusinessLanguageListPref;
2398 std::map<int,int>::iterator SLiter;
2399 wxString PropertyData;
2400 wxString PropertyName;
2401 wxString PropertyValue;
2402 wxString PropertyTokens;
2403 bool FirstToken = TRUE;
2405 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2406 intiter != SplitPoints.end(); ++intiter){
2408 SLiter = SplitLength.find(intiter->first);
2410 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2412 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2413 PropertyName = PropertyElement.GetNextToken();
2414 PropertyValue = PropertyElement.GetNextToken();
2416 intPrevValue = intiter->second;
2418 CaptureString(&PropertyValue, FALSE);
2420 // Process properties.
2422 if (PropertyName == wxT("ALTID")){
2424 LanguageListAltID->erase(*LanguageCount);
2425 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2427 } else if (PropertyName == wxT("PID")){
2429 LanguageListPID->erase(*LanguageCount);
2430 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2432 } else if (PropertyName == wxT("PREF")){
2434 int PriorityNumber = 0;
2435 bool ValidNumber = TRUE;
2438 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2441 catch(std::invalid_argument &e){
2442 ValidNumber = FALSE;
2445 if (ValidNumber == TRUE){
2447 LanguageListPref->erase(*LanguageCount);
2448 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2454 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2456 if (FirstToken == TRUE){
2458 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2463 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2473 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2475 // Add the name token data.
2477 if (!PropertyTokens.IsEmpty()){
2479 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2485 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2487 std::map<int, int> SplitPoints;
2488 std::map<int, int> SplitLength;
2490 int intPrevValue = 5;
2493 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2497 PropertyType PropType = PROPERTY_NONE;
2499 // Look for type before continuing.
2501 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2503 std::map<int, wxString> *GeopositionList = NULL;
2504 std::map<int, wxString> *GeopositionListType = NULL;
2505 std::map<int, wxString> *GeopositionListAltID = NULL;
2506 std::map<int, wxString> *GeopositionListPID = NULL;
2507 std::map<int, wxString> *GeopositionListTokens = NULL;
2508 std::map<int, wxString> *GeopositionListMediatype = NULL;
2509 std::map<int, int> *GeopositionListPref = NULL;
2513 GeopositionList = &GeneralGeographyList;
2514 GeopositionListType = &GeneralGeographyListType;
2515 GeopositionListAltID = &GeneralGeographyListAltID;
2516 GeopositionListPID = &GeneralGeographyListPID;
2517 GeopositionListTokens = &GeneralGeographyListTokens;
2518 GeopositionListMediatype = &GeneralGeographyListMediatype;
2519 GeopositionListPref = &GeneralGeographyListPref;
2522 GeopositionList = &HomeGeographyList;
2523 GeopositionListType = &HomeGeographyListType;
2524 GeopositionListAltID = &HomeGeographyListAltID;
2525 GeopositionListPID = &HomeGeographyListPID;
2526 GeopositionListTokens = &HomeGeographyListTokens;
2527 GeopositionListMediatype = &HomeGeographyListMediatype;
2528 GeopositionListPref = &HomeGeographyListPref;
2531 GeopositionList = &BusinessGeographyList;
2532 GeopositionListType = &BusinessGeographyListType;
2533 GeopositionListAltID = &BusinessGeographyListAltID;
2534 GeopositionListPID = &BusinessGeographyListPID;
2535 GeopositionListTokens = &BusinessGeographyListTokens;
2536 GeopositionListMediatype = &BusinessGeographyListMediatype;
2537 GeopositionListPref = &BusinessGeographyListPref;
2543 std::map<int,int>::iterator SLiter;
2544 wxString PropertyData;
2545 wxString PropertyName;
2546 wxString PropertyValue;
2547 wxString PropertyTokens;
2548 bool FirstToken = TRUE;
2550 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2551 intiter != SplitPoints.end(); ++intiter){
2553 SLiter = SplitLength.find(intiter->first);
2555 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2557 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2558 PropertyName = PropertyElement.GetNextToken();
2559 PropertyValue = PropertyElement.GetNextToken();
2561 intPrevValue = intiter->second;
2563 CaptureString(&PropertyValue, FALSE);
2565 // Process properties.
2567 if (PropertyName == wxT("ALTID")){
2569 GeopositionListAltID->erase(*GeographicCount);
2570 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2572 } else if (PropertyName == wxT("PID")){
2574 GeopositionListPID->erase(*GeographicCount);
2575 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2577 } else if (PropertyName == wxT("MEDIATYPE")){
2579 GeopositionListMediatype->erase(*GeographicCount);
2580 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2582 } else if (PropertyName == wxT("PREF")){
2584 int PriorityNumber = 0;
2585 bool ValidNumber = TRUE;
2588 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2591 catch(std::invalid_argument &e){
2592 ValidNumber = FALSE;
2595 if (ValidNumber == TRUE){
2597 GeopositionListPref->erase(*GeographicCount);
2598 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2604 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2606 if (FirstToken == TRUE){
2608 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2613 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2623 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2625 // Add the name token data.
2627 if (!PropertyTokens.IsEmpty()){
2629 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2635 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2637 size_t intPropertyLen = PropertySeg1.Len();
2638 std::map<int, int> SplitPoints;
2639 std::map<int, int> SplitLength;
2640 std::map<int, int>::iterator SLiter;
2641 wxString PropertyData;
2642 wxString PropertyName;
2643 wxString PropertyValue;
2644 wxString PropertyTokens;
2645 wxString RelatedType;
2646 wxString RelatedTypeOriginal;
2647 wxString RelatedName;
2648 bool FirstToken = TRUE;
2649 int intSplitsFound = 0;
2650 int intSplitSize = 0;
2651 int intPrevValue = 9;
2655 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2659 // Look for type before continuing.
2661 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2662 intiter != SplitPoints.end(); ++intiter){
2664 SLiter = SplitLength.find(intiter->first);
2666 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2668 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2669 PropertyName = PropertyElement.GetNextToken();
2670 PropertyValue = PropertyElement.GetNextToken();
2672 intPrevValue = intiter->second;
2676 RelatedTypeOriginal = PropertyValue;
2678 if (PropertyName == wxT("TYPE")){
2680 if (PropertyValue == wxT("contact")){
2682 RelatedType = _("Contact");
2684 } else if (PropertyValue == wxT("acquaintance")){
2686 RelatedType = _("Acquaintance");
2688 } else if (PropertyValue == wxT("friend")){
2690 RelatedType = _("Friend");
2692 } else if (PropertyValue == wxT("met")){
2694 RelatedType = _("Met");
2696 } else if (PropertyValue == wxT("co-worker")){
2698 RelatedType = _("Co-worker");
2700 } else if (PropertyValue == wxT("colleague")){
2702 RelatedType = _("Colleague");
2704 } else if (PropertyValue == wxT("co-resident")){
2706 RelatedType = _("Co-resident");
2708 } else if (PropertyValue == wxT("neighbor")){
2710 RelatedType = _("Neighbour");
2712 } else if (PropertyValue == wxT("child")){
2714 RelatedType = _("Child");
2716 } else if (PropertyValue == wxT("parent")){
2718 RelatedType = _("Parent");
2720 } else if (PropertyValue == wxT("sibling")){
2722 RelatedType = _("Sibling");
2724 } else if (PropertyValue == wxT("spouse")){
2726 RelatedType = _("Spouse");
2728 } else if (PropertyValue == wxT("kin")){
2730 RelatedType = _("Kin");
2732 } else if (PropertyValue == wxT("muse")){
2734 RelatedType = _("Muse");
2736 } else if (PropertyValue == wxT("crush")){
2738 RelatedType = _("Crush");
2740 } else if (PropertyValue == wxT("date")){
2742 RelatedType = _("Date");
2744 } else if (PropertyValue == wxT("sweetheart")){
2746 RelatedType = _("Sweetheart");
2748 } else if (PropertyValue == wxT("me")){
2750 RelatedType = _("Me");
2752 } else if (PropertyValue == wxT("agent")){
2754 RelatedType = _("Agent");
2756 } else if (PropertyValue == wxT("emergency")){
2758 RelatedType = _("Emergency");
2762 RelatedType = PropertyValue;
2772 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2773 intiter != SplitPoints.end(); ++intiter){
2775 SLiter = SplitLength.find(intiter->first);
2777 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2779 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2780 PropertyName = PropertyElement.GetNextToken();
2781 PropertyValue = PropertyElement.GetNextToken();
2783 intPrevValue = intiter->second;
2785 // Process properties.
2787 size_t intPropertyValueLen = PropertyValue.Len();
2789 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2791 PropertyValue.Trim();
2792 PropertyValue.RemoveLast();
2796 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2798 PropertyValue.Remove(0, 1);
2802 CaptureString(&PropertyValue, FALSE);
2804 if (PropertyName == wxT("ALTID")){
2806 GeneralRelatedListAltID.erase(*RelatedCount);
2807 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2809 } else if (PropertyName == wxT("PID")){
2811 GeneralRelatedListPID.erase(*RelatedCount);
2812 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2814 } else if (PropertyName == wxT("PREF")){
2816 int PriorityNumber = 0;
2817 bool ValidNumber = TRUE;
2820 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2823 catch(std::invalid_argument &e){
2824 ValidNumber = FALSE;
2827 if (ValidNumber == TRUE){
2829 GeneralRelatedListPref.erase(*RelatedCount);
2830 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2834 } else if (PropertyName == wxT("LANGUAGE")){
2836 GeneralRelatedListLanguage.erase(*RelatedCount);
2837 GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2839 } else if (PropertyName != wxT("TYPE")) {
2841 // Something else we don't know about so append
2842 // to the tokens variable.
2844 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2846 if (FirstToken == TRUE){
2848 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2853 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2863 // Add the data to the General/Home/Work address variables.
2865 GeneralRelatedList.erase(*RelatedCount);
2866 GeneralRelatedListRelType.erase(*RelatedCount);
2867 GeneralRelatedListType.erase(*RelatedCount);
2868 GeneralRelatedListTokens.erase(*RelatedCount);
2869 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2870 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2871 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2872 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2876 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2878 std::map<int, int> SplitPoints;
2879 std::map<int, int> SplitLength;
2880 std::map<int, int>::iterator SLiter;
2881 wxString PropertyData;
2882 wxString PropertyName;
2883 wxString PropertyValue;
2884 wxString PropertyTokens;
2885 bool FirstToken = TRUE;
2886 int intPrevValue = 5;
2891 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2895 PropertyType PropType = PROPERTY_NONE;
2897 // Look for type before continuing.
2899 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2901 // Setup the pointers.
2903 std::map<int, wxString> *WebsiteList = NULL;
2904 std::map<int, wxString> *WebsiteListAltID = NULL;
2905 std::map<int, wxString> *WebsiteListPID = NULL;
2906 std::map<int, wxString> *WebsiteListType = NULL;
2907 std::map<int, wxString> *WebsiteListTokens = NULL;
2908 std::map<int, wxString> *WebsiteListMediatype = NULL;
2909 std::map<int, int> *WebsiteListPref = NULL;
2911 // Setup blank lines for later on.
2915 WebsiteList = &GeneralWebsiteList;
2916 WebsiteListType = &GeneralWebsiteListType;
2917 WebsiteListAltID = &GeneralWebsiteListAltID;
2918 WebsiteListPID = &GeneralWebsiteListPID;
2919 WebsiteListTokens = &GeneralWebsiteListTokens;
2920 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2921 WebsiteListPref = &GeneralWebsiteListPref;
2924 WebsiteList = &HomeWebsiteList;
2925 WebsiteListType = &HomeWebsiteListType;
2926 WebsiteListAltID = &HomeWebsiteListAltID;
2927 WebsiteListPID = &HomeWebsiteListPID;
2928 WebsiteListTokens = &HomeWebsiteListTokens;
2929 WebsiteListMediatype = &HomeWebsiteListMediatype;
2930 WebsiteListPref = &HomeWebsiteListPref;
2933 WebsiteList = &BusinessWebsiteList;
2934 WebsiteListType = &BusinessWebsiteListType;
2935 WebsiteListAltID = &BusinessWebsiteListAltID;
2936 WebsiteListPID = &BusinessWebsiteListPID;
2937 WebsiteListTokens = &BusinessWebsiteListTokens;
2938 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2939 WebsiteListPref = &BusinessWebsiteListPref;
2945 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2946 intiter != SplitPoints.end(); ++intiter){
2948 SLiter = SplitLength.find(intiter->first);
2950 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2952 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2953 PropertyName = PropertyElement.GetNextToken();
2954 PropertyValue = PropertyElement.GetNextToken();
2956 intPrevValue = intiter->second;
2958 // Process properties.
2960 size_t intPropertyValueLen = PropertyValue.Len();
2962 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2964 PropertyValue.Trim();
2965 PropertyValue.RemoveLast();
2969 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2971 PropertyValue.Remove(0, 1);
2975 CaptureString(&PropertyValue, FALSE);
2977 if (PropertyName == wxT("ALTID")){
2979 WebsiteListAltID->erase(*URLCount);
2980 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2982 } else if (PropertyName == wxT("PID")){
2984 WebsiteListPID->erase(*URLCount);
2985 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2987 } else if (PropertyName == wxT("PREF")){
2989 int PriorityNumber = 0;
2990 bool ValidNumber = TRUE;
2993 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2996 catch(std::invalid_argument &e){
2997 ValidNumber = FALSE;
3000 if (ValidNumber == TRUE){
3002 WebsiteListPref->erase(*URLCount);
3003 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3007 } else if (PropertyName == wxT("MEDIATYPE")){
3009 WebsiteListMediatype->erase(*URLCount);
3010 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3014 // Something else we don't know about so append
3015 // to the tokens variable.
3017 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3019 if (FirstToken == TRUE){
3021 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3026 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3036 // Add the data to the General/Home/Work address variables.
3038 CaptureString(&PropertySeg2, FALSE);
3040 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3042 if (!PropertyTokens.IsEmpty()){
3044 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3050 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3052 std::map<int, int> SplitPoints;
3053 std::map<int, int> SplitLength;
3054 std::map<int, int>::iterator SLiter;
3055 wxString PropertyData;
3056 wxString PropertyName;
3057 wxString PropertyValue;
3058 wxString PropertyTokens;
3059 bool FirstToken = TRUE;
3060 int intPrevValue = 7;
3065 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3069 PropertyType PropType = PROPERTY_NONE;
3071 // Look for type before continuing.
3073 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3075 // Setup the pointers.
3077 std::map<int, wxString> *TitleList = NULL;
3078 std::map<int, wxString> *TitleListAltID = NULL;
3079 std::map<int, wxString> *TitleListPID = NULL;
3080 std::map<int, wxString> *TitleListType = NULL;
3081 std::map<int, wxString> *TitleListTokens = NULL;
3082 std::map<int, wxString> *TitleListLanguage = NULL;
3083 std::map<int, int> *TitleListPref = NULL;
3085 // Setup blank lines for later on.
3089 TitleList = &GeneralTitleList;
3090 TitleListType = &GeneralTitleListType;
3091 TitleListAltID = &GeneralTitleListAltID;
3092 TitleListPID = &GeneralTitleListPID;
3093 TitleListTokens = &GeneralTitleListTokens;
3094 TitleListLanguage = &GeneralTitleListLanguage;
3095 TitleListPref = &GeneralTitleListPref;
3098 TitleList = &HomeTitleList;
3099 TitleListType = &HomeTitleListType;
3100 TitleListAltID = &HomeTitleListAltID;
3101 TitleListPID = &HomeTitleListPID;
3102 TitleListTokens = &HomeTitleListTokens;
3103 TitleListLanguage = &HomeTitleListLanguage;
3104 TitleListPref = &HomeTitleListPref;
3107 TitleList = &BusinessTitleList;
3108 TitleListType = &BusinessTitleListType;
3109 TitleListAltID = &BusinessTitleListAltID;
3110 TitleListPID = &BusinessTitleListPID;
3111 TitleListTokens = &BusinessTitleListTokens;
3112 TitleListLanguage = &BusinessTitleListLanguage;
3113 TitleListPref = &BusinessTitleListPref;
3119 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3120 intiter != SplitPoints.end(); ++intiter){
3122 SLiter = SplitLength.find(intiter->first);
3124 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3126 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3127 PropertyName = PropertyElement.GetNextToken();
3128 PropertyValue = PropertyElement.GetNextToken();
3130 intPrevValue = intiter->second;
3132 // Process properties.
3134 size_t intPropertyValueLen = PropertyValue.Len();
3136 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3138 PropertyValue.Trim();
3139 PropertyValue.RemoveLast();
3143 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3145 PropertyValue.Remove(0, 1);
3149 CaptureString(&PropertyValue, FALSE);
3151 if (PropertyName == wxT("ALTID")){
3153 TitleListAltID->erase(*TitleCount);
3154 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3156 } else if (PropertyName == wxT("PID")){
3158 TitleListPID->erase(*TitleCount);
3159 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3161 } else if (PropertyName == wxT("PREF")){
3163 int PriorityNumber = 0;
3164 bool ValidNumber = TRUE;
3167 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3170 catch(std::invalid_argument &e){
3171 ValidNumber = FALSE;
3174 if (ValidNumber == TRUE){
3176 TitleListPref->erase(*TitleCount);
3177 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3181 } else if (PropertyName == wxT("LANGUAGE")){
3183 TitleListLanguage->erase(*TitleCount);
3184 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3188 // Something else we don't know about so append
3189 // to the tokens variable.
3191 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3193 if (FirstToken == TRUE){
3195 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3200 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3210 // Add the data to the General/Home/Work address variables.
3212 CaptureString(&PropertySeg2, FALSE);
3214 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3216 if (!PropertyTokens.IsEmpty()){
3218 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3224 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3226 std::map<int, int> SplitPoints;
3227 std::map<int, int> SplitLength;
3228 std::map<int, int>::iterator SLiter;
3229 wxString PropertyData;
3230 wxString PropertyName;
3231 wxString PropertyValue;
3232 wxString PropertyTokens;
3233 bool FirstToken = TRUE;
3234 int intPrevValue = 6;
3239 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3243 PropertyType PropType = PROPERTY_NONE;
3245 // Look for type before continuing.
3247 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3249 // Setup the pointers.
3251 std::map<int, wxString> *RoleList = NULL;
3252 std::map<int, wxString> *RoleListAltID = NULL;
3253 std::map<int, wxString> *RoleListPID = NULL;
3254 std::map<int, wxString> *RoleListType = NULL;
3255 std::map<int, wxString> *RoleListTokens = NULL;
3256 std::map<int, wxString> *RoleListLanguage = NULL;
3257 std::map<int, int> *RoleListPref = NULL;
3259 // Setup blank lines for later on.
3263 RoleList = &GeneralRoleList;
3264 RoleListType = &GeneralRoleListType;
3265 RoleListAltID = &GeneralRoleListAltID;
3266 RoleListPID = &GeneralRoleListPID;
3267 RoleListTokens = &GeneralRoleListTokens;
3268 RoleListLanguage = &GeneralRoleListLanguage;
3269 RoleListPref = &GeneralRoleListPref;
3272 RoleList = &HomeRoleList;
3273 RoleListType = &HomeRoleListType;
3274 RoleListAltID = &HomeRoleListAltID;
3275 RoleListPID = &HomeRoleListPID;
3276 RoleListTokens = &HomeRoleListTokens;
3277 RoleListLanguage = &HomeRoleListLanguage;
3278 RoleListPref = &HomeRoleListPref;
3281 RoleList = &BusinessRoleList;
3282 RoleListType = &BusinessRoleListType;
3283 RoleListAltID = &BusinessRoleListAltID;
3284 RoleListPID = &BusinessRoleListPID;
3285 RoleListTokens = &BusinessRoleListTokens;
3286 RoleListLanguage = &BusinessRoleListLanguage;
3287 RoleListPref = &BusinessRoleListPref;
3293 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3294 intiter != SplitPoints.end(); ++intiter){
3296 SLiter = SplitLength.find(intiter->first);
3298 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3300 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3301 PropertyName = PropertyElement.GetNextToken();
3302 PropertyValue = PropertyElement.GetNextToken();
3304 intPrevValue = intiter->second;
3306 // Process properties.
3308 size_t intPropertyValueLen = PropertyValue.Len();
3310 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3312 PropertyValue.Trim();
3313 PropertyValue.RemoveLast();
3317 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3319 PropertyValue.Remove(0, 1);
3323 CaptureString(&PropertyValue, FALSE);
3325 if (PropertyName == wxT("ALTID")){
3327 RoleListAltID->erase(*RoleCount);
3328 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3330 } else if (PropertyName == wxT("PID")){
3332 RoleListPID->erase(*RoleCount);
3333 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3335 } else if (PropertyName == wxT("PREF")){
3337 int PriorityNumber = 0;
3338 bool ValidNumber = TRUE;
3341 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3344 catch(std::invalid_argument &e){
3345 ValidNumber = FALSE;
3348 if (ValidNumber == TRUE){
3350 RoleListPref->erase(*RoleCount);
3351 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3355 } else if (PropertyName == wxT("LANGUAGE")){
3357 RoleListLanguage->erase(*RoleCount);
3358 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3362 // Something else we don't know about so append
3363 // to the tokens variable.
3365 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3367 if (FirstToken == TRUE){
3369 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3374 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3384 // Add the data to the General/Home/Work address variables.
3386 CaptureString(&PropertySeg2, FALSE);
3388 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3390 if (!PropertyTokens.IsEmpty()){
3392 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3398 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3400 std::map<int, int> SplitPoints;
3401 std::map<int, int> SplitLength;
3402 std::map<int, int>::iterator SLiter;
3403 wxString PropertyData;
3404 wxString PropertyName;
3405 wxString PropertyValue;
3406 wxString PropertyTokens;
3407 bool FirstToken = TRUE;
3408 int intPrevValue = 5;
3413 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3417 PropertyType PropType = PROPERTY_NONE;
3419 // Look for type before continuing.
3421 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3423 // Setup the pointers.
3425 std::map<int, wxString> *OrganisationsList = NULL;
3426 std::map<int, wxString> *OrganisationsListAltID = NULL;
3427 std::map<int, wxString> *OrganisationsListPID = NULL;
3428 std::map<int, wxString> *OrganisationsListType = NULL;
3429 std::map<int, wxString> *OrganisationsListTokens = NULL;
3430 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3431 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3432 std::map<int, int> *OrganisationsListPref = NULL;
3434 // Setup blank lines for later on.
3438 OrganisationsList = &GeneralOrganisationsList;
3439 OrganisationsListType = &GeneralOrganisationsListType;
3440 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3441 OrganisationsListPID = &GeneralOrganisationsListPID;
3442 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3443 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3444 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3445 OrganisationsListPref = &GeneralOrganisationsListPref;
3448 OrganisationsList = &HomeOrganisationsList;
3449 OrganisationsListType = &HomeOrganisationsListType;
3450 OrganisationsListAltID = &HomeOrganisationsListAltID;
3451 OrganisationsListPID = &HomeOrganisationsListPID;
3452 OrganisationsListTokens = &HomeOrganisationsListTokens;
3453 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3454 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3455 OrganisationsListPref = &HomeOrganisationsListPref;
3458 OrganisationsList = &BusinessOrganisationsList;
3459 OrganisationsListType = &BusinessOrganisationsListType;
3460 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3461 OrganisationsListPID = &BusinessOrganisationsListPID;
3462 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3463 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3464 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3465 OrganisationsListPref = &BusinessOrganisationsListPref;
3471 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3472 intiter != SplitPoints.end(); ++intiter){
3474 SLiter = SplitLength.find(intiter->first);
3476 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3478 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3479 PropertyName = PropertyElement.GetNextToken();
3480 PropertyValue = PropertyElement.GetNextToken();
3482 intPrevValue = intiter->second;
3484 // Process properties.
3486 size_t intPropertyValueLen = PropertyValue.Len();
3488 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3490 PropertyValue.Trim();
3491 PropertyValue.RemoveLast();
3495 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3497 PropertyValue.Remove(0, 1);
3501 CaptureString(&PropertyValue, FALSE);
3503 if (PropertyName == wxT("ALTID")){
3505 OrganisationsListAltID->erase(*OrganisationCount);
3506 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3508 } else if (PropertyName == wxT("PID")){
3510 OrganisationsListPID->erase(*OrganisationCount);
3511 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3513 } else if (PropertyName == wxT("SORT-AS")){
3515 OrganisationsListSortAs->erase(*OrganisationCount);
3516 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3518 } else if (PropertyName == wxT("PREF")){
3520 int PriorityNumber = 0;
3521 bool ValidNumber = TRUE;
3524 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3527 catch(std::invalid_argument &e){
3528 ValidNumber = FALSE;
3531 if (ValidNumber == TRUE){
3533 OrganisationsListPref->erase(*OrganisationCount);
3534 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3538 } else if (PropertyName == wxT("LANGUAGE")){
3540 OrganisationsListLanguage->erase(*OrganisationCount);
3541 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3545 // Something else we don't know about so append
3546 // to the tokens variable.
3548 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3550 if (FirstToken == TRUE){
3552 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3557 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3567 // Add the data to the General/Home/Work address variables.
3569 CaptureString(&PropertySeg2, FALSE);
3571 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3573 if (!PropertyTokens.IsEmpty()){
3575 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3581 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3583 std::map<int, int> SplitPoints;
3584 std::map<int, int> SplitLength;
3585 std::map<int, int>::iterator SLiter;
3586 wxString PropertyData;
3587 wxString PropertyName;
3588 wxString PropertyValue;
3589 wxString PropertyTokens;
3590 bool FirstToken = TRUE;
3591 int intPrevValue = 6;
3596 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3600 PropertyType PropType = PROPERTY_NONE;
3602 // Look for type before continuing.
3604 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3606 // Setup the pointers.
3608 std::map<int, wxString> *NoteList = NULL;
3609 std::map<int, wxString> *NoteListAltID = NULL;
3610 std::map<int, wxString> *NoteListPID = NULL;
3611 std::map<int, wxString> *NoteListType = NULL;
3612 std::map<int, wxString> *NoteListTokens = NULL;
3613 std::map<int, wxString> *NoteListLanguage = NULL;
3614 std::map<int, int> *NoteListPref = NULL;
3616 // Setup blank lines for later on.
3620 NoteList = &GeneralNoteList;
3621 NoteListType = &GeneralNoteListType;
3622 NoteListAltID = &GeneralNoteListAltID;
3623 NoteListPID = &GeneralNoteListPID;
3624 NoteListTokens = &GeneralNoteListTokens;
3625 NoteListLanguage = &GeneralNoteListLanguage;
3626 NoteListPref = &GeneralNoteListPref;
3629 NoteList = &HomeNoteList;
3630 NoteListType = &HomeNoteListType;
3631 NoteListAltID = &HomeNoteListAltID;
3632 NoteListPID = &HomeNoteListPID;
3633 NoteListTokens = &HomeNoteListTokens;
3634 NoteListLanguage = &HomeNoteListLanguage;
3635 NoteListPref = &HomeNoteListPref;
3638 NoteList = &BusinessNoteList;
3639 NoteListType = &BusinessNoteListType;
3640 NoteListAltID = &BusinessNoteListAltID;
3641 NoteListPID = &BusinessNoteListPID;
3642 NoteListTokens = &BusinessNoteListTokens;
3643 NoteListLanguage = &BusinessNoteListLanguage;
3644 NoteListPref = &BusinessNoteListPref;
3650 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3651 intiter != SplitPoints.end(); ++intiter){
3653 SLiter = SplitLength.find(intiter->first);
3655 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3657 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3658 PropertyName = PropertyElement.GetNextToken();
3659 PropertyValue = PropertyElement.GetNextToken();
3661 intPrevValue = intiter->second;
3663 // Process properties.
3665 size_t intPropertyValueLen = PropertyValue.Len();
3667 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3669 PropertyValue.Trim();
3670 PropertyValue.RemoveLast();
3674 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3676 PropertyValue.Remove(0, 1);
3680 CaptureString(&PropertyValue, FALSE);
3682 if (PropertyName == wxT("ALTID")){
3684 NoteListAltID->erase(*NoteCount);
3685 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3687 } else if (PropertyName == wxT("PID")){
3689 NoteListPID->erase(*NoteCount);
3690 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3692 } else if (PropertyName == wxT("PREF")){
3694 int PriorityNumber = 0;
3695 bool ValidNumber = TRUE;
3698 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3701 catch(std::invalid_argument &e){
3702 ValidNumber = FALSE;
3705 if (ValidNumber == TRUE){
3707 NoteListPref->erase(*NoteCount);
3708 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3712 } else if (PropertyName == wxT("LANGUAGE")){
3714 NoteListLanguage->erase(*NoteCount);
3715 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3719 // Something else we don't know about so append
3720 // to the tokens variable.
3722 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3724 if (FirstToken == TRUE){
3726 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3731 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3741 // Add the data to the General/Home/Work address variables.
3743 CaptureString(&PropertySeg2, FALSE);
3745 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3747 if (!PropertyTokens.IsEmpty()){
3749 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3755 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3757 std::map<int, int> SplitPoints;
3758 std::map<int, int> SplitLength;
3759 std::map<int, int>::iterator SLiter;
3760 wxString PropertyData;
3761 wxString PropertyName;
3762 wxString PropertyValue;
3763 wxString PropertyTokens;
3764 bool FirstToken = TRUE;
3765 int intPrevValue = 12;
3770 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3774 PropertyType PropType = PROPERTY_NONE;
3776 // Look for type before continuing.
3778 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3780 // Setup blank lines for later on.
3786 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3789 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3795 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3796 intiter != SplitPoints.end(); ++intiter){
3798 SLiter = SplitLength.find(intiter->first);
3800 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3802 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3803 PropertyName = PropertyElement.GetNextToken();
3804 PropertyValue = PropertyElement.GetNextToken();
3806 intPrevValue = intiter->second;
3808 // Process properties.
3810 size_t intPropertyValueLen = PropertyValue.Len();
3812 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3814 PropertyValue.Trim();
3815 PropertyValue.RemoveLast();
3819 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3821 PropertyValue.Remove(0, 1);
3825 CaptureString(&PropertyValue, FALSE);
3827 if (PropertyName == wxT("ALTID")){
3829 CategoriesListAltID.erase(*CategoryCount);
3830 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3832 } else if (PropertyName == wxT("PID")){
3834 CategoriesListPID.erase(*CategoryCount);
3835 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3837 } else if (PropertyName == wxT("PREF")){
3839 int PriorityNumber = 0;
3840 bool ValidNumber = TRUE;
3843 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3846 catch(std::invalid_argument &e){
3847 ValidNumber = FALSE;
3850 if (ValidNumber == TRUE){
3852 CategoriesListPref.erase(*CategoryCount);
3853 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3857 } else if (PropertyName == wxT("LANGUAGE")){
3859 CategoriesListLanguage.erase(*CategoryCount);
3860 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3864 // Something else we don't know about so append
3865 // to the tokens variable.
3867 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3869 if (FirstToken == TRUE){
3871 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3876 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3886 // Deal with multiple categories.
3888 int intOrigCatCount = *CategoryCount;
3889 bool FirstCategoryProcessed = TRUE;
3890 bool AfterFirstToken = FALSE;
3891 int intSplitSize = 0;
3892 int intSplitsFound = 0;
3893 int intSplitSeek = 0;
3894 int intPropertyLen = PropertySeg2.Len();
3896 SplitPoints.clear();
3897 SplitLength.clear();
3900 for (int i = 0; i <= intPropertyLen; i++){
3902 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3910 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3912 if (AfterFirstToken == TRUE){
3914 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3915 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3919 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3920 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3921 AfterFirstToken = TRUE;
3933 if (SplitPoints.size() > 0){
3935 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3936 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3940 if (SplitPoints.size() == 0){
3942 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3944 if (!PropertyTokens.IsEmpty()){
3946 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3952 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3953 intiter != SplitPoints.end(); ++intiter){
3955 SLiter = SplitLength.find(intiter->first);
3957 intPrevValue = intiter->second;
3959 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3961 // Add the data to the General/Home/Work address variables.
3963 // Trim any whitespace from the start and end.
3965 PropertyData = PropertyData.Trim(FALSE);
3966 PropertyData = PropertyData.Trim(TRUE);
3968 CaptureString(&PropertyData, FALSE);
3970 if (FirstCategoryProcessed == TRUE){
3972 FirstCategoryProcessed = FALSE;
3974 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3976 if (!PropertyTokens.IsEmpty()){
3978 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3988 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3990 if (!PropertyTokens.IsEmpty()){
3992 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3998 // Copy the properties to each of the categories (if it exists).
4000 if (!PropertyTokens.IsEmpty()){
4002 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4006 // Check if ALTID was used.
4008 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4010 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4014 // Check if PID was used.
4016 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4018 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4022 // Check if PREF was used.
4024 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4026 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4030 // Check if LANGUAGE was used.
4032 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4034 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4038 // Check if TYPE was used.
4044 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4047 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4055 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4057 size_t intPropertyLen = PropertySeg1.Len();
4058 std::map<int, int> SplitPoints;
4059 std::map<int, int> SplitLength;
4060 std::map<int, int>::iterator SLiter;
4061 wxString PropertyData;
4062 wxString PropertyName;
4063 wxString PropertyValue;
4064 wxString PropertyTokens;
4065 bool FirstToken = TRUE;
4066 int intSplitsFound = 0;
4067 int intSplitSize = 0;
4068 int intPrevValue = 7;
4072 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4076 PropertyType PropType = PROPERTY_NONE;
4078 // Look for type before continuing.
4080 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4084 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4085 intiter != SplitPoints.end(); ++intiter){
4087 SLiter = SplitLength.find(intiter->first);
4089 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4091 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4092 PropertyName = PropertyElement.GetNextToken();
4093 PropertyValue = PropertyElement.GetNextToken();
4095 intPrevValue = intiter->second;
4097 // Process properties.
4099 size_t intPropertyValueLen = PropertyValue.Len();
4101 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4103 PropertyValue.Trim();
4104 PropertyValue.RemoveLast();
4108 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4110 PropertyValue.Remove(0, 1);
4114 CaptureString(&PropertyValue, FALSE);
4116 if (PropertyName == wxT("ALTID")){
4118 PicturesListAltID.erase(*PhotoCount);
4119 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4121 } else if (PropertyName == wxT("PID")){
4123 PicturesListPID.erase(*PhotoCount);
4124 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4126 } else if (PropertyName == wxT("PREF")){
4128 int PriorityNumber = 0;
4129 bool ValidNumber = TRUE;
4132 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4135 catch(std::invalid_argument &e){
4136 ValidNumber = FALSE;
4139 if (ValidNumber == TRUE){
4141 PicturesListPref.erase(*PhotoCount);
4142 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4146 } else if (PropertyName == wxT("MEDIATYPE")){
4148 PicturesListMediatype.erase(*PhotoCount);
4149 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4153 // Something else we don't know about so append
4154 // to the tokens variable.
4156 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4158 if (FirstToken == TRUE){
4160 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4165 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4175 intPropertyLen = PropertySeg2.Len();
4176 SplitPoints.clear();
4177 SplitLength.clear();
4182 CaptureString(&PropertySeg2, FALSE);
4184 for (int i = 0; i <= intPropertyLen; i++){
4188 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4191 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4193 if (intSplitsFound == 6){
4195 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4200 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4210 wxString wxSPhotoURI;
4211 wxString wxSPhotoMIME;
4212 wxString wxSPhotoEncoding;
4213 wxString wxSPhotoData;
4214 std::string base64enc;
4216 if (intSplitsFound == 0){
4220 std::map<int, int>::iterator striter;
4222 striter = SplitLength.find(1);
4224 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4226 while (wSTDataType.HasMoreTokens() == TRUE){
4228 wxSPhotoURI = wSTDataType.GetNextToken();
4229 wxSPhotoMIME = wSTDataType.GetNextToken();
4234 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4236 while (wSTDataInfo.HasMoreTokens() == TRUE){
4238 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4239 wxSPhotoData = wSTDataInfo.GetNextToken();
4240 base64enc = wxSPhotoData.mb_str();
4247 // Add the data to the General/Home/Work address variables.
4249 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4250 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4251 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4257 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4260 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4264 if (!PropertyTokens.IsEmpty()){
4266 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4272 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4274 size_t intPropertyLen = PropertySeg1.Len();
4275 std::map<int, int> SplitPoints;
4276 std::map<int, int> SplitLength;
4277 std::map<int, int>::iterator SLiter;
4278 wxString PropertyData;
4279 wxString PropertyName;
4280 wxString PropertyValue;
4281 wxString PropertyTokens;
4282 bool FirstToken = TRUE;
4283 int intSplitsFound = 0;
4284 int intSplitSize = 0;
4285 int intPrevValue = 6;
4289 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4293 PropertyType PropType = PROPERTY_NONE;
4295 // Look for type before continuing.
4297 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4301 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4302 intiter != SplitPoints.end(); ++intiter){
4304 SLiter = SplitLength.find(intiter->first);
4306 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4308 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4309 PropertyName = PropertyElement.GetNextToken();
4310 PropertyValue = PropertyElement.GetNextToken();
4312 intPrevValue = intiter->second;
4314 // Process properties.
4316 size_t intPropertyValueLen = PropertyValue.Len();
4318 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4320 PropertyValue.Trim();
4321 PropertyValue.RemoveLast();
4325 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4327 PropertyValue.Remove(0, 1);
4331 CaptureString(&PropertyValue, FALSE);
4333 if (PropertyName == wxT("ALTID")){
4335 LogosListAltID.erase(*LogoCount);
4336 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4338 } else if (PropertyName == wxT("PID")){
4340 LogosListPID.erase(*LogoCount);
4341 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4343 } else if (PropertyName == wxT("PREF")){
4345 int PriorityNumber = 0;
4346 bool ValidNumber = TRUE;
4349 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4352 catch(std::invalid_argument &e){
4353 ValidNumber = FALSE;
4356 if (ValidNumber == TRUE){
4358 LogosListPref.erase(*LogoCount);
4359 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4363 } else if (PropertyName == wxT("MEDIATYPE")){
4365 LogosListMediatype.erase(*LogoCount);
4366 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4370 // Something else we don't know about so append
4371 // to the tokens variable.
4373 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4375 if (FirstToken == TRUE){
4377 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4382 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4392 intPropertyLen = PropertySeg2.Len();
4393 SplitPoints.clear();
4394 SplitLength.clear();
4399 CaptureString(&PropertySeg2, FALSE);
4401 for (int i = 0; i <= intPropertyLen; i++){
4405 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4408 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4410 if (intSplitsFound == 6){
4412 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4417 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4427 wxString wxSPhotoURI;
4428 wxString wxSPhotoMIME;
4429 wxString wxSPhotoEncoding;
4430 wxString wxSPhotoData;
4431 std::string base64enc;
4433 if (intSplitsFound == 0){
4437 std::map<int, int>::iterator striter;
4439 striter = SplitLength.find(1);
4441 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4443 while (wSTDataType.HasMoreTokens() == TRUE){
4445 wxSPhotoURI = wSTDataType.GetNextToken();
4446 wxSPhotoMIME = wSTDataType.GetNextToken();
4451 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4453 while (wSTDataInfo.HasMoreTokens() == TRUE){
4455 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4456 wxSPhotoData = wSTDataInfo.GetNextToken();
4457 base64enc = wxSPhotoData.mb_str();
4464 // Add the data to the General/Home/Work address variables.
4466 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4467 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4468 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4474 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4477 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4481 if (!PropertyTokens.IsEmpty()){
4483 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4489 void SplitValues(wxString *PropertyLine,
4490 std::map<int,int> *SplitPoints,
4491 std::map<int,int> *SplitLength,
4494 size_t intPropertyLen = PropertyLine->Len();
4495 int intSplitsFound = 0;
4496 int intSplitSize = 0;
4497 int intSplitSeek = 0;
4499 for (int i = intSize; i <= intPropertyLen; i++){
4503 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4504 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4506 if (intSplitsFound == 0){
4508 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4512 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4516 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4526 if (intSplitsFound == 0){
4528 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4529 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4533 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4534 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4540 void CheckType(wxString *PropertySeg1,
4541 std::map<int,int> *SplitPoints,
4542 std::map<int,int> *SplitLength,
4544 PropertyType *PropType){
4546 wxString PropertyData;
4547 wxString PropertyName;
4548 wxString PropertyValue;
4549 std::map<int,int>::iterator SLiter;
4551 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
4552 intiter != SplitPoints->end(); ++intiter){
4554 SLiter = SplitLength->find(intiter->first);
4556 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4558 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4559 PropertyName = PropertyElement.GetNextToken();
4560 PropertyValue = PropertyElement.GetNextToken();
4562 *intPrevValue = intiter->second;
4564 if (PropertyName == wxT("TYPE")){
4566 if (PropertyValue == wxT("work")){
4568 *PropType = PROPERTY_WORK;
4570 } else if (PropertyValue == wxT("home")){
4572 *PropType = PROPERTY_HOME;
4576 *PropType = PROPERTY_NONE;