int KeyCount = 0;
int VendorCount = 0;
int XTokenCount = 0;
+ int XMLCount = 0;
wxString ContactLine;
wxString PropertyLine;
wxString PropertySeg1;
ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
SourceCount++;
+ } else if (Property == wxT("XML")){
+
+ ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
+ XMLCount++;
+
} else if (Property == wxT("MEMBER")){
ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
}
+void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
+
+ std::map<int, int> SplitPoints;
+ std::map<int, int> 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<int,int>::iterator SLiter;
+ bool FirstToken = TRUE;
+
+ for (std::map<int, int>::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<int, int> SplitPoints;
void ProcessKind(wxString KindData);
void ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount);
+ void ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount);
void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount);
void ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount);
void ProcessN(wxString PropertySeg1, wxString PropertySeg2);
std::map<int, wxString> SourceListTokens;
std::map<int, wxString> SourceListMediatype;
std::map<int, int> SourceListPref;
+
+ std::map<int, wxString> XMLList;
+ std::map<int, wxString> XMLListAltID;
/* We don't use these at the moment but we want to keep
them for compatability reasons */
VERSION:4.0
UID:903588-9082374-989120310-AAFECDBCDF
KIND:individual
+XML:<a xmlns="http://www.w3.org/1999/xhtml"\n
+ href="http://example.com/">Example Page 1</a>
+XML;ALTID=3:<a xmlns="http://www.w3.org/1999/xhtml"\n
+ href="http://example.com/page2.html">Example Page 2</a>
+XML;ALTID=5:<a xmlns="http://www.w3.org/1999/xhtml"\n
+ href="http://example.com/page3.html">Example Page 3</a>
SOURCE;ALTID=74;PID=71;PREF=72;MEDIATYPE=text/plain;STATUS=FEED:http://examp
le.com/source/sourcea.vcf
SOURCE;TYPE=home;ALTID=84;PID=81;MEDIATYPE=text/plainpaper;STATUS=ONLINE;PRE
}
+TEST(ContactLoad, XMLTest){
+
+ ContactDataObject TestFile;
+
+ // Check that the vCard 4.0 file loads OK.
+
+ ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+ std::map<int,wxString>::iterator TestFileIter;
+ std::map<int,int>::iterator TestFileIntIter;
+
+ // Start with the first XML property.
+
+ // Start with a general source address.
+
+ TestFileIter = TestFile.XMLList.find(0);
+ ASSERT_NE(TestFile.XMLList.end(), TestFileIter);
+ ASSERT_EQ("<a xmlns=\"http://www.w3.org/1999/xhtml\"\\n"
+ " href=\"http://example.com/\">Example Page 1</a>", TestFileIter->second);
+
+ TestFileIter = TestFile.XMLList.find(1);
+ ASSERT_NE(TestFile.XMLList.end(), TestFileIter);
+ ASSERT_EQ("<a xmlns=\"http://www.w3.org/1999/xhtml\"\\n"
+ " href=\"http://example.com/page2.html\">Example Page 2</a>", TestFileIter->second);
+
+ TestFileIter = TestFile.XMLList.find(2);
+ ASSERT_NE(TestFile.XMLList.end(), TestFileIter);
+ ASSERT_EQ("<a xmlns=\"http://www.w3.org/1999/xhtml\"\\n"
+ " href=\"http://example.com/page3.html\">Example Page 3</a>", TestFileIter->second);
+
+}
+
TEST(ContactLoad, NicknameTests){
ContactDataObject TestFile;