int TelephoneCount = 0;
int LanguageCount = 0;
int GeographicCount = 0;
+ int RelatedCount = 0;
+ int URLCount = 0;
wxString ContactLine;
wxString PropertyLine;
wxString PropertySeg1;
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++;
+
}
}
}
+void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
+
+ size_t intPropertyLen = PropertySeg1.Len();
+ std::map<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+ std::map<int, int>::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<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;
+
+ // 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<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;
+
+ // 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")){
+
+ intPref = wxAtoi(PropertyValue);
+
+ if (intPref > 0 && intPref < 101){
+
+ GeneralRelatedListPref.erase(*RelatedCount);
+ GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, intPref));
+
+
+ }
+
+ } 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<int, int> SplitPoints;
+ std::map<int, int> SplitLength;
+ std::map<int, int>::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<int, wxString> *WebsiteList = NULL;
+ std::map<int, wxString> *WebsiteListAltID = NULL;
+ std::map<int, wxString> *WebsiteListPID = NULL;
+ std::map<int, wxString> *WebsiteListType = NULL;
+ std::map<int, wxString> *WebsiteListTokens = NULL;
+ std::map<int, wxString> *WebsiteListMediatype = NULL;
+ std::map<int, int> *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<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;
+
+ // 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 SplitValues(wxString *PropertyLine,
std::map<int,int> *SplitPoints,
std::map<int,int> *SplitLength,
class ContactDataObject{
+ private:
+
+ void ProcessKind(wxString KindData);
+ void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount);
+ void ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount);
+ void ProcessN(wxString PropertySeg1, wxString PropertySeg2);
+ void ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount);
+ void ProcessGender(wxString PropertySeg1, wxString PropertySeg2);
+ void ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2);
+ void ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2);
+ void ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount);
+ void ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount);
+ void ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount);
+ void ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount);
+ void ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount);
+ void ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount);
+ void ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount);
+ void ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount);
+ void ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount);
+
public:
ContactKindType ContactKind = CONTACTKIND_NONE;
std::map<int, wxString> HomeGeographyListMediatype;
std::map<int, int> HomeGeographyListPref;
- std::map<int, wxString> HomeRelatedList;
- std::map<int, wxString> HomeRelatedListRelType;
- std::map<int, wxString> HomeRelatedListLanguage;
- std::map<int, wxString> HomeRelatedListAltID;
- std::map<int, wxString> HomeRelatedListPID;
- std::map<int, wxString> HomeRelatedListType;
- std::map<int, wxString> HomeRelatedListTokens;
- std::map<int, int> HomeRelatedListPref;
-
std::map<int, wxString> HomeWebsiteList;
std::map<int, wxString> HomeWebsiteListAltID;
std::map<int, wxString> HomeWebsiteListPID;
std::map<int, wxString> BusinessGeographyListType;
std::map<int, wxString> BusinessGeographyListTokens;
std::map<int, wxString> BusinessGeographyListMediatype;
- std::map<int, int> BusinessGeographyListPref;
-
- std::map<int, wxString> BusinessRelatedList;
- std::map<int, wxString> BusinessRelatedListRelType;
- std::map<int, wxString> BusinessRelatedListLanguage;
- std::map<int, wxString> BusinessRelatedListAltID;
- std::map<int, wxString> BusinessRelatedListPID;
- std::map<int, wxString> BusinessRelatedListType;
- std::map<int, wxString> BusinessRelatedListTokens;
- std::map<int, int> BusinessRelatedListPref;
+ std::map<int, int> BusinessGeographyListPref;
std::map<int, wxString> BusinessWebsiteList;
std::map<int, wxString> BusinessWebsiteListAltID;
// Subroutines.
ContactLoadStatus LoadFile(wxString Filename);
- void ProcessKind(wxString KindData);
- void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount);
- void ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount);
- void ProcessN(wxString PropertySeg1, wxString PropertySeg2);
- void ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount);
- void ProcessGender(wxString PropertySeg1, wxString PropertySeg2);
- void ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2);
- void ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2);
- void ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount);
- void ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount);
- void ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount);
- void ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount);
- void ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount);
- void ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount);
- void ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount);
};
o:7.0,7.0
GEO;TYPE=work;ALTID=75;PID=32;TYPE=text/greenplain;PREF=4;POS=Money;MEDIATYP
E=text/greenplain:geo:14.0,14.0
+RELATED;TYPE=Kin;ALTID=5;PID=10;PREF=20;OPTION=Yes:Friend Test
+RELATED;TYPE=spouse;ALTID=1;PID=2;PREF=3;OPTION=No:Friend Test Two
+RELATED;TYPE=muse;ALTID=4;PID=5;PREF=6;OPTION=Maybe:Friend Test Three
+URL;ALTID=0;PID=1;PREF=2;MEDIATYPE=text/plain;MEEP=Moo:http://example.com/
+URL;TYPE=home;ALTID=10;PID=11;PREF=12;MEDIATYPE=grass/soggy;BON=Bon:http://e
+ xample.com/home/
+URL;TYPE=work;ALTID=20;PID=21;PREF=22;MEDIATYPE=chocolate/yummy;YES=No:http:
+ //example.com/business/
END:VCARD
}
+TEST(ContactLoad, RelatedTests){
+
+ 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 relation.
+
+ TestFileIter = TestFile.GeneralRelatedList.find(0);
+ ASSERT_NE(TestFile.GeneralRelatedList.end(), TestFileIter);
+ ASSERT_EQ("Friend Test", TestFileIter->second);
+
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.GeneralRelatedListType.find(0);
+ ASSERT_NE(TestFile.GeneralRelatedListType.end(), TestFileIter);
+ ASSERT_EQ("Kin", TestFileIter->second);
+
+ // Check the ALTID section.
+
+ TestFileIter = TestFile.GeneralRelatedListAltID.find(0);
+ ASSERT_NE(TestFile.GeneralRelatedListAltID.end(), TestFileIter);
+ ASSERT_EQ("5", TestFileIter->second);
+
+ // Check the PID section.
+
+ TestFileIter = TestFile.GeneralRelatedListPID.find(0);
+ ASSERT_NE(TestFile.GeneralRelatedListPID.end(), TestFileIter);
+ ASSERT_EQ("10", TestFileIter->second);
+
+ // Check the PREF section.
+
+ TestFileIntIter = TestFile.GeneralRelatedListPref.find(0);
+ ASSERT_NE(TestFile.GeneralRelatedListPref.end(), TestFileIntIter);
+ ASSERT_EQ(20, TestFileIntIter->second);
+
+ // Check the extra tokens.
+
+ TestFileIter = TestFile.GeneralRelatedListTokens.find(0);
+ ASSERT_NE(TestFile.GeneralRelatedListTokens.end(), TestFileIter);
+ ASSERT_EQ("OPTION=Yes", TestFileIter->second);
+
+ // Start with the second relation.
+
+ TestFileIter = TestFile.GeneralRelatedList.find(1);
+ ASSERT_NE(TestFile.GeneralRelatedList.end(), TestFileIter);
+ ASSERT_EQ("Friend Test Two", TestFileIter->second);
+
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.GeneralRelatedListType.find(1);
+ ASSERT_NE(TestFile.GeneralRelatedListType.end(), TestFileIter);
+ ASSERT_EQ("Spouse", TestFileIter->second);
+
+ // Check the ALTID section.
+
+ TestFileIter = TestFile.GeneralRelatedListAltID.find(1);
+ ASSERT_NE(TestFile.GeneralRelatedListAltID.end(), TestFileIter);
+ ASSERT_EQ("1", TestFileIter->second);
+
+ // Check the PID section.
+
+ TestFileIter = TestFile.GeneralRelatedListPID.find(1);
+ ASSERT_NE(TestFile.GeneralRelatedListPID.end(), TestFileIter);
+ ASSERT_EQ("2", TestFileIter->second);
+
+ // Check the PREF section.
+
+ TestFileIntIter = TestFile.GeneralRelatedListPref.find(1);
+ ASSERT_NE(TestFile.GeneralRelatedListPref.end(), TestFileIntIter);
+ ASSERT_EQ(3, TestFileIntIter->second);
+
+ // Check the extra tokens.
+
+ TestFileIter = TestFile.GeneralRelatedListTokens.find(1);
+ ASSERT_NE(TestFile.GeneralRelatedListTokens.end(), TestFileIter);
+ ASSERT_EQ("OPTION=No", TestFileIter->second);
+
+ // Start with the second relation.
+
+ TestFileIter = TestFile.GeneralRelatedList.find(2);
+ ASSERT_NE(TestFile.GeneralRelatedList.end(), TestFileIter);
+ ASSERT_EQ("Friend Test Three", TestFileIter->second);
+
+ // Check the TYPE section.
+
+ TestFileIter = TestFile.GeneralRelatedListType.find(2);
+ ASSERT_NE(TestFile.GeneralRelatedListType.end(), TestFileIter);
+ ASSERT_EQ("Muse", TestFileIter->second);
+
+ // Check the ALTID section.
+
+ TestFileIter = TestFile.GeneralRelatedListAltID.find(2);
+ ASSERT_NE(TestFile.GeneralRelatedListAltID.end(), TestFileIter);
+ ASSERT_EQ("4", TestFileIter->second);
+
+ // Check the PID section.
+
+ TestFileIter = TestFile.GeneralRelatedListPID.find(2);
+ ASSERT_NE(TestFile.GeneralRelatedListPID.end(), TestFileIter);
+ ASSERT_EQ("5", TestFileIter->second);
+
+ // Check the PREF section.
+
+ TestFileIntIter = TestFile.GeneralRelatedListPref.find(2);
+ ASSERT_NE(TestFile.GeneralRelatedListPref.end(), TestFileIntIter);
+ ASSERT_EQ(6, TestFileIntIter->second);
+
+ // Check the extra tokens.
+
+ TestFileIter = TestFile.GeneralRelatedListTokens.find(2);
+ ASSERT_NE(TestFile.GeneralRelatedListTokens.end(), TestFileIter);
+ ASSERT_EQ("OPTION=Maybe", TestFileIter->second);
+
+}
+
+TEST(ContactLoad, URLTests){
+
+ 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 general URL.
+
+ TestFileIter = TestFile.GeneralWebsiteList.find(0);
+ ASSERT_NE(TestFile.GeneralWebsiteList.end(), TestFileIter);
+ ASSERT_EQ("http://example.com/", TestFileIter->second);
+
+ // Check the ALTID section.
+
+ TestFileIter = TestFile.GeneralWebsiteListAltID.find(0);
+ ASSERT_NE(TestFile.GeneralWebsiteListAltID.end(), TestFileIter);
+ ASSERT_EQ("0", TestFileIter->second);
+
+ // Check the PID section.
+
+ TestFileIter = TestFile.GeneralWebsiteListPID.find(0);
+ ASSERT_NE(TestFile.GeneralWebsiteListPID.end(), TestFileIter);
+ ASSERT_EQ("1", TestFileIter->second);
+
+ // Check the MEDIATYPE section.
+
+ TestFileIter = TestFile.GeneralWebsiteListMediatype.find(0);
+ ASSERT_NE(TestFile.GeneralWebsiteListMediatype.end(), TestFileIter);
+ ASSERT_EQ("text/plain", TestFileIter->second);
+
+ // Check the PREF section.
+
+ TestFileIntIter = TestFile.GeneralWebsiteListPref.find(0);
+ ASSERT_NE(TestFile.GeneralWebsiteListPref.end(), TestFileIntIter);
+ ASSERT_EQ(2, TestFileIntIter->second);
+
+ // Check the extra tokens.
+
+ TestFileIter = TestFile.GeneralWebsiteListTokens.find(0);
+ ASSERT_NE(TestFile.GeneralWebsiteListTokens.end(), TestFileIter);
+ ASSERT_EQ("MEEP=Moo", TestFileIter->second);
+
+ // Start with the home URL.
+
+ TestFileIter = TestFile.HomeWebsiteList.find(1);
+ ASSERT_NE(TestFile.HomeWebsiteList.end(), TestFileIter);
+ ASSERT_EQ("http://example.com/home/", TestFileIter->second);
+
+ // Check the ALTID section.
+
+ TestFileIter = TestFile.HomeWebsiteListAltID.find(1);
+ ASSERT_NE(TestFile.HomeWebsiteListAltID.end(), TestFileIter);
+ ASSERT_EQ("10", TestFileIter->second);
+
+ // Check the PID section.
+
+ TestFileIter = TestFile.HomeWebsiteListPID.find(1);
+ ASSERT_NE(TestFile.HomeWebsiteListPID.end(), TestFileIter);
+ ASSERT_EQ("11", TestFileIter->second);
+
+ // Check the MEDIATYPE section.
+
+ TestFileIter = TestFile.HomeWebsiteListMediatype.find(1);
+ ASSERT_NE(TestFile.HomeWebsiteListMediatype.end(), TestFileIter);
+ ASSERT_EQ("grass/soggy", TestFileIter->second);
+
+ // Check the PREF section.
+
+ TestFileIntIter = TestFile.HomeWebsiteListPref.find(1);
+ ASSERT_NE(TestFile.HomeWebsiteListPref.end(), TestFileIntIter);
+ ASSERT_EQ(12, TestFileIntIter->second);
+
+ // Check the extra tokens.
+
+ TestFileIter = TestFile.HomeWebsiteListTokens.find(1);
+ ASSERT_NE(TestFile.HomeWebsiteListTokens.end(), TestFileIter);
+ ASSERT_EQ("BON=Bon", TestFileIter->second);
+
+ // Start with the business URL.
+
+ TestFileIter = TestFile.BusinessWebsiteList.find(2);
+ ASSERT_NE(TestFile.BusinessWebsiteList.end(), TestFileIter);
+ ASSERT_EQ("http://example.com/business/", TestFileIter->second);
+
+ // Check the ALTID section.
+
+ TestFileIter = TestFile.BusinessWebsiteListAltID.find(2);
+ ASSERT_NE(TestFile.BusinessWebsiteListAltID.end(), TestFileIter);
+ ASSERT_EQ("20", TestFileIter->second);
+
+ // Check the PID section.
+
+ TestFileIter = TestFile.BusinessWebsiteListPID.find(2);
+ ASSERT_NE(TestFile.BusinessWebsiteListPID.end(), TestFileIter);
+ ASSERT_EQ("21", TestFileIter->second);
+
+ // Check the MEDIATYPE section.
+
+ TestFileIter = TestFile.BusinessWebsiteListMediatype.find(2);
+ ASSERT_NE(TestFile.BusinessWebsiteListMediatype.end(), TestFileIter);
+ ASSERT_EQ("chocolate/yummy", TestFileIter->second);
+
+ // Check the PREF section.
+
+ TestFileIntIter = TestFile.BusinessWebsiteListPref.find(2);
+ ASSERT_NE(TestFile.BusinessWebsiteListPref.end(), TestFileIntIter);
+ ASSERT_EQ(22, TestFileIntIter->second);
+
+ // Check the extra tokens.
+
+ TestFileIter = TestFile.BusinessWebsiteListTokens.find(2);
+ ASSERT_NE(TestFile.BusinessWebsiteListTokens.end(), TestFileIter);
+ ASSERT_EQ("YES=No", TestFileIter->second);
+
+}
+
// TODO: Add tests for the Contact Loading process.
\ No newline at end of file