Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code to process the configuration files in the CalDAV unit tests.
authorKiri <kiri@Alejandra.alejandra.local>
Tue, 23 Feb 2016 21:15:33 +0000 (21:15 +0000)
committerKiri <kiri@Alejandra.alejandra.local>
Tue, 23 Feb 2016 21:15:33 +0000 (21:15 +0000)
source/tests/xestiacalendar_testcommon.cpp

index 99cf8fa..6c58342 100644 (file)
@@ -42,6 +42,136 @@ ProcessConnectionDataFileResult ProcessConnectionDataFile(string DataFilename,
        
        delete[] BufferRead;
        
+       bool NewLine = false;
+       bool SkipMode = false;
+       bool EqualFound = false;
+       bool QuoteMode = false;
+       bool ServerNameFound = false;
+       bool ServerUserFound = false;
+       bool ServerPassFound = false;
+       bool ServerSSLFound = false;
+       bool ServerPortFound = false;
+       bool ServerPrefixFound = false;
+       char BufferChar = 0;
+       int StringDataSize = ReceivedStringData.size();
+       int SeekCount = 0;
+       string PropertyName;
+       string PropertyValue;
+
+       while (SeekCount < StringDataSize){
+
+               if (ReceivedStringData[SeekCount] == '='){
+               
+                       EqualFound = true;              
+               
+               } else if (ReceivedStringData[SeekCount] == '\n'){
+               
+                       // Newline reached. Check for what type of
+                       // data it is.
+               
+                       // Chceck that the equals sign has been found,
+                       // there is a values in the property name
+                       // and property value before doing anything.
+                                               
+                       if (EqualFound == true &&
+                               PropertyName.size() > 0 &&
+                               PropertyValue.size() > 0){
+                       
+                               if (PropertyName == "server" && ServerNameFound == false){
+                               
+                                       // Setup the server hostname.
+                               
+                                       ConnData->Hostname = PropertyValue;
+                                       ServerNameFound = true;
+                               
+                               } else if (PropertyName == "port" && ServerPortFound == false){
+                               
+                                       // Setup the server port.
+                               
+                                       int PortNum;
+                                       bool PortNumValid = true;
+                               
+                                       try{
+                                               PortNum = stoi(PropertyValue);
+                                       }
+                                       
+                                       catch(const invalid_argument &oor){
+                                               PortNumValid = false;
+                                       }
+                                       
+                                       // Port Number is valid so add to the
+                                       // CalDAVConnectionData handle.
+                                       
+                                       if (PortNumValid == true){
+                                               ConnData->Port = PortNum;
+                                               ServerPortFound = true;
+                                       }
+                               
+                               } else if (PropertyName == "user" && ServerUserFound == false){
+                               
+                                       // Setup the server user.
+                                       
+                                       ConnData->Username = PropertyValue;
+                                       ServerUserFound = true;
+                               
+                               } else if (PropertyName == "pass" && ServerPassFound == false){
+                               
+                                       // Setup the server pass.
+                                       
+                                       ConnData->Password = PropertyValue;
+                                       ServerPassFound = true;                         
+                               
+                               } else if (PropertyName == "ssl" && ServerSSLFound == false){
+                               
+                                       // Setup the server SSL status.
+                                       
+                                       if (PropertyValue == "true"){
+                                               ConnData->UseSSL = true;
+                                       } else {
+                                               ConnData->UseSSL = false;                                       
+                                       }
+                                       
+                                       ServerSSLFound = true;
+                               
+                               } else if (PropertyName == "prefix" && ServerPrefixFound == false){
+                               
+                                       // Setup the server prefix.
+                               
+                                       ConnData->Prefix = PropertyValue;
+                                       ServerPrefixFound = true;
+                               
+                               }
+                               
+                       }
+                       
+                       // Reset the variables.
+               
+                       EqualFound = false;
+                       PropertyName.clear();
+                       PropertyValue.clear();
+               
+               } else {
+               
+                       // No special character so add it to the 
+                       // Property name or value depending on 
+                       // if the equal sign has been found.
+               
+                       BufferChar = ReceivedStringData[SeekCount];
+               
+                       if (EqualFound == true){
+                               PropertyValue += BufferChar;
+                       } else {
+                               PropertyName += BufferChar;                     
+                       }
+                       
+                       BufferChar = 0;
+               
+               }
+
+               SeekCount++;
+
+       }
+       
        return ProcessResult;
                
 }
\ 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