commit 101b23b980df2c46af954e116d4f0972a3b4fda2
parent d7aa63d7d749e7019a11a37662b38ec451bc4c63
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Tue, 4 Feb 2025 23:03:30 +0100
fix(caldav): caldav_port combinations
Diffstat:
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/caldav.c b/src/caldav.c
@@ -330,7 +330,11 @@ int caldav_sync(struct tm* date,
// get the home-set of the user
char uri[300];
- sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, current_user_principal);
+ if (caldav_port == NULL) {
+ sprintf(uri, "%s://%s%s", caldav_host_scheme, caldav_host, current_user_principal);
+ } else {
+ sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, current_user_principal);
+ }
char* home_set = caldav_req(date, uri, "PROPFIND", homeset_request, 0, basicauth_enabled, "application/xml", 0);
debug("Home set xml %s", home_set);
@@ -348,7 +352,11 @@ int caldav_sync(struct tm* date,
return -1;
}
- sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, home_set_parsed);
+ if (caldav_port == NULL) {
+ sprintf(uri, "%s://%s%s", caldav_host_scheme, caldav_host, home_set_parsed);
+ } else {
+ sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, home_set_parsed);
+ }
free(home_set);
free(home_set_parsed);
@@ -391,7 +399,11 @@ int caldav_sync(struct tm* date,
dstr_end);
// fetch event for the cursor date
- sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, calendar_href);
+ if (caldav_port == NULL) {
+ sprintf(uri, "%s://%s%s", caldav_host_scheme, caldav_host, calendar_href);
+ } else {
+ sprintf(uri, "%s://%s:%s%s", caldav_host_scheme, caldav_host, caldav_port, calendar_href);
+ }
char* events_xml = caldav_req(date, uri, "REPORT", caldata_postfields, 1, basicauth_enabled, "application/xml", 0);
@@ -480,7 +492,11 @@ int caldav_sync(struct tm* date,
if (remote_uid) {
// purge any existing daily calendar entries on the remote side
char event_uri[300];
- sprintf(event_uri, "%s://%s:%s%s%s.ics", caldav_host_scheme, caldav_host, caldav_port, calendar_href, remote_uid);
+ if (caldav_port == NULL) {
+ sprintf(event_uri, "%s://%s:%s%s.ics", caldav_host_scheme, caldav_host, calendar_href, remote_uid);
+ } else {
+ sprintf(event_uri, "%s://%s:%s%s%s.ics", caldav_host_scheme, caldav_host, caldav_port, calendar_href, remote_uid);
+ }
//sprintf(event_uri, "%s%s%s.ics", CONFIG.caldav_server, calendar_href, remote_uid);
debug("Event URI for DELETE request: %s", event_uri);
char* response = caldav_req(date, event_uri, "DELETE", NULL, 0, basicauth_enabled, "", 0);