Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit testing for UID, VND-* and X-* vCard Properties...
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 27 Dec 2015 01:49:05 +0000 (01:49 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 27 Dec 2015 01:49:05 +0000 (01:49 +0000)
source/contacteditor/ContactDataObject.cpp
source/contacteditor/ContactDataObject.h
source/tests/LoadCheck-Load4.vcf
source/tests/xestiaab_contactload.h

index 7531af0..bb85052 100644 (file)
@@ -78,6 +78,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
        bool GenderProcessed = FALSE;
        bool BirthdayProcessed = FALSE;
        bool AnniversaryProcessed = FALSE;
+       bool UIDProcessed = FALSE;
        int ContactLineLen = 0;
        int QuoteBreakPoint = 0;
        int GroupCount = 0;
@@ -104,6 +105,8 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
        int CalendarAddressCount = 0;
        int FreeBusyAddressCount = 0;
        int KeyCount = 0;
+       int VendorCount = 0;
+       int XTokenCount = 0;
        wxString ContactLine;
        wxString PropertyLine;
        wxString PropertySeg1;
@@ -206,6 +209,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
                                
                        ProcessKind(PropertySeg2);
                
+               } else if (Property == wxT("UID") && UIDProcessed == FALSE){
+               
+                       UIDToken = PropertySeg2;
+                       UIDProcessed = TRUE;
+               
                } else if (Property == wxT("MEMBER")){
 
                        ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
@@ -383,6 +391,17 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
                        ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
                        KeyCount++;
                
+               } else if (Property.Mid(0, 3) == wxT("VND")){
+               
+                       ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
+                       VendorCount++;
+               
+               } else if (Property.Mid(0, 2) == wxT("X-")){
+                       
+                       XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
+                       XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
+                       XTokenCount++;
+               
                }
                
        }
@@ -5436,6 +5455,41 @@ void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2,
 
 }
 
+void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
+
+       // Split the Vendor three ways.
+       
+       wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
+       
+       wxString wxSVNDID;
+       wxString wxSVNDPropName;
+       long ListCtrlIndex;                     
+
+       while (wSTVendorDetails.HasMoreTokens() == TRUE){
+       
+               wSTVendorDetails.GetNextToken();
+               wxSVNDID = wSTVendorDetails.GetNextToken();
+               wxSVNDPropName = wSTVendorDetails.GetNextToken();
+               break;
+       
+       }
+       
+       if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
+       
+               // Add the data to the vendor variables.
+       
+               VendorList.erase(*VendorCount);
+               VendorListPEN.erase(*VendorCount);
+               VendorListElement.erase(*VendorCount);
+       
+               VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
+               VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
+               VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
+       
+       }
+
+}
+
 void SplitValues(wxString *PropertyLine, 
        std::map<int,int> *SplitPoints, 
        std::map<int,int> *SplitLength, 
index 8cb40d5..4e834d5 100644 (file)
@@ -83,6 +83,7 @@ class ContactDataObject{
        void ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount);
        void ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount);
        void ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount);
+       void ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount);
 
        public:
 
index e43f044..704deee 100644 (file)
@@ -1,5 +1,6 @@
 BEGIN:VCARD
 VERSION:4.0
+UID:903588-9082374-989120310-AAFECDBCDF
 KIND:individual
 MEMBER;ALTID=35;PID=40;PREF=45;MEDIATYPE=text/plain;EXAMPLE=Meep:7a2af44d-64
  31-4797-a55f-d86d56304fda
@@ -623,4 +624,16 @@ KEY;TYPE=work;ALTID=74;PID=71;PREF=72;KEYS=MISSING:data:application/pgp-keys
  S3ZwN2R4aWJ1YS9FanNxRC85eHNUOHRZUUQrT2VqRndvRmVrbnpZa2RFMmdJb2ZuaDk0CjdKeUh
  aNDUyTERkamZXQ1BZWFU9Cj16T3NxCi0tLS0tRU5EIFBHUCBQVUJMSUMgS0VZIEJMT0NLLS0tLS
  0K
+VND-696-CAKE:Lemon
+VND-696-DRINK:Orange
+VND-696-MUSIC:Shiena Nishizawa
+X-FARM:Yard
+X-FARM:Animals
+X-FARM;LOCATION=Back;TYPE=Vehicles:Shed
+X-DISKSERIAL:14444
+X-DISKSERIAL:7555
+X-DISKSERIAL;STATUS=DESTROYED;TYPE=FLASH:3250539032590
+X-FOODS;STATUS=HIGH:Lemon Cake
+X-FOODS;STATUS=LOW:Starrey Gazey Pie
+X-FOODS;STATUS=FAVOURITE;TYPE=CHEESEANDONION:Cornish Pasties
 END:VCARD
index 3886d4c..da35e06 100644 (file)
@@ -157,6 +157,18 @@ TEST(ContactLoad, ContactLoadTests){
 
 }
 
+TEST(ContactLoad, UIDTest){
+
+       ContactDataObject TestFile;
+
+       // Check that the vCard 4.0 file loads OK.
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+       
+       ASSERT_EQ("903588-9082374-989120310-AAFECDBCDF", TestFile.UIDToken);
+
+}
+
 TEST(ContactLoad, NicknameTests){
 
        ContactDataObject TestFile;
@@ -3896,4 +3908,146 @@ TEST(ContactLoad, KeyTests){
 
 }
 
+TEST(ContactLoad, VendorTests){
+
+       ContactDataObject TestFile;
+
+       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 vendor namespace.
+       
+       TestFileIter = TestFile.VendorList.find(0);
+       ASSERT_NE(TestFile.VendorList.end(), TestFileIter);
+       ASSERT_EQ("Lemon", TestFileIter->second);
+
+       TestFileIter = TestFile.VendorListPEN.find(0);
+       ASSERT_NE(TestFile.VendorListPEN.end(), TestFileIter);
+       ASSERT_EQ("696", TestFileIter->second);
+
+       TestFileIter = TestFile.VendorListElement.find(0);
+       ASSERT_NE(TestFile.VendorListElement.end(), TestFileIter);
+       ASSERT_EQ("CAKE", TestFileIter->second);
+
+       // Start with the second vendor namespace.
+       
+       TestFileIter = TestFile.VendorList.find(1);
+       ASSERT_NE(TestFile.VendorList.end(), TestFileIter);
+       ASSERT_EQ("Orange", TestFileIter->second);
+
+       TestFileIter = TestFile.VendorListPEN.find(1);
+       ASSERT_NE(TestFile.VendorListPEN.end(), TestFileIter);
+       ASSERT_EQ("696", TestFileIter->second);
+
+       TestFileIter = TestFile.VendorListElement.find(1);
+       ASSERT_NE(TestFile.VendorListElement.end(), TestFileIter);
+       ASSERT_EQ("DRINK", TestFileIter->second);
+
+       // Start with the third vendor namespace.
+       
+       TestFileIter = TestFile.VendorList.find(2);
+       ASSERT_NE(TestFile.VendorList.end(), TestFileIter);
+       ASSERT_EQ("Shiena Nishizawa", TestFileIter->second);
+
+       TestFileIter = TestFile.VendorListPEN.find(2);
+       ASSERT_NE(TestFile.VendorListPEN.end(), TestFileIter);
+       ASSERT_EQ("696", TestFileIter->second);
+
+       TestFileIter = TestFile.VendorListElement.find(2);
+       ASSERT_NE(TestFile.VendorListElement.end(), TestFileIter);
+       ASSERT_EQ("MUSIC", TestFileIter->second);
+
+}
+
+TEST(ContactLoad, XTokenTest){
+
+       ContactDataObject TestFile;
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+       std::map<int,wxString>::iterator TestFileIter;
+       std::map<int,int>::iterator TestFileIntIter;
+
+       // Three X-FARM variables.
+
+       TestFileIter = TestFile.XTokenList.find(0);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("Yard", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(0);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("FARM", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenList.find(1);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("Animals", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(1);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("FARM", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenList.find(2);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("Shed", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(2);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("FARM;LOCATION=Back;TYPE=Vehicles", TestFileIter->second.ToStdString());
+
+       // Three X-DISKSERIAL variables.
+
+       TestFileIter = TestFile.XTokenList.find(3);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("14444", TestFileIter->second);
+       
+       TestFileIter = TestFile.XTokenListTokens.find(3);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("DISKSERIAL", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenList.find(4);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("7555", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(4);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("DISKSERIAL", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenList.find(5);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("3250539032590", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(5);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("DISKSERIAL;STATUS=DESTROYED;TYPE=FLASH", TestFileIter->second.ToStdString());
+
+       // Three X-FOODS variables.
+
+       TestFileIter = TestFile.XTokenList.find(6);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("Lemon Cake", TestFileIter->second);
+       
+       TestFileIter = TestFile.XTokenListTokens.find(6);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("FOODS;STATUS=HIGH", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenList.find(7);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("Starrey Gazey Pie", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(7);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("FOODS;STATUS=LOW", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenList.find(8);
+       ASSERT_NE(TestFile.XTokenList.end(), TestFileIter);
+       ASSERT_EQ("Cornish Pasties", TestFileIter->second);
+
+       TestFileIter = TestFile.XTokenListTokens.find(8);
+       ASSERT_NE(TestFile.XTokenListTokens.end(), TestFileIter);
+       ASSERT_EQ("FOODS;STATUS=FAVOURITE;TYPE=CHEESEANDONION", TestFileIter->second.ToStdString());
+
+}
+
 // TODO: Add tests for the Contact Loading process.
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy