X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=f7a7e91d1eaf187c74727e1408bc82264861183a;hp=3de45b712ce08d059cad7b0f0e4b9430451a4f1c;hb=fb85e5194a16222937abf13bcfd53a28e47675ee;hpb=12e81906f4a76d4773a0305e0722aed881148db7 diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 3de45b7..f7a7e91 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -89,6 +89,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int IMCount = 0; int TelephoneCount = 0; int LanguageCount = 0; + int GeographicCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -258,6 +259,13 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount); LanguageCount++; + } else if (Property == wxT("GEO")){ + + // See frmContactEditor-LoadGeo.cpp + + ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount); + GeographicCount++; + } } @@ -2402,6 +2410,156 @@ void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString Property } +void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){ + + std::map SplitPoints; + std::map SplitLength; + + int intPrevValue = 5; + int intPref = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + std::map *GeopositionList = NULL; + std::map *GeopositionListType = NULL; + std::map *GeopositionListAltID = NULL; + std::map *GeopositionListPID = NULL; + std::map *GeopositionListTokens = NULL; + std::map *GeopositionListMediatype = NULL; + std::map *GeopositionListPref = NULL; + + switch(PropType){ + case PROPERTY_NONE: + GeopositionList = &GeneralGeographyList; + GeopositionListType = &GeneralGeographyListType; + GeopositionListAltID = &GeneralGeographyListAltID; + GeopositionListPID = &GeneralGeographyListPID; + GeopositionListTokens = &GeneralGeographyListTokens; + GeopositionListMediatype = &GeneralGeographyListMediatype; + GeopositionListPref = &GeneralGeographyListPref; + break; + case PROPERTY_HOME: + GeopositionList = &HomeGeographyList; + GeopositionListType = &HomeGeographyListType; + GeopositionListAltID = &HomeGeographyListAltID; + GeopositionListPID = &HomeGeographyListPID; + GeopositionListTokens = &HomeGeographyListTokens; + GeopositionListMediatype = &HomeGeographyListMediatype; + GeopositionListPref = &HomeGeographyListPref; + break; + case PROPERTY_WORK: + GeopositionList = &BusinessGeographyList; + GeopositionListType = &BusinessGeographyListType; + GeopositionListAltID = &BusinessGeographyListAltID; + GeopositionListPID = &BusinessGeographyListPID; + GeopositionListTokens = &BusinessGeographyListTokens; + GeopositionListMediatype = &BusinessGeographyListMediatype; + GeopositionListPref = &BusinessGeographyListPref; + break; + } + + intPrevValue = 4; + + 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")){ + + GeopositionListAltID->erase(*GeographicCount); + GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + GeopositionListPID->erase(*GeographicCount); + GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue)); + + } else if (PropertyName == wxT("MEDIATYPE")){ + + GeopositionListMediatype->erase(*GeographicCount); + 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)); + + } + + } 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); + + } + + } + + } + + } + + GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2)); + + // Add the name token data. + + if (!PropertyTokens.IsEmpty()){ + + GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,