X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=28c12b32c522cb79f27df3fe385265dd3ed9c84e;hb=45bd26d628a5b2832d3598a43a3d013b59a8896e;hp=b49e0bb451d061c0c5cf607ccb99e74f4e6553cf;hpb=64e5af606c4f78b992c820414044a6ad8fef29f2;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index b49e0bb..28c12b3 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -86,6 +86,8 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int TimeZoneCount = 0; int AddressCount = 0; int EmailCount = 0; + int IMCount = 0; + int TelephoneCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -234,12 +236,20 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ AddressCount++; } else if (Property == wxT("EMAIL")){ - - // See frmContactEditor-LoadEmail.cpp - + ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount); EmailCount++; + } else if (Property == wxT("IMPP")){ + + ProcessIM(PropertySeg1, PropertySeg2, &IMCount); + IMCount++; + + } else if (Property == wxT("TEL")){ + + ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount); + TelephoneCount++; + } } @@ -645,7 +655,7 @@ void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString Property intPrevValue = 9; - PropertyType PropType; + PropertyType PropType = PROPERTY_NONE; // Look for type before continuing. @@ -1136,7 +1146,7 @@ void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString Property intPrevValue = 3; - PropertyType PropType; + PropertyType PropType = PROPERTY_NONE; // Look for type before continuing. @@ -1315,8 +1325,8 @@ void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertyS intPrevValue = 4; - PropertyType PropType; - + PropertyType PropType = PROPERTY_NONE; + // Look for type before continuing. CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); @@ -1652,8 +1662,8 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg intPrevValue = 6; - PropertyType PropType; - + PropertyType PropType = PROPERTY_NONE; + // Look for type before continuing. CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); @@ -1782,6 +1792,467 @@ void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg } +void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){ + + std::map SplitPoints; + std::map SplitLength; + + int intPrevValue = 6; + int intPref = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 5; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + std::map *IMList = NULL; + std::map *IMListType = NULL; + std::map *IMListAltID = NULL; + std::map *IMListPID = NULL; + std::map *IMListTokens = NULL; + std::map *IMListMediatype = NULL; + std::map *IMListPref = NULL; + + switch(PropType){ + case PROPERTY_NONE: + IMList = &GeneralIMList; + IMListType = &GeneralIMListType; + IMListAltID = &GeneralIMListAltID; + IMListPID = &GeneralIMListPID; + IMListTokens = &GeneralIMListTokens; + IMListMediatype = &GeneralIMListMediatype; + IMListPref = &GeneralIMListPref; + break; + case PROPERTY_HOME: + IMList = &HomeIMList; + IMListType = &HomeIMListType; + IMListAltID = &HomeIMListAltID; + IMListPID = &HomeIMListPID; + IMListTokens = &HomeIMListTokens; + IMListMediatype = &HomeIMListMediatype; + IMListPref = &HomeIMListPref; + break; + case PROPERTY_WORK: + IMList = &BusinessIMList; + IMListType = &BusinessIMListType; + IMListAltID = &BusinessIMListAltID; + IMListPID = &BusinessIMListPID; + IMListTokens = &BusinessIMListTokens; + IMListMediatype = &BusinessIMListMediatype; + IMListPref = &BusinessIMListPref; + break; + } + + intPrevValue = 5; + + 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")){ + + IMListAltID->erase(*IMCount); + IMListAltID->insert(std::make_pair(*IMCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + IMListPID->erase(*IMCount); + IMListPID->insert(std::make_pair(*IMCount, PropertyValue)); + + } else if (PropertyName == wxT("MEDIATYPE")){ + + IMListMediatype->erase(*IMCount); + IMListMediatype->insert(std::make_pair(*IMCount, 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){ + + IMListPref->erase(*IMCount); + IMListPref->insert(std::make_pair(*IMCount, 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); + + } + + } + + } + + } + + IMList->insert(std::make_pair(*IMCount, PropertySeg2)); + + // Add the name token data. + + if (!PropertyTokens.IsEmpty()){ + + IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens)); + + } + +} + +void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){ + + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + + int intPref = 0; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + wxString TelTypeUI; + wxString TelTypeDetail; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + + std::map TypeSplitPoints; + std::map TypeSplitLength; + std::map::iterator TSLiter; + + int intSplitSize = 0; + int intSplitsFound = 0; + int intSplitPoint = 0; + int intType = 0; + int intPrevValue = 5; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + // 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; + + if (PropertyName == wxT("TYPE")){ + + // Process each value in type and translate each + // part. + + // Strip out the quotes if they are there. + + 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); + + } + + TelTypeDetail = PropertyValue; + + intSplitSize = 0; + intSplitsFound = 0; + intSplitPoint = 0; + + for (int i = 0; i <= intPropertyValueLen; i++){ + + intSplitSize++; + + if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){ + + if (intSplitsFound == 0){ + + TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint)); + TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1))); + + } else { + + TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint)); + TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize)); + + } + + intSplitsFound++; + i++; + intSplitPoint = i; + intSplitSize = 0; + + } + + } + + TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint)); + TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize)); + + int intTypeSeek = 0; + + for (std::map::iterator typeiter = TypeSplitPoints.begin(); + typeiter != TypeSplitPoints.end(); ++typeiter){ + + wxString TypePropertyName; + + TSLiter = TypeSplitLength.find(typeiter->first); + + TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second); + + if (intTypeSeek == 0){ + + + } else { + + TelTypeUI.Append(wxT(",")); + + } + + if (TypePropertyName == wxT("home")){ + + PropType = PROPERTY_HOME; + + } else if (TypePropertyName == wxT("work")){ + + PropType = PROPERTY_WORK; + + } + + + if (TypePropertyName == wxT("text")){ + + TelTypeUI.Append(_("text")); + intTypeSeek++; + + } else if (TypePropertyName == wxT("voice")){ + + TelTypeUI.Append(_("voice")); + intTypeSeek++; + + } else if (TypePropertyName == wxT("fax")){ + + TelTypeUI.Append(_("fax")); + intTypeSeek++; + + } else if (TypePropertyName == wxT("cell")){ + + TelTypeUI.Append(_("mobile")); + intTypeSeek++; + + } else if (TypePropertyName == wxT("video")){ + + TelTypeUI.Append(_("video")); + intTypeSeek++; + + } else if (TypePropertyName == wxT("pager")){ + + TelTypeUI.Append(_("pager")); + intTypeSeek++; + + } else if (TypePropertyName == wxT("textphone")){ + + TelTypeUI.Append(_("textphone")); + intTypeSeek++; + + } + + } + + } + + } + + std::map *TelephoneList = NULL; + std::map *TelephoneListType = NULL; + std::map *TelephoneListAltID = NULL; + std::map *TelephoneListPID = NULL; + std::map *TelephoneListTokens = NULL; + std::map *TelephoneListTypeInfo = NULL; + std::map *TelephoneListPref = NULL; + + switch(PropType){ + case PROPERTY_NONE: + TelephoneList = &GeneralTelephoneList; + TelephoneListType = &GeneralTelephoneListType; + TelephoneListAltID = &GeneralTelephoneListAltID; + TelephoneListPID = &GeneralTelephoneListPID; + TelephoneListTokens = &GeneralTelephoneListTokens; + TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo; + TelephoneListPref = &GeneralTelephoneListPref; + break; + case PROPERTY_HOME: + TelephoneList = &HomeTelephoneList; + TelephoneListType = &HomeTelephoneListType; + TelephoneListAltID = &HomeTelephoneListAltID; + TelephoneListPID = &HomeTelephoneListPID; + TelephoneListTokens = &HomeTelephoneListTokens; + TelephoneListTypeInfo = &HomeTelephoneListTypeInfo; + TelephoneListPref = &HomeTelephoneListPref; + break; + case PROPERTY_WORK: + TelephoneList = &BusinessTelephoneList; + TelephoneListType = &BusinessTelephoneListType; + TelephoneListAltID = &BusinessTelephoneListAltID; + TelephoneListPID = &BusinessTelephoneListPID; + TelephoneListTokens = &BusinessTelephoneListTokens; + TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; + TelephoneListPref = &BusinessTelephoneListPref; + break; + } + + // Process the properties. + + bool FirstToken = TRUE; + + intPrevValue = 5; + SplitPoints.clear(); + SplitLength.clear(); + + 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; + + CaptureString(&PropertyValue, FALSE); + + // Process properties. + + if (PropertyName == wxT("ALTID")){ + + TelephoneListAltID->erase(*TelephoneCount); + TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + TelephoneListPID->erase(*TelephoneCount); + 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)); + + } + + } 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); + + } + + } + + } + + } + + TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2)); + TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI)); + + // Add the name token data. + + if (!PropertyTokens.IsEmpty()){ + + TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens)); + + } + +} + void SplitValues(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength,