X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=b49e0bb451d061c0c5cf607ccb99e74f4e6553cf;hp=eeb95b014222ff069c379688fbf0af3474403fde;hb=64e5af606c4f78b992c820414044a6ad8fef29f2;hpb=02248b76582978705c083ef8ffb85c8d4efe4a23 diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index eeb95b0..b49e0bb 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -85,6 +85,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int NicknameCount = 0; int TimeZoneCount = 0; int AddressCount = 0; + int EmailCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -232,6 +233,13 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount); AddressCount++; + } else if (Property == wxT("EMAIL")){ + + // See frmContactEditor-LoadEmail.cpp + + ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount); + EmailCount++; + } } @@ -1632,6 +1640,148 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS } +void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){ + + std::map SplitPoints; + std::map SplitLength; + + int intPrevValue = 7; + int intPref = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 6; + + PropertyType PropType; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + std::map *EmailList = NULL; + std::map *EmailListType = NULL; + std::map *EmailListAltID = NULL; + std::map *EmailListPID = NULL; + std::map *EmailListTokens = NULL; + std::map *EmailListPref = NULL; + + switch(PropType){ + case PROPERTY_NONE: + EmailList = &GeneralEmailList; + EmailListType = &GeneralEmailListType; + EmailListAltID = &GeneralEmailListAltID; + EmailListPID = &GeneralEmailListPID; + EmailListTokens = &GeneralEmailListTokens; + EmailListPref = &GeneralEmailListPref; + break; + case PROPERTY_HOME: + EmailList = &HomeEmailList; + EmailListType = &HomeEmailListType; + EmailListAltID = &HomeEmailListAltID; + EmailListPID = &HomeEmailListPID; + EmailListTokens = &HomeEmailListTokens; + EmailListPref = &HomeEmailListPref; + break; + case PROPERTY_WORK: + EmailList = &BusinessEmailList; + EmailListType = &BusinessEmailListType; + EmailListAltID = &BusinessEmailListAltID; + EmailListPID = &BusinessEmailListPID; + EmailListTokens = &BusinessEmailListTokens; + EmailListPref = &BusinessEmailListPref; + break; + } + + intPrevValue = 6; + + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + 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); + + // Process properties. + + if (PropertyName == wxT("ALTID")){ + + EmailListAltID->erase(*EmailCount); + EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + EmailListPID->erase(*EmailCount); + EmailListPID->insert(std::make_pair(*EmailCount, 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){ + + EmailListPref->erase(*EmailCount); + EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber)); + + } + + } else { + + 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); + + } + + } + + } + + } + + EmailList->insert(std::make_pair(*EmailCount, PropertySeg2)); + + // Add the name token data. + + if (!PropertyTokens.IsEmpty()){ + + EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens)); + + } + + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,