From fc4e51d8910464a793f9f23bd56b37f314931936 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 1 Mar 2016 17:09:21 +0000 Subject: [PATCH] Added Timeout setting to CalDAVConnectionData/CalDAVStatus --- source/objects/CalDAV/CalDAV.cpp | 2 ++ source/objects/CalDAV/CalDAV.h | 2 ++ source/tests/xestiacalendar_caldav.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/source/objects/CalDAV/CalDAV.cpp b/source/objects/CalDAV/CalDAV.cpp index c781e94..964f286 100644 --- a/source/objects/CalDAV/CalDAV.cpp +++ b/source/objects/CalDAV/CalDAV.cpp @@ -77,6 +77,7 @@ CalDAVStatus CalDAV::GetConnectionData(){ ConnectionStatus.Username = ConnectionData.Username; ConnectionStatus.Prefix = ConnectionData.Prefix; ConnectionStatus.UseSSL = ConnectionData.UseSSL; + ConnectionStatus.Timeout = ConnectionData.Timeout; return ConnectionStatus; @@ -121,6 +122,7 @@ CalDAVServerResult CalDAV::Connect(){ curl_easy_setopt(ConnectionHandle, CURLOPT_USERPWD, ServerUserPass.c_str()); curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_easy_setopt(ConnectionHandle, CURLOPT_FAILONERROR, 1L); + curl_easy_setopt(ConnectionHandle, CURLOPT_TIMEOUT, ConnectionData.Timeout); curl_easy_setopt(ConnectionHandle, CURLOPT_WRITEFUNCTION, CalDAVOutput); curl_easy_setopt(ConnectionHandle, CURLOPT_WRITEDATA, &ServerData); curl_easy_setopt(ConnectionHandle, CURLOPT_WRITEHEADER, &ServerHeader); diff --git a/source/objects/CalDAV/CalDAV.h b/source/objects/CalDAV/CalDAV.h index cbae3d8..2ccd4ea 100644 --- a/source/objects/CalDAV/CalDAV.h +++ b/source/objects/CalDAV/CalDAV.h @@ -43,6 +43,7 @@ struct CalDAVConnectionData{ string Password = ""; string Prefix = ""; bool UseSSL = true; + int Timeout = 60; }; @@ -58,6 +59,7 @@ struct CalDAVStatus{ string Username; string Prefix; bool UseSSL; + int Timeout; }; diff --git a/source/tests/xestiacalendar_caldav.h b/source/tests/xestiacalendar_caldav.h index e2660fb..5fd20c6 100644 --- a/source/tests/xestiacalendar_caldav.h +++ b/source/tests/xestiacalendar_caldav.h @@ -236,6 +236,8 @@ TEST(CalDAV, BasicTests){ // (*nix version) Setup an inital connection on a server where // a timeout occurs. + ConnTimeout.Timeout = 5; + CalDAV CalDAVTimeout; CalDAVTimeout.SetupConnectionData(&ConnTimeout); @@ -248,6 +250,7 @@ TEST(CalDAV, BasicTests){ ASSERT_EQ(CalDAVTimeoutStatus.Username, ConnTimeout.Username); ASSERT_EQ(CalDAVTimeoutStatus.Port, ConnTimeout.Port); ASSERT_EQ(CalDAVTimeoutStatus.Prefix, ConnTimeout.Prefix); + ASSERT_EQ(CalDAVTimeoutStatus.Timeout, ConnTimeout.Timeout); ASSERT_EQ(CalDAVTimeoutStatus.UseSSL, ConnTimeout.UseSSL); // Verify that the connection had timed out. -- 2.39.2