Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced string processing in SOURCE with ProcessStringValue.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Dec 2015 03:46:36 +0000 (03:46 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 28 Dec 2015 03:46:36 +0000 (03:46 +0000)
source/contacteditor/ContactDataObject.cpp
source/contacteditor/ContactDataObject.h

index bc45c48..4c2cbc6 100644 (file)
@@ -549,6 +549,7 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe
        wxString PropertyValue;
        wxString PropertyTokens;
        bool FirstToken = TRUE;
+       bool PropertyMatched = FALSE;
        int intSplitsFound = 0;
        int intSplitSize = 0;
        int intPrevValue = 8;
@@ -599,42 +600,28 @@ void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySe
                
                CaptureString(&PropertyValue, FALSE);
                
-               if (PropertyName == wxT("ALTID")){
-
-                       SourceListAltID.erase(*SourceCount);
-                       SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
+               ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
+               ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
+               ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
+               ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
                
-               } else if (PropertyName == wxT("PID")){
-
-                       SourceListPID.erase(*SourceCount);
-                       SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
+               if (PropertyMatched == TRUE){
                
-               } else if (PropertyName == wxT("PREF")){
-                       
-                       ProcessIntegerValue(&SourceListPref, &PropertyValue, SourceCount);
-
-               } else if (PropertyName == wxT("MEDIATYPE")){
+                       PropertyMatched = FALSE;
+                       continue;
                
-                       SourceListMediatype.erase(*SourceCount);
-                       SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
-
-               } else {
+               }
                
-                       // Something else we don't know about so append
-                       // to the tokens variable.
-                       
-                       if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
+               if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
                        
-                               if (FirstToken == TRUE){
-                               
-                                       PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
-                                       FirstToken = FALSE;
-                               
-                               } else {
-                               
-                                       PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
+                       if (FirstToken == TRUE){
                                
-                               }
+                               PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
+                               FirstToken = FALSE;
+                       
+                       } else {
+                       
+                               PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
                        
                        }
                
@@ -5496,15 +5483,50 @@ void ProcessStringValue(wxString *PropertyName,
        wxString PropertyNameMatch,
        std::map<int,wxString> *MapPtr,
        wxString *PropertyValue,
-       int *ItemCount){
-
+       int *ItemCount,
+       bool *PropertyMatched){
+       
        if (*PropertyName == PropertyNameMatch){
                MapPtr->erase(*ItemCount);
                MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
+               *PropertyMatched = TRUE;
        }
        
 }
 
+void ProcessIntegerValue(wxString *PropertyName,
+       wxString PropertyNameMatch,
+       std::map<int,int> *PrefPtr, 
+       wxString *PropertyValue, 
+       int *ItemCount,
+       bool *PropertyMatched){
+
+       if (*PropertyName == PropertyNameMatch){
+               *PropertyMatched = TRUE;
+       } else {
+               return;
+       }
+
+       int PriorityNumber = 0; 
+       bool ValidNumber = TRUE;
+                       
+       try{
+               PriorityNumber = std::stoi(PropertyValue->ToStdString());
+       }
+                       
+       catch(std::invalid_argument &e){
+               ValidNumber = FALSE;
+       }
+
+       if (ValidNumber == TRUE){
+
+               PrefPtr->erase(*ItemCount);
+               PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
+
+       }
+
+}
+
 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
        wxString *PropertyValue, 
        int *ItemCount){
index a6e9761..a5c1fbb 100644 (file)
@@ -618,6 +618,13 @@ void CheckType(wxString *PropertySeg1,
        int *intPrevValue, 
        PropertyType *intType);
 
+void ProcessIntegerValue(wxString *PropertyName,
+       wxString PropertyNameMatch,
+       std::map<int,int> *PrefPtr, 
+       wxString *PropertyValue, 
+       int *ItemCount,
+       bool *PropertyMatched);
+       
 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
        wxString *PropertyValue, 
        int *ItemCount);
@@ -626,6 +633,7 @@ void ProcessStringValue(wxString *PropertyName,
        wxString PropertyNameMatch,
        std::map<int,wxString> *MapPtr,
        wxString *PropertyValue,
-       int *ItemCount);
+       int *ItemCount,
+       bool *PropertyMatched);
 
 #endif
\ 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