X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=4c2cbc6442b59b4a7a07daaeb18a85a758834c66;hb=b22d89925df6f435578ae08c37f91d73ee2bdda7;hp=607f28cd44b4cb4e19e8792385db1e8190343182;hpb=5d6277a1b4af590329f694d988780704bfcf2d9a;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 607f28c..4c2cbc6 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -549,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; @@ -599,42 +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")){ - - ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount); - - } 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); } @@ -769,7 +756,7 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount); + ProcessIntegerValue(&GroupsListPref, &PropertyValue, GroupCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -866,7 +853,7 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount); + ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount); } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){ @@ -1226,7 +1213,7 @@ void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount); + ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount); } else if (PropertyName == wxT("LANGUAGE")){ @@ -1701,7 +1688,7 @@ void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString Property } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount); + ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -1918,7 +1905,7 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount); + ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount); } else { @@ -2183,7 +2170,7 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg } else if (PropertyName == wxT("PREF")){ - ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount); + ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount); } else { @@ -2318,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 { @@ -2627,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 { @@ -2770,23 +2725,7 @@ void ContactDataObject::ProcessLanguage(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){ - - LanguageListPref->erase(*LanguageCount); - LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber)); - - } + ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount); } else { @@ -2919,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 { @@ -3171,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")) { @@ -3324,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); @@ -3498,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); @@ -3672,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); @@ -3855,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); @@ -4029,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); @@ -4174,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); @@ -4463,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")){ @@ -4680,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")){ @@ -4897,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")){ @@ -5119,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")){ @@ -5271,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")){ @@ -5423,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")){ @@ -5574,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 { @@ -5765,8 +5479,55 @@ void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySe } -void ProcessIntegerValue(ContactDataObject *ContactData, +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){