X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FContactDataObject.cpp;h=66f42594d4daccf647c123e2dfc6f471d6b451e6;hb=17d33f5a39d1b64be75d308a78467290e96b7e38;hp=bb85052fc83f827f383195a7061ae08827f43d48;hpb=0eebe029ad2758d33667055f675320d75ba7c492;p=xestiaab%2F.git diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index bb85052..66f4259 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -79,8 +79,10 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ bool BirthdayProcessed = FALSE; bool AnniversaryProcessed = FALSE; bool UIDProcessed = FALSE; + bool RevisionProcessed = FALSE; int ContactLineLen = 0; int QuoteBreakPoint = 0; + int SourceCount = 0; int GroupCount = 0; int FNCount = 0; int NicknameCount = 0; @@ -107,6 +109,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ int KeyCount = 0; int VendorCount = 0; int XTokenCount = 0; + int XMLCount = 0; wxString ContactLine; wxString PropertyLine; wxString PropertySeg1; @@ -214,6 +217,21 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ UIDToken = PropertySeg2; UIDProcessed = TRUE; + } else if (Property == wxT("SOURCE")){ + + ProcessSource(PropertySeg1, PropertySeg2, &SourceCount); + SourceCount++; + + } else if (Property == wxT("XML")){ + + ProcessXML(PropertySeg1, PropertySeg2, &XMLCount); + XMLCount++; + + } else if (Property == wxT("REV") && RevisionProcessed == FALSE){ + + ProcessRevision(PropertySeg1, PropertySeg2); + RevisionProcessed = TRUE; + } else if (Property == wxT("MEMBER")){ ProcessMember(PropertySeg1, PropertySeg2, &GroupCount); @@ -435,6 +453,285 @@ void ContactDataObject::ProcessKind(wxString KindType){ } +void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){ + + size_t intPropertyLen = PropertySeg1.Len(); + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intSplitsFound = 0; + int intSplitSize = 0; + int intPrevValue = 5; + int intPref = 0; + int intType = 0; + + 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; + + // 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 (FirstToken == TRUE){ + + PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue); + FirstToken = FALSE; + + } else { + + PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue); + + } + + } + + CaptureString(&PropertySeg2, FALSE); + + Revision = PropertySeg2; + + if (!PropertyTokens.IsEmpty()){ + + RevisionTokens = PropertyTokens; + + } + + +} + +void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){ + + size_t intPropertyLen = PropertySeg1.Len(); + std::map SplitPoints; + std::map SplitLength; + std::map::iterator SLiter; + wxString PropertyData; + wxString PropertyName; + wxString PropertyValue; + wxString PropertyTokens; + bool FirstToken = TRUE; + int intSplitsFound = 0; + int intSplitSize = 0; + int intPrevValue = 8; + int intPref = 0; + int intType = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 7; + + PropertyType PropType = PROPERTY_NONE; + + // Look for type before continuing. + + CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType); + + intPrevValue = 7; + + 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")){ + + SourceListAltID.erase(*SourceCount); + SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue)); + + } else if (PropertyName == wxT("PID")){ + + SourceListPID.erase(*SourceCount); + SourceListPID.insert(std::make_pair(*SourceCount, 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){ + + SourceListPref.erase(*SourceCount); + SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber)); + + } + + } else if (PropertyName == wxT("MEDIATYPE")){ + + SourceListMediatype.erase(*SourceCount); + SourceListMediatype.insert(std::make_pair(*SourceCount, 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); + + } + + } + + } + + } + + intPropertyLen = PropertySeg2.Len(); + SplitPoints.clear(); + SplitLength.clear(); + intSplitsFound = 0; + intSplitSize = 0; + intPrevValue = 0; + + CaptureString(&PropertySeg2, FALSE); + + // Add the data to the General/Home/Work address variables. + + switch(PropType){ + case PROPERTY_NONE: + break; + case PROPERTY_HOME: + SourceListType.insert(std::make_pair(*SourceCount, "home")); + break; + case PROPERTY_WORK: + SourceListType.insert(std::make_pair(*SourceCount, "work")); + break; + } + + SourceList.insert(std::make_pair(*SourceCount, PropertySeg2)); + + if (!PropertyTokens.IsEmpty()){ + + SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens)); + + } + +} + +void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){ + + std::map SplitPoints; + std::map SplitLength; + + int intPrevValue = 5; + int intPref = 0; + int intType = 0; + + SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue); + + intPrevValue = 4; + + wxString PropertyName; + wxString PropertyValue; + wxString PropertyData; + wxString PropertyTokens; + std::map::iterator SLiter; + 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); + + if (PropertyName == wxT("ALTID")){ + + XMLListAltID.erase(*XMLCount); + XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue)); + + } + + } + + XMLList.insert(std::make_pair(*XMLCount, PropertySeg2)); + +} + void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){ std::map SplitPoints;