Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added property value, ALTID, LANGUAGE source, header and unit tests for the N vCard...
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 12 Dec 2015 21:14:56 +0000 (21:14 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 12 Dec 2015 21:14:56 +0000 (21:14 +0000)
source/contacteditor/ContactDataObject.cpp
source/contacteditor/ContactDataObject.h
source/tests/LoadCheck-Load4.vcf
source/tests/xestiaab_contactload.h

index 266a5e0..54e0bfd 100644 (file)
@@ -74,6 +74,7 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
        bool QuoteMode = FALSE;
        bool PropertyFind = TRUE;
        bool KindProcessed = FALSE;
+       bool NameProcessed = FALSE;
        int ContactLineLen = 0;
        int QuoteBreakPoint = 0;
        int GroupCount = 0;
@@ -190,6 +191,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
                        ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
                        FNCount++;
                
+               } else if (Property == wxT("N") && NameProcessed == FALSE){
+               
+                       ProcessN(PropertySeg1, PropertySeg2);
+                       NameProcessed = TRUE;
+               
                }
                
        }
@@ -428,6 +434,57 @@ void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2,
 
 }
 
+void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
+
+       std::map<int, int> SplitPoints;
+       std::map<int, int> SplitLength;
+
+       int intPrevValue = 3;
+       int intPref = 0;                        
+       int intType = 0;
+       
+       SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+       
+       intPrevValue = 2;
+       
+       NameForename = PropertySeg2;
+       
+       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")){
+
+                       NameAltID = PropertyValue;
+               
+               } else if (PropertyName == wxT("LANGUAGE")){
+               
+                       NameLanguage = PropertyValue;
+               
+               }
+       
+       }
+
+} 
+
 void SplitValues(wxString *PropertyLine, 
        std::map<int,int> *SplitPoints, 
        std::map<int,int> *SplitLength, 
index b62c6a8..ead05b8 100644 (file)
@@ -561,6 +561,7 @@ class ContactDataObject{
        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);
 
 };
 
index a3b057b..866e808 100644 (file)
@@ -4,4 +4,5 @@ KIND:individual
 MEMBER;ALTID=35;PID=40;PREF=45;MEDIATYPE=text/plain;EXAMPLE=Meep:7a2af44d-64
  31-4797-a55f-d86d56304fda
 FN;TYPE=work;LANGUAGE=kw;ALTID=500;PID=40;PREF=45;EXAMPLE=Baaa:Test Contact
+N;ALTID=3;LANGUAGE=kw:Test
 END:VCARD
index b3e53f4..4585abc 100644 (file)
@@ -131,6 +131,13 @@ TEST(ContactLoad, ContactLoadTests){
        ASSERT_NE(TestFile.FullNamesListTokens.end(), TestFileIter);
        ASSERT_EQ("EXAMPLE=Baaa", TestFileIter->second);
        
+       // Check that the name has been read (N).
+       
+       ASSERT_EQ("Test", TestFile.NameForename); 
+       ASSERT_EQ("3", TestFile.NameAltID); 
+       ASSERT_EQ("kw", TestFile.NameLanguage); 
+
+       
 }
 
 // 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