Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit tests for the CLIENTPIDMAP vCard Property for...
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Dec 2015 01:23:12 +0000 (01:23 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Dec 2015 01:23:12 +0000 (01:23 +0000)
source/contacteditor/ContactDataObject.cpp
source/contacteditor/ContactDataObject.h
source/tests/LoadCheck-Load4.vcf
source/tests/xestiaab_contactload.h

index 66f4259..ffca460 100644 (file)
@@ -110,6 +110,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
        int VendorCount = 0;
        int XTokenCount = 0;
        int XMLCount = 0;
+       int ClientPIDCount = 0;
        wxString ContactLine;
        wxString PropertyLine;
        wxString PropertySeg1;
@@ -247,6 +248,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
                        ProcessN(PropertySeg1, PropertySeg2);
                        NameProcessed = TRUE;
                
+               } else if (Property == wxT("CLIENTPIDMAP")){
+               
+                       ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
+                       ClientPIDCount++;
+               
                } else if (Property == wxT("NICKNAME")){
                                                
                        ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
@@ -1092,6 +1098,90 @@ void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
 
 }
 
+void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
+
+       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 = 14;
+       int intPref = 0;                        
+       int intType = 0;
+       
+       SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+       
+       intPrevValue = 13;
+
+       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.IsEmpty() || PropertyName.IsEmpty()){
+               
+                       continue;
+               
+               }
+                                                       
+               if (FirstToken == TRUE){
+                               
+                       PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+                       FirstToken = FALSE;
+                               
+               } else {
+                               
+                       PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+                               
+               }
+       
+       }       
+       
+       CaptureString(&PropertySeg2, FALSE);
+       
+       ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
+       
+       if (!PropertyTokens.IsEmpty()){
+       
+               ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
+       
+       }
+
+}
+
 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
 
        std::map<int, int> SplitPoints;
index 3179f56..4cf459d 100644 (file)
@@ -61,6 +61,7 @@ class ContactDataObject{
        void ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount);
        void ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount);
        void ProcessN(wxString PropertySeg1, wxString PropertySeg2);
+       void ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount);
        void ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount);
        void ProcessGender(wxString PropertySeg1, wxString PropertySeg2);
        void ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2);
@@ -133,6 +134,9 @@ class ContactDataObject{
        std::map<int, wxString> XMLList;
        std::map<int, wxString> XMLListAltID;
 
+       std::map<int, wxString> ClientPIDList;
+       std::map<int, wxString> ClientPIDListTokens;
+
        /* We don't use these at the moment but we want to keep
          them for compatability reasons */
 
index 90cd129..31462b0 100644 (file)
@@ -3,6 +3,10 @@ VERSION:4.0
 UID:903588-9082374-989120310-AAFECDBCDF
 KIND:individual
 REV;TEST=YES;DATA=NO;MORE=MAYBE:20151227T033000Z
+CLIENTPIDMAP:1;urn;uuid:aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
+CLIENTPIDMAP:2;urn;uuid:ccccccccc-cccc-cccc-cccc-cccccccccccc
+CLIENTPIDMAP;MEEP=MOO;WOOP=WOO:3;urn;uuid:bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbb
+ bbb
 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 07160e0..3c72c72 100644 (file)
@@ -169,6 +169,44 @@ TEST(ContactLoad, UIDTest){
 
 }
 
+TEST(ContactLoad, ClientPIDMapTests){
+
+       ContactDataObject TestFile;
+
+       ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf"));
+
+       std::map<int,wxString>::iterator TestFileIter;
+
+       // Test the first Client PID Map.
+
+       TestFileIter = TestFile.ClientPIDList.find(0);
+       ASSERT_NE(TestFile.ClientPIDList.end(), TestFileIter);
+       ASSERT_EQ("1;urn;uuid:aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", TestFileIter->second);    
+
+       TestFileIter = TestFile.ClientPIDListTokens.find(0);
+       ASSERT_EQ(TestFile.ClientPIDListTokens.end(), TestFileIter);
+
+       // Test the second Client PID Map.
+
+       TestFileIter = TestFile.ClientPIDList.find(1);
+       ASSERT_NE(TestFile.ClientPIDList.end(), TestFileIter);
+       ASSERT_EQ("2;urn;uuid:ccccccccc-cccc-cccc-cccc-cccccccccccc", TestFileIter->second);
+
+       TestFileIter = TestFile.ClientPIDListTokens.find(1);
+       ASSERT_EQ(TestFile.ClientPIDListTokens.end(), TestFileIter);
+       
+       // Test the third Client PID Map.
+       
+       TestFileIter = TestFile.ClientPIDListTokens.find(2);
+       ASSERT_NE(TestFile.ClientPIDListTokens.end(), TestFileIter);
+       ASSERT_EQ("MEEP=MOO;WOOP=WOO", TestFileIter->second);
+
+       TestFileIter = TestFile.ClientPIDList.find(2);
+       ASSERT_NE(TestFile.ClientPIDList.end(), TestFileIter);
+       ASSERT_EQ("3;urn;uuid:bbbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", TestFileIter->second);
+
+}
+
 TEST(ContactLoad, RevisionTests){
 
        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