X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=13c869fe301fc338860c85a31cb28f1a03332558;hp=f7a7e91d1eaf187c74727e1408bc82264861183a;hb=5d618c0c96ee88769cc63b0a6fe03679cf68bd18;hpb=fb85e5194a16222937abf13bcfd53a28e47675ee diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index f7a7e91..13c869f 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -90,6 +90,8 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int TelephoneCount = 0; int LanguageCount = 0; int GeographicCount = 0; + int RelatedCount = 0; + int URLCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -266,6 +268,20 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount); GeographicCount++; + } else if (Property == wxT("RELATED")){ + + // See fromContactEditor-LoadRelated.cpp + + ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount); + RelatedCount++; + + } else if (Property == wxT("URL")){ + + // See frmContactEditor-LoadURL.cpp + + ProcessURL(PropertySeg1, PropertySeg2, &URLCount); + URLCount++; + } } @@ -2560,6 +2576,413 @@ void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString Proper } +void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){ + + size_t intPropertyLen = PropertySeg1.Len(); + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + wxString RelatedType; + wxString RelatedTypeOriginal; + wxString RelatedName; + bool FirstToken = TRUE; + int intSplitsFound = 0; + int intSplitSize = 0; + int intPrevValue = 9; + int intPref = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 8; + + // Look for type before continuing. + + 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 these. + + RelatedTypeOriginal = PropertyValue; + + if (PropertyName == wxT("TYPE")){ + + if (PropertyValue == wxT("contact")){ + + RelatedType = _("Contact"); + + } else if (PropertyValue == wxT("acquaintance")){ + + RelatedType = _("Acquaintance"); + + } else if (PropertyValue == wxT("friend")){ + + RelatedType = _("Friend"); + + } else if (PropertyValue == wxT("met")){ + + RelatedType = _("Met"); + + } else if (PropertyValue == wxT("co-worker")){ + + RelatedType = _("Co-worker"); + + } else if (PropertyValue == wxT("colleague")){ + + RelatedType = _("Colleague"); + + } else if (PropertyValue == wxT("co-resident")){ + + RelatedType = _("Co-resident"); + + } else if (PropertyValue == wxT("neighbor")){ + + RelatedType = _("Neighbour"); + + } else if (PropertyValue == wxT("child")){ + + RelatedType = _("Child"); + + } else if (PropertyValue == wxT("parent")){ + + RelatedType = _("Parent"); + + } else if (PropertyValue == wxT("sibling")){ + + RelatedType = _("Sibling"); + + } else if (PropertyValue == wxT("spouse")){ + + RelatedType = _("Spouse"); + + } else if (PropertyValue == wxT("kin")){ + + RelatedType = _("Kin"); + + } else if (PropertyValue == wxT("muse")){ + + RelatedType = _("Muse"); + + } else if (PropertyValue == wxT("crush")){ + + RelatedType = _("Crush"); + + } else if (PropertyValue == wxT("date")){ + + RelatedType = _("Date"); + + } else if (PropertyValue == wxT("sweetheart")){ + + RelatedType = _("Sweetheart"); + + } else if (PropertyValue == wxT("me")){ + + RelatedType = _("Me"); + + } else if (PropertyValue == wxT("agent")){ + + RelatedType = _("Agent"); + + } else if (PropertyValue == wxT("emergency")){ + + RelatedType = _("Emergency"); + + } else { + + RelatedType = PropertyValue; + + } + + } + + } + + intPrevValue = 8; + + 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 == wxT("ALTID")){ + + GeneralRelatedListAltID.erase(*RelatedCount); + GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + GeneralRelatedListPID.erase(*RelatedCount); + GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue)); + + } else if (PropertyName == wxT("PREF")){ + + intPref = wxAtoi(PropertyValue); + + if (intPref > 0 && intPref < 101){ + + GeneralRelatedListPref.erase(*RelatedCount); + GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, intPref)); + + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + GeneralRelatedListLanguage.erase(*RelatedCount); + GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue)); + + } else if (PropertyName != wxT("TYPE")) { + + // Something else we don't know about so append + // to the tokens variable. + + 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); + + } + + } + + } + + } + + // Add the data to the General/Home/Work address variables. + + GeneralRelatedList.erase(*RelatedCount); + GeneralRelatedListRelType.erase(*RelatedCount); + GeneralRelatedListType.erase(*RelatedCount); + GeneralRelatedListTokens.erase(*RelatedCount); + GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2)); + GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType)); + GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType)); + GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens)); + +} + +void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 5; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *WebsiteList = NULL; + std::map *WebsiteListAltID = NULL; + std::map *WebsiteListPID = NULL; + std::map *WebsiteListType = NULL; + std::map *WebsiteListTokens = NULL; + std::map *WebsiteListMediatype = NULL; + std::map *WebsiteListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + WebsiteList = &GeneralWebsiteList; + WebsiteListType = &GeneralWebsiteListType; + WebsiteListAltID = &GeneralWebsiteListAltID; + WebsiteListPID = &GeneralWebsiteListPID; + WebsiteListTokens = &GeneralWebsiteListTokens; + WebsiteListMediatype = &GeneralWebsiteListMediatype; + WebsiteListPref = &GeneralWebsiteListPref; + break; + case PROPERTY_HOME: + WebsiteList = &HomeWebsiteList; + WebsiteListType = &HomeWebsiteListType; + WebsiteListAltID = &HomeWebsiteListAltID; + WebsiteListPID = &HomeWebsiteListPID; + WebsiteListTokens = &HomeWebsiteListTokens; + WebsiteListMediatype = &HomeWebsiteListMediatype; + WebsiteListPref = &HomeWebsiteListPref; + break; + case PROPERTY_WORK: + WebsiteList = &BusinessWebsiteList; + WebsiteListType = &BusinessWebsiteListType; + WebsiteListAltID = &BusinessWebsiteListAltID; + WebsiteListPID = &BusinessWebsiteListPID; + WebsiteListTokens = &BusinessWebsiteListTokens; + WebsiteListMediatype = &BusinessWebsiteListMediatype; + WebsiteListPref = &BusinessWebsiteListPref; + break; + } + + 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 (PropertyName == wxT("ALTID")){ + + WebsiteListAltID->erase(*URLCount); + WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + WebsiteListPID->erase(*URLCount); + 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)); + + } + + } else if (PropertyName == wxT("MEDIATYPE")){ + + WebsiteListMediatype->erase(*URLCount); + WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue)); + + } else { + + // Something else we don't know about so append + // to the tokens variable. + + 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); + + } + + } + + } + + } + + // Add the data to the General/Home/Work address variables. + + CaptureString(&PropertySeg2, FALSE); + + WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,