Skip to content

Commit dac0189

Browse files
authored
Added an option to bypass the call to resolve_well_known_caldav () (#1780)
1 parent 409aee8 commit dac0189

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

src/Dialogs/Preferences/Pages/Accounts/CalDAVSetup.vala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Dialogs.Preferences.Pages.CalDAVSetup : Dialogs.Preferences.Pages.B
3232
// Advanced Options
3333
private Adw.EntryRow calendar_home_entry;
3434
private Widgets.IgnoreSSLSwitchRow ignore_ssl_row;
35+
private Widgets.BypassResolveSwitchRow bypass_resolve_row;
3536

3637
public CalDAVSetup (Adw.PreferencesDialog preferences_dialog, Accounts accounts_page) {
3738
Object (
@@ -65,6 +66,7 @@ public class Dialogs.Preferences.Pages.CalDAVSetup : Dialogs.Preferences.Pages.B
6566
calendar_home_entry.title = _("Calendar Home URL");
6667

6768
ignore_ssl_row = new Widgets.IgnoreSSLSwitchRow ();
69+
bypass_resolve_row = new Widgets.BypassResolveSwitchRow ();
6870

6971
var advanced_options_revealer = new Gtk.Revealer () {
7072
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN,
@@ -83,6 +85,7 @@ public class Dialogs.Preferences.Pages.CalDAVSetup : Dialogs.Preferences.Pages.B
8385

8486
advanced_entries_group.add (calendar_home_entry);
8587
advanced_entries_group.add (ignore_ssl_row);
88+
advanced_entries_group.add (bypass_resolve_row);
8689

8790
login_button = new Widgets.LoadingButton.with_label (_("Log In")) {
8891
margin_top = 12,
@@ -178,7 +181,18 @@ public class Dialogs.Preferences.Pages.CalDAVSetup : Dialogs.Preferences.Pages.B
178181
return;
179182
}
180183

181-
var dav_endpoint = yield Services.CalDAV.Core.get_default ().resolve_well_known_caldav (new Soup.Session (), server_entry.text, ignore_ssl_row.active);
184+
/*
185+
* The `resolve_well_known_caldav ()` function can fail on misconfigured CalDAV servers where
186+
* the `Location` header doesn't contain the configured port.
187+
* This option allows us to bypass the call.
188+
*/
189+
var dav_endpoint = "";
190+
var bypass_resolve = bypass_resolve_row.active;
191+
if (bypass_resolve) {
192+
dav_endpoint = server_entry.text;
193+
} else {
194+
dav_endpoint = yield Services.CalDAV.Core.get_default ().resolve_well_known_caldav (new Soup.Session (), server_entry.text, ignore_ssl_row.active);
195+
}
182196

183197
var calendar_home = "";
184198

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright © 2025 Alain M. (https://github.com/alainm23/planify)
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 3 of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public
15+
* License along with this program; if not, write to the
16+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+
* Boston, MA 02110-1301 USA
18+
*
19+
* Authored by: nijakow (https://github.com/nijakow)
20+
*/
21+
22+
public class Widgets.BypassResolveSwitchRow : Adw.ActionRow {
23+
private Gtk.Switch toggle;
24+
25+
public bool active {
26+
get { return toggle.active; }
27+
set { toggle.active = value; }
28+
}
29+
30+
public BypassResolveSwitchRow () {
31+
title = _("Bypass Location Resolve");
32+
subtitle = _("Workaround for CalDAV connection issues with connections using non-default ports");
33+
34+
toggle = new Gtk.Switch () {
35+
valign = Gtk.Align.CENTER,
36+
halign = Gtk.Align.END
37+
};
38+
39+
add_suffix (toggle);
40+
activatable_widget = toggle;
41+
42+
toggle.state_set.connect ((state) => {
43+
if (state) {
44+
var dialog = new Adw.AlertDialog (
45+
_("Warning"),
46+
_("This will disable the CalDAV resolve process.\nProceed at your own risk")
47+
);
48+
dialog.add_response ("cancel", _("Cancel"));
49+
dialog.add_response ("accept", _("Continue Anyway"));
50+
dialog.set_response_appearance ("accept", Adw.ResponseAppearance.DESTRUCTIVE);
51+
52+
dialog.response.connect ((response) => {
53+
if (response == "accept") {
54+
toggle.state = true;
55+
toggle.active = true;
56+
} else {
57+
toggle.state = false;
58+
toggle.active = false;
59+
}
60+
});
61+
62+
dialog.present (Planify._instance.main_window);
63+
return true; // prevent immediate state change
64+
}
65+
return false;
66+
});
67+
68+
}
69+
}
70+
71+

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ sources = files(
6363
'Widgets/ReorderChild.vala',
6464
'Widgets/FilterFlowBox.vala',
6565
'Widgets/FilterFlowBoxChild.vala',
66+
'Widgets/BypassResolveSwitchRow.vala',
6667
'Widgets/IgnoreSSLSwitchRow.vala',
6768
'Widgets/Attachments.vala',
6869
'Widgets/AttachmentRow.vala',

0 commit comments

Comments
 (0)