X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=6247596bd22c3bdf3c92961822084f415326efbb;hb=7d729a4ae2a2f9255de6ea3babe3d5ee983fd1fd;hp=4dad1f9c30c9b9f53dda9662cec5ce994432b07e;hpb=8a44cb6af4ffe0aae2d27208d9471e0d6b158c8b;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 4dad1f9..6247596 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -79,6 +79,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ bool BirthdayProcessed = FALSE; bool AnniversaryProcessed = FALSE; bool UIDProcessed = FALSE; + bool RevisionProcessed = FALSE; int ContactLineLen = 0; int QuoteBreakPoint = 0; int SourceCount = 0; @@ -108,6 +109,8 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int KeyCount = 0; int VendorCount = 0; int XTokenCount = 0; + int XMLCount = 0; + int ClientPIDCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -220,6 +223,16 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessSource(PropertySeg1, PropertySeg2, &SourceCount); SourceCount++; + } else if (Property == wxT("XML")){ + + ProcessXML(PropertySeg1, PropertySeg2, &XMLCount); + XMLCount++; + + } else if (Property == wxT("REV") && RevisionProcessed == FALSE){ + + ProcessRevision(PropertySeg1, PropertySeg2); + RevisionProcessed = TRUE; + } else if (Property == wxT("MEMBER")){ ProcessMember(PropertySeg1, PropertySeg2, &GroupCount); @@ -235,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); @@ -441,6 +459,85 @@ void ContactDataObject::ProcessKind(wxString KindType){ } +void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){ + + 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 = 5; + int intPref = 0; + int intType = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + 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 (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + CaptureString(&PropertySeg2, FALSE); + + Revision = PropertySeg2; + + if (!PropertyTokens.IsEmpty()){ + + RevisionTokens = PropertyTokens; + + } + + +} + void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){ size_t intPropertyLen = PropertySeg1.Len(); @@ -514,24 +611,8 @@ void ContactDataObject::ProcessSource(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){ - - SourceListPref.erase(*SourceCount); - SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber)); + ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount); - } - } else if (PropertyName == wxT("MEDIATYPE")){ SourceListMediatype.erase(*SourceCount); @@ -593,6 +674,54 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe } +void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){ + + std::map SplitPoints; + std::map SplitLength; + + int intPrevValue = 5; + int intPref = 0; + int intType = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + wxString PropertyName; + wxString PropertyValue; + wxString PropertyData; + wxString PropertyTokens; + std::map::iterator SLiter; + bool FirstToken = TRUE; + + 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; + + CaptureString(&PropertyValue, FALSE); + + if (PropertyName == wxT("ALTID")){ + + XMLListAltID.erase(*XMLCount); + XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue)); + + } + + } + + XMLList.insert(std::make_pair(*XMLCount, PropertySeg2)); + +} + void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){ std::map SplitPoints; @@ -640,23 +769,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(this, &GroupsListPref, &PropertyValue, GroupCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -753,23 +866,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(this, &FullNamesListPref, &PropertyValue, FNCount); } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){ @@ -953,6 +1050,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; @@ -1045,23 +1226,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(this, NicknamesListPref, &PropertyValue, NicknameCount); } else if (PropertyName == wxT("LANGUAGE")){ @@ -1536,23 +1701,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(this, TZListPref, &PropertyValue, TimeZoneCount); } else if (PropertyName == wxT("MEDIATYPE")){ @@ -1768,24 +1917,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(this, AddressListPref, &PropertyValue, AddressCount); } else { @@ -2050,23 +2183,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(this, EmailListPref, &PropertyValue, EmailCount); } else { @@ -2201,23 +2318,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(this, IMListPref, &PropertyValue, IMCount); } else { @@ -2510,24 +2611,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(this, TelephoneListPref, &PropertyValue, TelephoneCount); } else { @@ -2653,23 +2738,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(this, LanguageListPref, &PropertyValue, LanguageCount); } else { @@ -2802,24 +2871,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(this, GeopositionListPref, &PropertyValue, GeographicCount); } else { @@ -3054,9 +3107,8 @@ void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertyS } } else if (PropertyName == wxT("LANGUAGE")){ - - GeneralRelatedListLanguage.erase(*RelatedCount); - GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue)); + + ProcessIntegerValue(this, &GeneralRelatedListPref, &PropertyValue, RelatedCount); } else if (PropertyName != wxT("TYPE")) { @@ -3207,25 +3259,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(this, WebsiteListPref, &PropertyValue, URLCount); + } else if (PropertyName == wxT("MEDIATYPE")){ WebsiteListMediatype->erase(*URLCount); @@ -3381,25 +3417,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(this, TitleListPref, &PropertyValue, TitleCount); + } else if (PropertyName == wxT("LANGUAGE")){ TitleListLanguage->erase(*TitleCount); @@ -5648,6 +5668,31 @@ void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySe } +void ProcessIntegerValue(ContactDataObject *ContactData, + 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,