Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added remaining property source code and unit tests for the FN vCard member for Conta...
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
index 28c29e7..266a5e0 100644 (file)
@@ -177,15 +177,11 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
                PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
                
                 if (Property == wxT("KIND") && KindProcessed == FALSE){
-               
-                       // See frmContactEditor-LoadGroup.cpp
-               
+                               
                        ProcessKind(PropertySeg2);
                
                } else if (Property == wxT("MEMBER")){
 
-                       // See frmContactEditor-LoadGroup.cpp
-
                        ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
                        GroupCount++;   
                
@@ -240,8 +236,6 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe
 
        intPrevValue = 7;
        
-       // Look for type before continuing.
-       
        wxString PropertyName;
        wxString PropertyValue;
        wxString PropertyData;
@@ -263,8 +257,6 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe
                intPrevValue = intiter->second;
                
                CaptureString(&PropertyValue, FALSE);
-               
-               //ContactProcess::ContactProcessCaptureStrings(&PropertyValue);
        
                if (PropertyName == wxT("ALTID")){
 
@@ -331,8 +323,109 @@ void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySe
 
 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
 
+       std::map<int, int> SplitPoints;
+       std::map<int, int> SplitLength;
+
+       int intPrevValue = 4;
+       int intPref = 0;                        
+       int intType = 0;
+       
+       SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
+
+       intPrevValue = 3;
+       
+       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("TYPE")){
+
+                       if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
+                               PropertyValue == wxT("work") ){
+
+                               FullNamesListType.erase(*FNCount);
+                               FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
+               
+                       }
+               
+               } else if (PropertyName == wxT("LANGUAGE")){
+
+                       FullNamesListLanguage.erase(*FNCount);
+                       FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
+               
+               } else if (PropertyName == wxT("ALTID")){
+               
+                       FullNamesListAltID.erase(*FNCount);
+                       FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
+               
+               } else if (PropertyName == wxT("PID")){
+
+                       FullNamesListPID.erase(*FNCount);
+                       FullNamesListPID.insert(std::make_pair(*FNCount, 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){
+
+                               FullNamesListPref.erase(*FNCount);
+                               FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
+
+                       }
+               
+               } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
+                       
+                       if (FirstToken == TRUE){
+                               
+                               PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+                               FirstToken = FALSE;
+                               
+                       } else {
+                       
+                               PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+                               
+                       }
+                       
+               } 
+       
+       }
+
        FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
 
+       if (!PropertyTokens.IsEmpty()){
+       
+               FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
+       
+       }
+
 }
 
 void SplitValues(wxString *PropertyLine, 
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