Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit tests for the REV vCard Property for ContactDataO...
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 27 Dec 2015 03:40:15 +0000 (03:40 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 27 Dec 2015 03:40:15 +0000 (03:40 +0000)
source/contacteditor/ContactDataObject.cpp
source/contacteditor/ContactDataObject.h
source/tests/LoadCheck-Load4.vcf
source/tests/xestiaab_contactload.h

index b9035ed..66f4259 100644 (file)
@@ -79,6 +79,7 @@ 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;
@@ -226,6 +227,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
                        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);
@@ -447,6 +453,85 @@ void ContactDataObject::ProcessKind(wxString KindType){
 
 }
 
+void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
+
+       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;
+       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<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 (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();
index 0c788dd..3179f56 100644 (file)
@@ -55,6 +55,7 @@ class ContactDataObject{
        private:
        
        void ProcessKind(wxString KindData);
+       void ProcessRevision(wxString PropertySeg1, wxString PropertySeg2);
        void ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount);
        void ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount);
        void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount);
@@ -118,6 +119,8 @@ class ContactDataObject{
        wxString GenderTokens;
        
        wxString UIDToken;
+       wxString Revision;
+       wxString RevisionTokens;
        
        std::map<int, wxString> SourceList;
        std::map<int, wxString> SourceListAltID;
index afa0e9a..90cd129 100644 (file)
@@ -2,6 +2,7 @@ BEGIN:VCARD
 VERSION:4.0
 UID:903588-9082374-989120310-AAFECDBCDF
 KIND:individual
+REV;TEST=YES;DATA=NO;MORE=MAYBE:20151227T033000Z
 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
index 1f910d2..07160e0 100644 (file)
@@ -169,6 +169,17 @@ TEST(ContactLoad, UIDTest){
 
 }
 
+TEST(ContactLoad, RevisionTests){
+
+       ContactDataObject TestFile;
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+       
+       ASSERT_EQ("20151227T033000Z", TestFile.Revision);
+       ASSERT_EQ("TEST=YES;DATA=NO;MORE=MAYBE", TestFile.RevisionTokens);
+
+}
+
 TEST(ContactLoad, SourceTests){
 
        ContactDataObject TestFile;
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