From: Steve Brokenshire Date: Thu, 25 Feb 2016 21:51:35 +0000 (+0000) Subject: Merge branch 'master' of ssh://digit.mahou.co.uk/home/kirinji/repos/xestiacal X-Git-Tag: release-0.02~343 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=b776fb87f9406910f146cd935605b0e505943142;hp=78a200fc60edf5d14f13644df12cb468e09b4480;p=xestiacalendar%2F.git Merge branch 'master' of ssh://digit.mahou.co.uk/home/kirinji/repos/xestiacal --- diff --git a/source/objects/CalDAV/CalDAV.cpp b/source/objects/CalDAV/CalDAV.cpp index ec931d4..33c81b4 100644 --- a/source/objects/CalDAV/CalDAV.cpp +++ b/source/objects/CalDAV/CalDAV.cpp @@ -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 diff --git a/source/objects/CalDAV/CalDAV.h b/source/objects/CalDAV/CalDAV.h index c4f1a8b..8a9c06c 100644 --- a/source/objects/CalDAV/CalDAV.h +++ b/source/objects/CalDAV/CalDAV.h @@ -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 diff --git a/source/tests/xestiacalendar_caldav.h b/source/tests/xestiacalendar_caldav.h index f2f7654..955113b 100644 --- a/source/tests/xestiacalendar_caldav.h +++ b/source/tests/xestiacalendar_caldav.h @@ -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){ diff --git a/source/tests/xestiacalendar_testcommon.cpp b/source/tests/xestiacalendar_testcommon.cpp index 6c58342..fd716c4 100644 --- a/source/tests/xestiacalendar_testcommon.cpp +++ b/source/tests/xestiacalendar_testcommon.cpp @@ -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 diff --git a/source/tests/xestiacalendar_testcommon.h b/source/tests/xestiacalendar_testcommon.h index 739bd64..363b9b8 100644 --- a/source/tests/xestiacalendar_testcommon.h +++ b/source/tests/xestiacalendar_testcommon.h @@ -11,7 +11,8 @@ enum ProcessConnectionDataFileResult{ PROCESSCONNECTIONDATAFILE_UNITTESTFAIL = -1, PROCESSCONNECTIONDATAFILE_OK, PROCESSCONNECTIONDATAFILE_MISSING, - PROCESSCONNECTIONDATAFILE_CANNOTOPEN + PROCESSCONNECTIONDATAFILE_CANNOTOPEN, + PROCESSCONNECTIONDATAFILE_INVALID }; ProcessConnectionDataFileResult ProcessConnectionDataFile(string DataFilename,