X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=0770747b1cecb900d9a5d7ec0d71887291f7a36a;hp=f7a7e91d1eaf187c74727e1408bc82264861183a;hb=c1f0c1c8b56a8304a894dea7f361bda8cbc8d11a;hpb=fb85e5194a16222937abf13bcfd53a28e47675ee diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index f7a7e91..0770747 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -90,6 +90,12 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int TelephoneCount = 0; int LanguageCount = 0; int GeographicCount = 0; + int RelatedCount = 0; + int URLCount = 0; + int TitleCount = 0; + int RoleCount = 0; + int OrganisationCount = 0; + int NoteCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -266,6 +272,48 @@ 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++; + + } else if (Property == wxT("TITLE")) { + + // See frmContactEditor-LoadTitle.cpp + + ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount); + TitleCount++; + + } else if (Property == wxT("ROLE")) { + + // See frmContactEditor-LoadTitle.cpp + + ProcessRole(PropertySeg1, PropertySeg2, &RoleCount); + RoleCount++; + + } else if (Property == wxT("ORG")) { + + // See frmContactEditor-LoadOrg.cpp + + ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount); + OrganisationCount++; + + } else if (Property == wxT("NOTE")) { + + // See frmContactEditor-LoadNote.cpp + + ProcessNote(PropertySeg1, PropertySeg2, &NoteCount); + NoteCount++; + } } @@ -2560,6 +2608,1132 @@ 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")){ + + int PriorityNumber = 0; + bool ValidNumber = TRUE; + + try{ + PriorityNumber = std::stoi(PropertyValue.ToStdString()); + } + + catch(std::invalid_argument &e){ + ValidNumber = FALSE; + } + + if (ValidNumber == TRUE){ + + GeneralRelatedListPref.erase(*RelatedCount); + GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber)); + + } + + } 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 ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 7; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 6; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *TitleList = NULL; + std::map *TitleListAltID = NULL; + std::map *TitleListPID = NULL; + std::map *TitleListType = NULL; + std::map *TitleListTokens = NULL; + std::map *TitleListLanguage = NULL; + std::map *TitleListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + TitleList = &GeneralTitleList; + TitleListType = &GeneralTitleListType; + TitleListAltID = &GeneralTitleListAltID; + TitleListPID = &GeneralTitleListPID; + TitleListTokens = &GeneralTitleListTokens; + TitleListLanguage = &GeneralTitleListLanguage; + TitleListPref = &GeneralTitleListPref; + break; + case PROPERTY_HOME: + TitleList = &HomeTitleList; + TitleListType = &HomeTitleListType; + TitleListAltID = &HomeTitleListAltID; + TitleListPID = &HomeTitleListPID; + TitleListTokens = &HomeTitleListTokens; + TitleListLanguage = &HomeTitleListLanguage; + TitleListPref = &HomeTitleListPref; + break; + case PROPERTY_WORK: + TitleList = &BusinessTitleList; + TitleListType = &BusinessTitleListType; + TitleListAltID = &BusinessTitleListAltID; + TitleListPID = &BusinessTitleListPID; + TitleListTokens = &BusinessTitleListTokens; + TitleListLanguage = &BusinessTitleListLanguage; + TitleListPref = &BusinessTitleListPref; + break; + } + + intPrevValue = 6; + + 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")){ + + TitleListAltID->erase(*TitleCount); + TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + TitleListPID->erase(*TitleCount); + 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)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + TitleListLanguage->erase(*TitleCount); + TitleListLanguage->insert(std::make_pair(*TitleCount, 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); + + TitleList->insert(std::make_pair(*TitleCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens)); + + } + +} + +void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 6; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 5; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *RoleList = NULL; + std::map *RoleListAltID = NULL; + std::map *RoleListPID = NULL; + std::map *RoleListType = NULL; + std::map *RoleListTokens = NULL; + std::map *RoleListLanguage = NULL; + std::map *RoleListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + RoleList = &GeneralRoleList; + RoleListType = &GeneralRoleListType; + RoleListAltID = &GeneralRoleListAltID; + RoleListPID = &GeneralRoleListPID; + RoleListTokens = &GeneralRoleListTokens; + RoleListLanguage = &GeneralRoleListLanguage; + RoleListPref = &GeneralRoleListPref; + break; + case PROPERTY_HOME: + RoleList = &HomeRoleList; + RoleListType = &HomeRoleListType; + RoleListAltID = &HomeRoleListAltID; + RoleListPID = &HomeRoleListPID; + RoleListTokens = &HomeRoleListTokens; + RoleListLanguage = &HomeRoleListLanguage; + RoleListPref = &HomeRoleListPref; + break; + case PROPERTY_WORK: + RoleList = &BusinessRoleList; + RoleListType = &BusinessRoleListType; + RoleListAltID = &BusinessRoleListAltID; + RoleListPID = &BusinessRoleListPID; + RoleListTokens = &BusinessRoleListTokens; + RoleListLanguage = &BusinessRoleListLanguage; + RoleListPref = &BusinessRoleListPref; + break; + } + + intPrevValue = 5; + + 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")){ + + RoleListAltID->erase(*RoleCount); + RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + RoleListPID->erase(*RoleCount); + 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)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + RoleListLanguage->erase(*RoleCount); + RoleListLanguage->insert(std::make_pair(*RoleCount, 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); + + RoleList->insert(std::make_pair(*RoleCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens)); + + } + +} + +void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){ + + 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 *OrganisationsList = NULL; + std::map *OrganisationsListAltID = NULL; + std::map *OrganisationsListPID = NULL; + std::map *OrganisationsListType = NULL; + std::map *OrganisationsListTokens = NULL; + std::map *OrganisationsListLanguage = NULL; + std::map *OrganisationsListSortAs = NULL; + std::map *OrganisationsListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + OrganisationsList = &GeneralOrganisationsList; + OrganisationsListType = &GeneralOrganisationsListType; + OrganisationsListAltID = &GeneralOrganisationsListAltID; + OrganisationsListPID = &GeneralOrganisationsListPID; + OrganisationsListTokens = &GeneralOrganisationsListTokens; + OrganisationsListLanguage = &GeneralOrganisationsListLanguage; + OrganisationsListSortAs = &GeneralOrganisationsListSortAs; + OrganisationsListPref = &GeneralOrganisationsListPref; + break; + case PROPERTY_HOME: + OrganisationsList = &HomeOrganisationsList; + OrganisationsListType = &HomeOrganisationsListType; + OrganisationsListAltID = &HomeOrganisationsListAltID; + OrganisationsListPID = &HomeOrganisationsListPID; + OrganisationsListTokens = &HomeOrganisationsListTokens; + OrganisationsListLanguage = &HomeOrganisationsListLanguage; + OrganisationsListSortAs = &HomeOrganisationsListSortAs; + OrganisationsListPref = &HomeOrganisationsListPref; + break; + case PROPERTY_WORK: + OrganisationsList = &BusinessOrganisationsList; + OrganisationsListType = &BusinessOrganisationsListType; + OrganisationsListAltID = &BusinessOrganisationsListAltID; + OrganisationsListPID = &BusinessOrganisationsListPID; + OrganisationsListTokens = &BusinessOrganisationsListTokens; + OrganisationsListLanguage = &BusinessOrganisationsListLanguage; + OrganisationsListSortAs = &BusinessOrganisationsListSortAs; + OrganisationsListPref = &BusinessOrganisationsListPref; + 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")){ + + OrganisationsListAltID->erase(*OrganisationCount); + OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + OrganisationsListPID->erase(*OrganisationCount); + OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue)); + + } else if (PropertyName == wxT("SORT-AS")){ + + OrganisationsListSortAs->erase(*OrganisationCount); + 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)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + OrganisationsListLanguage->erase(*OrganisationCount); + OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, 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); + + OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens)); + + } + +} + +void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intPrevValue = 6; + int intPref = 0; + int intType = 0; + long ListCtrlIndex; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 5; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + // Setup the pointers. + + std::map *NoteList = NULL; + std::map *NoteListAltID = NULL; + std::map *NoteListPID = NULL; + std::map *NoteListType = NULL; + std::map *NoteListTokens = NULL; + std::map *NoteListLanguage = NULL; + std::map *NoteListSortAs = NULL; + std::map *NoteListPref = NULL; + + // Setup blank lines for later on. + + switch(PropType){ + case PROPERTY_NONE: + NoteList = &GeneralNoteList; + NoteListType = &GeneralNoteListType; + NoteListAltID = &GeneralNoteListAltID; + NoteListPID = &GeneralNoteListPID; + NoteListTokens = &GeneralNoteListTokens; + NoteListLanguage = &GeneralNoteListLanguage; + NoteListPref = &GeneralNoteListPref; + break; + case PROPERTY_HOME: + NoteList = &HomeNoteList; + NoteListType = &HomeNoteListType; + NoteListAltID = &HomeNoteListAltID; + NoteListPID = &HomeNoteListPID; + NoteListTokens = &HomeNoteListTokens; + NoteListLanguage = &HomeNoteListLanguage; + NoteListPref = &HomeNoteListPref; + break; + case PROPERTY_WORK: + NoteList = &BusinessNoteList; + NoteListType = &BusinessNoteListType; + NoteListAltID = &BusinessNoteListAltID; + NoteListPID = &BusinessNoteListPID; + NoteListTokens = &BusinessNoteListTokens; + NoteListLanguage = &BusinessNoteListLanguage; + NoteListPref = &BusinessNoteListPref; + break; + } + + intPrevValue = 5; + + 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")){ + + NoteListAltID->erase(*NoteCount); + NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + NoteListPID->erase(*NoteCount); + NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue)); + + } else if (PropertyName == wxT("SORT-AS")){ + + NoteListSortAs->erase(*NoteCount); + NoteListSortAs->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)); + + } + + } else if (PropertyName == wxT("LANGUAGE")){ + + NoteListLanguage->erase(*NoteCount); + NoteListLanguage->insert(std::make_pair(*NoteCount, 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); + + NoteList->insert(std::make_pair(*NoteCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,