X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=4c2cbc6442b59b4a7a07daaeb18a85a758834c66;hb=b22d89925df6f435578ae08c37f91d73ee2bdda7;hp=66f42594d4daccf647c123e2dfc6f471d6b451e6;hpb=17d33f5a39d1b64be75d308a78467290e96b7e38;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 66f4259..4c2cbc6 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -110,6 +110,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int VendorCount = 0; int XTokenCount = 0; int XMLCount = 0; + int ClientPIDCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -247,6 +248,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessN(PropertySeg1, PropertySeg2); NameProcessed = TRUE; + } else if (Property == wxT("CLIENTPIDMAP")){ + + ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount); + ClientPIDCount++; + } else if (Property == wxT("NICKNAME")){ ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount); @@ -543,6 +549,7 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe wxString PropertyValue; wxString PropertyTokens; bool FirstToken = TRUE; + bool PropertyMatched = FALSE; int intSplitsFound = 0; int intSplitSize = 0; int intPrevValue = 8; @@ -593,58 +600,28 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe CaptureString(&PropertyValue, FALSE); - if (PropertyName == wxT("ALTID")){ - - SourceListAltID.erase(*SourceCount); - SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue)); + ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched); + ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched); + ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched); + ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched); - } else if (PropertyName == wxT("PID")){ - - SourceListPID.erase(*SourceCount); - SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue)); + if (PropertyMatched == TRUE){ - } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - SourceListPref.erase(*SourceCount); - SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber)); - - } - - } else if (PropertyName == wxT("MEDIATYPE")){ + PropertyMatched = FALSE; + continue; - SourceListMediatype.erase(*SourceCount); - SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue)); - - } else { + } - // Something else we don't know about so append - // to the tokens variable. - - if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ + if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){ - if (FirstToken == TRUE){ - - PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); - FirstToken = FALSE; - - } else { - - PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + if (FirstToken == TRUE){ - } + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); } @@ -779,23 +756,7 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - GroupsListPref.erase(*GroupCount); - GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber)); - - } + ProcessIntegerValue(&GroupsListPref, &PropertyValue, GroupCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -892,23 +853,7 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - FullNamesListPref.erase(*FNCount); - FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber)); - - } + ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount); } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){ @@ -1092,6 +1037,90 @@ void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){ } +void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){ + + size_t intPropertyLen = PropertySeg1.Len(); + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intSplitsFound = 0; + int intSplitSize = 0; + int intPrevValue = 14; + int intPref = 0; + int intType = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 13; + + for (std::map::iterator intiter = SplitPoints.begin(); + intiter != SplitPoints.end(); ++intiter){ + + SLiter = SplitLength.find(intiter->first); + + PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second)); + + wxStringTokenizer PropertyElement (PropertyData, wxT("=")); + PropertyName = PropertyElement.GetNextToken(); + PropertyValue = PropertyElement.GetNextToken(); + + intPrevValue = intiter->second; + + // Process properties. + + size_t intPropertyValueLen = PropertyValue.Len(); + + if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){ + + PropertyValue.Trim(); + PropertyValue.RemoveLast(); + + } + + if (PropertyValue.Mid(0, 1) == wxT("\"")){ + + PropertyValue.Remove(0, 1); + + } + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){ + + continue; + + } + + if (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + CaptureString(&PropertySeg2, FALSE); + + ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens)); + + } + +} + void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){ std::map SplitPoints; @@ -1184,23 +1213,7 @@ void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - NicknamesListPref->erase(*NicknameCount); - NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber)); - - } + ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount); } else if (PropertyName == wxT("LANGUAGE")){ @@ -1675,23 +1688,7 @@ void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - TZListPref->erase(*TimeZoneCount); - TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber)); - - } + ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -1907,24 +1904,8 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - AddressListPref->erase(*AddressCount); - AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber)); - - } + ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount); } else { @@ -2189,23 +2170,7 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - EmailListPref->erase(*EmailCount); - EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber)); - - } + ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount); } else { @@ -2340,23 +2305,7 @@ void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, } else if (PropertyName == wxT("PREF")){ - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - IMListPref->erase(*IMCount); - IMListPref->insert(std::make_pair(*IMCount, PriorityNumber)); - - } + ProcessIntegerValue(IMListPref, &PropertyValue, IMCount); } else { @@ -2649,24 +2598,8 @@ void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString Propert TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - TelephoneListPref->erase(*TelephoneCount); - TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber)); - - } + ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount); } else { @@ -2791,24 +2724,8 @@ void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString Property LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - LanguageListPref->erase(*LanguageCount); - LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber)); - - } + + ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount); } else { @@ -2941,24 +2858,8 @@ void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString Proper GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - GeopositionListPref->erase(*GeographicCount); - GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber)); - - } + ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount); } else { @@ -3193,9 +3094,8 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS } } else if (PropertyName == wxT("LANGUAGE")){ - - GeneralRelatedListLanguage.erase(*RelatedCount); - GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue)); + + ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount); } else if (PropertyName != wxT("TYPE")) { @@ -3346,25 +3246,9 @@ void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - WebsiteListPref->erase(*URLCount); - WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber)); - } - + ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount); + } else if (PropertyName == wxT("MEDIATYPE")){ WebsiteListMediatype->erase(*URLCount); @@ -3520,25 +3404,9 @@ void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - TitleListPref->erase(*TitleCount); - TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber)); - - } - + ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount); + } else if (PropertyName == wxT("LANGUAGE")){ TitleListLanguage->erase(*TitleCount); @@ -3694,25 +3562,9 @@ void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - RoleListPref->erase(*RoleCount); - RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber)); - } - + ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount); + } else if (PropertyName == wxT("LANGUAGE")){ RoleListLanguage->erase(*RoleCount); @@ -3877,25 +3729,9 @@ void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString Prop OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - OrganisationsListPref->erase(*OrganisationCount); - OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber)); - - } - + ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount); + } else if (PropertyName == wxT("LANGUAGE")){ OrganisationsListLanguage->erase(*OrganisationCount); @@ -4051,25 +3887,9 @@ void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - NoteListPref->erase(*NoteCount); - NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber)); - } - + ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount); + } else if (PropertyName == wxT("LANGUAGE")){ NoteListLanguage->erase(*NoteCount); @@ -4196,25 +4016,9 @@ void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString Property CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - CategoriesListPref.erase(*CategoryCount); - CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber)); - - } - + ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount); + } else if (PropertyName == wxT("LANGUAGE")){ CategoriesListLanguage.erase(*CategoryCount); @@ -4485,24 +4289,8 @@ void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - PicturesListPref.erase(*PhotoCount); - PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber)); - } + ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -4702,24 +4490,8 @@ void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - LogosListPref.erase(*LogoCount); - LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber)); - - } + ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -4919,24 +4691,8 @@ void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - SoundsListPref.erase(*SoundCount); - SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber)); - } + ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5141,24 +4897,8 @@ void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString Prope CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - if (ValidNumber == TRUE){ - - CalendarListPref.erase(*CalURICount); - CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber)); - - } + ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5293,24 +5033,8 @@ void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxStrin CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - CalendarRequestListPref.erase(*CalAdrURICount); - CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber)); - } + ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5445,24 +5169,8 @@ void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - FreeBusyListPref.erase(*FreeBusyAddressCount); - FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber)); - - } + ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -5596,24 +5304,8 @@ void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue)); } else if (PropertyName == wxT("PREF")){ - - int PriorityNumber = 0; - bool ValidNumber = TRUE; - - try{ - PriorityNumber = std::stoi(PropertyValue.ToStdString()); - } - - catch(std::invalid_argument &e){ - ValidNumber = FALSE; - } - - if (ValidNumber == TRUE){ - - KeyListPref.erase(*KeyCount); - KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber)); - } + ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount); } else { @@ -5787,6 +5479,78 @@ void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySe } +void ProcessStringValue(wxString *PropertyName, + wxString PropertyNameMatch, + std::map *MapPtr, + wxString *PropertyValue, + int *ItemCount, + bool *PropertyMatched){ + + if (*PropertyName == PropertyNameMatch){ + MapPtr->erase(*ItemCount); + MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue)); + *PropertyMatched = TRUE; + } + +} + +void ProcessIntegerValue(wxString *PropertyName, + wxString PropertyNameMatch, + std::map *PrefPtr, + wxString *PropertyValue, + int *ItemCount, + bool *PropertyMatched){ + + if (*PropertyName == PropertyNameMatch){ + *PropertyMatched = TRUE; + } else { + return; + } + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue->ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + PrefPtr->erase(*ItemCount); + PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber)); + + } + +} + +void ProcessIntegerValue(std::map *PrefPtr, + wxString *PropertyValue, + int *ItemCount){ + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue->ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + PrefPtr->erase(*ItemCount); + PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,