Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Merge branch 'master' of ssh://digit.mahou.co.uk/home/kirinji/repos/xestiacal
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 25 Feb 2016 21:51:35 +0000 (21:51 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 25 Feb 2016 21:51:35 +0000 (21:51 +0000)
source/objects/CalDAV/CalDAV.cpp
source/objects/CalDAV/CalDAV.h
source/tests/xestiacalendar_caldav.h
source/tests/xestiacalendar_testcommon.cpp
source/tests/xestiacalendar_testcommon.h

index ec931d4..33c81b4 100644 (file)
@@ -1,2 +1,58 @@
 #include "CalDAV.h"
 
+bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData){
+
+       // Check if the passed CalDAV Connection Data is has
+       // an address set. Return false if nullptr is used.
+
+       if (ConnData == nullptr){
+       
+               return false;
+       
+       }
+       
+       // Check the server hostname. Return false
+       // if no value has been set.
+       
+       if (ConnData->Hostname.size() > 0){
+       
+               return false;
+       
+       }
+       
+       // Check the server port. Return false if
+       // no value has been set or the port number
+       // is less than 1 or higher than 65535.
+       
+       if (ConnData->Port < 1 || ConnData->Port > 65535){
+       
+               return false;
+       
+       }
+       
+       // Check the server username. Return false
+       // if no value has been set.
+
+       if (ConnData->Username.size() > 0){
+               return false;
+       }
+
+       // Check the server password. Return false
+       // if no value has been set.
+
+       if (ConnData->Password.size() > 0){
+               return false;
+       }
+
+       // Cannot check UseSSL: It is either true
+       // or false.
+       
+       // Cannot check Prefix: The prefix may need
+       // to be worked out first.
+
+       // No errors were found whilst checking so
+       // return true.
+       
+       return true;
+
+}
\ No newline at end of file
index c4f1a8b..8a9c06c 100644 (file)
@@ -32,7 +32,11 @@ struct CalDAVConnectionData{
 
 struct CalDAVStatus{
 
-               
+       string Hostname;
+       int Port;
+       string Username;
+       string Prefix;
+       bool UseSSL;    
 
 };
 
@@ -53,4 +57,9 @@ class CalDAV{
        
 };
 
+// Subroutines that are used with the 
+// CalDAVConnectionData struct.
+
+bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
+
 #endif
index f2f7654..955113b 100644 (file)
@@ -25,15 +25,44 @@ using namespace std;
 
 TEST(CalDAV, BasicTests){
 
+       CalDAVConnectionData ConnPlain;
+       CalDAVConnectionData ConnNormal;
+       CalDAVConnectionData ConnFail;
+       CalDAVConnectionData ConnTimeout;
+       ProcessConnectionDataFileResult DataFileResult;
+
        bool ValidDataPlain = false;
        bool ValidDataNormal = false;
        bool ValidDataFail = false;
        bool ValidDataTimeout = false;
 
        // Attempt to read the caldavtest-plain.auth file.
+       
+       DataFileResult = ProcessConnectionDataFile("caldavtest-plain.auth", &ConnPlain);
+       if (DataFileResult != PROCESSCONNECTIONDATAFILE_OK){
+               ValidDataPlain = true;
+       }
+       
+       // Attempt to read the caldavtest.auth file.
+
+       DataFileResult = ProcessConnectionDataFile("caldavtest.auth", &ConnNormal);
+       if (DataFileResult != PROCESSCONNECTIONDATAFILE_OK){
+               ValidDataNormal = true;
+       }
+       
        // Attempt to read the caldavtest-fail.auth file.
+       
+       DataFileResult = ProcessConnectionDataFile("caldavtest-fail.auth", &ConnFail);
+       if (DataFileResult != PROCESSCONNECTIONDATAFILE_OK){
+               ValidDataFail = true;
+       }
+       
        // Attempt to read the caldavtest-timeout.auth file.
-       // Attempt to read the caldavtest.auth file.
+       
+       DataFileResult = ProcessConnectionDataFile("caldavtest-fail.auth", &ConnTimeout);
+       if (DataFileResult != PROCESSCONNECTIONDATAFILE_OK){
+               ValidDataTimeout = true;
+       }
 
        if (ValidDataPlain == false){
        
index 6c58342..fd716c4 100644 (file)
@@ -172,6 +172,17 @@ ProcessConnectionDataFileResult ProcessConnectionDataFile(string DataFilename,
 
        }
        
+       // Check that the CalDAV connection data object 
+       // contains valid data.
+       
+       bool CalDAVConnDataResult = CalDAVObjectValidSettings(&ConnData);
+       
+       if (CalDAVConnDataResult == false){
+               ProcessResult = PROCESSCONNECTIONDATAFILE_INVALID;
+       } else {
+               ProcessResult = PROCESSCONNECTIONDATAFILE_OK;
+       }
+       
        return ProcessResult;
                
 }
\ No newline at end of file
index 739bd64..363b9b8 100644 (file)
@@ -11,7 +11,8 @@ enum ProcessConnectionDataFileResult{
        PROCESSCONNECTIONDATAFILE_UNITTESTFAIL = -1,
        PROCESSCONNECTIONDATAFILE_OK,
        PROCESSCONNECTIONDATAFILE_MISSING,
-       PROCESSCONNECTIONDATAFILE_CANNOTOPEN
+       PROCESSCONNECTIONDATAFILE_CANNOTOPEN,
+       PROCESSCONNECTIONDATAFILE_INVALID
 };
 
 ProcessConnectionDataFileResult ProcessConnectionDataFile(string DataFilename, 
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