Add a Jitsi video conference to events on Core calendars

The event editor offers "Add Video Conference" on the calendars of a
Federated Computer Core. It makes a room with an unguessable name, like
BraveOttersSing-k3f9x2m7, on the Core's Jitsi at jitsi.<CORE_DOMAIN>,
and shows its link with Copy and Remove buttons.

The link goes at the end of the event's notes, which reach everyone
invited whatever their mail app, and in an RFC 7986 CONFERENCE property.
Saving puts the link back in the notes if it was taken out, and "All
events" copies the conference to the whole series.

Existing conferences are found in CONFERENCE, or as Jitsi links in the
notes or location, so the editor doesn't offer a second one and the
popover shows a Join button. The popover now keeps showing a place in
the location alongside a meeting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 07:28:20 -07:00
co-authored by Claude Opus 5.5
parent 0304695ab2
commit 3c118fbb9d
23 changed files with 1809 additions and 61 deletions
+184
View File
@@ -2270,3 +2270,187 @@ gcal_event_attendees_equal (GcalEvent *event1,
return TRUE;
}
static GPtrArray *
get_conference_properties (GcalEvent *self)
{
ICalComponent *icalcomp;
ICalProperty *prop;
GPtrArray *props;
props = g_ptr_array_new_with_free_func (g_object_unref);
icalcomp = e_cal_component_get_icalcomponent (self->component);
for (prop = i_cal_component_get_first_property (icalcomp, I_CAL_CONFERENCE_PROPERTY);
prop;
prop = i_cal_component_get_next_property (icalcomp, I_CAL_CONFERENCE_PROPERTY))
{
g_ptr_array_add (props, prop);
}
return props;
}
/**
* gcal_event_dup_conference_url:
* @self: a #GcalEvent
*
* Gets the URL of the first of the event's conferences, from its iCalendar
* CONFERENCE properties (RFC 7986).
*
* Returns: (transfer full) (nullable): the conference's URL, or %NULL
*/
gchar *
gcal_event_dup_conference_url (GcalEvent *self)
{
g_autoptr (GPtrArray) props = NULL;
g_return_val_if_fail (GCAL_IS_EVENT (self), NULL);
props = get_conference_properties (self);
for (guint i = 0; i < props->len; i++)
{
const gchar *url = i_cal_property_get_conference (g_ptr_array_index (props, i));
if (url && *url)
return g_strdup (url);
}
return NULL;
}
/**
* gcal_event_add_conference:
* @self: a #GcalEvent
* @url: the URL of a video conference
* @label: (nullable): a name for the conference to show people
*
* Adds a CONFERENCE property (RFC 7986) for the video conference at @url
* to @self, unless it has one already.
*/
void
gcal_event_add_conference (GcalEvent *self,
const gchar *url,
const gchar *label)
{
g_autoptr (GPtrArray) props = NULL;
ICalComponent *icalcomp;
ICalProperty *prop;
g_return_if_fail (GCAL_IS_EVENT (self));
g_return_if_fail (url != NULL && *url);
props = get_conference_properties (self);
for (guint i = 0; i < props->len; i++)
{
if (g_strcmp0 (i_cal_property_get_conference (g_ptr_array_index (props, i)), url) == 0)
return;
}
prop = i_cal_property_new_conference (url);
i_cal_property_take_parameter (prop, i_cal_parameter_new_value (I_CAL_VALUE_URI));
/* Parsed, because libical 3 can't make a FEATURE with several values */
i_cal_property_take_parameter (prop, i_cal_parameter_new_from_string ("FEATURE=AUDIO,VIDEO"));
if (label && *label)
i_cal_property_take_parameter (prop, i_cal_parameter_new_label (label));
icalcomp = e_cal_component_get_icalcomponent (self->component);
i_cal_component_take_property (icalcomp, prop);
}
/**
* gcal_event_remove_conference:
* @self: a #GcalEvent
* @url: the URL of a video conference
*
* Removes the CONFERENCE properties for the conference at @url from @self.
*/
void
gcal_event_remove_conference (GcalEvent *self,
const gchar *url)
{
g_autoptr (GPtrArray) props = NULL;
ICalComponent *icalcomp;
g_return_if_fail (GCAL_IS_EVENT (self));
g_return_if_fail (url != NULL);
props = get_conference_properties (self);
icalcomp = e_cal_component_get_icalcomponent (self->component);
for (guint i = 0; i < props->len; i++)
{
ICalProperty *prop = g_ptr_array_index (props, i);
if (g_strcmp0 (i_cal_property_get_conference (prop), url) == 0)
i_cal_component_remove_property (icalcomp, prop);
}
}
/**
* gcal_event_copy_conferences:
* @self: a #GcalEvent
* @event: the #GcalEvent to copy from
*
* Replaces the CONFERENCE properties of @self with those of @event.
*/
void
gcal_event_copy_conferences (GcalEvent *self,
GcalEvent *event)
{
g_autoptr (GPtrArray) old_props = NULL;
g_autoptr (GPtrArray) new_props = NULL;
ICalComponent *icalcomp;
g_return_if_fail (GCAL_IS_EVENT (self));
g_return_if_fail (GCAL_IS_EVENT (event));
old_props = get_conference_properties (self);
new_props = get_conference_properties (event);
icalcomp = e_cal_component_get_icalcomponent (self->component);
for (guint i = 0; i < old_props->len; i++)
i_cal_component_remove_property (icalcomp, g_ptr_array_index (old_props, i));
for (guint i = 0; i < new_props->len; i++)
i_cal_component_take_property (icalcomp, i_cal_property_clone (g_ptr_array_index (new_props, i)));
}
/**
* gcal_event_conferences_equal:
* @event1: a #GcalEvent
* @event2: a #GcalEvent
*
* Checks if @event1 and @event2 have the same CONFERENCE properties.
*
* Returns: %TRUE if the events' conferences are identical
*/
gboolean
gcal_event_conferences_equal (GcalEvent *event1,
GcalEvent *event2)
{
g_autoptr (GPtrArray) props1 = NULL;
g_autoptr (GPtrArray) props2 = NULL;
g_assert (GCAL_IS_EVENT (event1) && GCAL_IS_EVENT (event2));
props1 = get_conference_properties (event1);
props2 = get_conference_properties (event2);
if (props1->len != props2->len)
return FALSE;
for (guint i = 0; i < props1->len; i++)
{
g_autofree gchar *string1 = i_cal_property_as_ical_string (g_ptr_array_index (props1, i));
g_autofree gchar *string2 = i_cal_property_as_ical_string (g_ptr_array_index (props2, i));
if (g_strcmp0 (string1, string2) != 0)
return FALSE;
}
return TRUE;
}
+15
View File
@@ -171,6 +171,21 @@ gboolean gcal_event_schedule_equal (GcalEvent
gboolean gcal_event_strings_equal (GcalEvent *event1,
GcalEvent *event2);
gchar* gcal_event_dup_conference_url (GcalEvent *self);
void gcal_event_add_conference (GcalEvent *self,
const gchar *url,
const gchar *label);
void gcal_event_remove_conference (GcalEvent *self,
const gchar *url);
void gcal_event_copy_conferences (GcalEvent *self,
GcalEvent *event);
gboolean gcal_event_conferences_equal (GcalEvent *event1,
GcalEvent *event2);
G_END_DECLS
#endif /* GCAL_EVENT_H */
+123 -35
View File
@@ -147,6 +147,64 @@ load_cores (const gchar *config_dir)
return g_steal_pointer (&cores);
}
/*
* Looks for the Core whose Nextcloud is at @host
*/
static CoreConf *
find_core_conf (const gchar *config_dir,
const gchar *host)
{
g_autoptr (GPtrArray) cores = NULL;
if (!host)
return NULL;
cores = load_cores (config_dir);
for (guint i = 0; i < cores->len; i++)
{
CoreConf *conf = g_ptr_array_index (cores, i);
g_autofree gchar *nextcloud_host = g_strconcat ("nextcloud.", conf->domain, NULL);
if (g_ascii_strcasecmp (host, nextcloud_host) == 0)
return g_ptr_array_steal_index (cores, i);
}
return NULL;
}
#ifdef ENABLE_FEDERATED_CORE
/*
* Looks for the Core whose Nextcloud @calendar is on
*/
static CoreConf *
find_calendar_core_conf (GcalCalendar *calendar,
ESourceWebdav **out_webdav)
{
g_autofree gchar *config_dir = NULL;
g_autoptr (GUri) uri = NULL;
ESourceWebdav *webdav;
ESource *source;
source = gcal_calendar_get_source (calendar);
if (!source || !e_source_has_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND))
return NULL;
webdav = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
uri = e_source_webdav_dup_uri (webdav);
if (!uri)
return NULL;
if (out_webdav)
*out_webdav = webdav;
/* CoreDesktop writes to ~/.config, even where XDG_CONFIG_HOME is elsewhere (e.g. Flatpak) */
config_dir = g_build_filename (g_get_home_dir (), ".config", "coredesktop", NULL);
return find_core_conf (config_dir, g_uri_get_host (uri));
}
#endif
/**
* gcal_federated_core_find_core:
* @config_dir: CoreDesktop's configuration directory
@@ -164,32 +222,75 @@ gcal_federated_core_find_core (const gchar *config_dir,
gchar **out_email,
gchar **out_name)
{
g_autoptr (GPtrArray) cores = NULL;
g_autoptr (CoreConf) conf = NULL;
g_return_val_if_fail (config_dir != NULL, FALSE);
if (!host)
conf = find_core_conf (config_dir, host);
if (!conf)
return FALSE;
cores = load_cores (config_dir);
if (out_email)
*out_email = g_strdup (conf->email);
if (out_name)
*out_name = g_strdup (conf->name);
for (guint i = 0; i < cores->len; i++)
{
CoreConf *conf = g_ptr_array_index (cores, i);
g_autofree gchar *nextcloud_host = g_strconcat ("nextcloud.", conf->domain, NULL);
return TRUE;
}
if (g_ascii_strcasecmp (host, nextcloud_host) != 0)
continue;
/**
* gcal_federated_core_find_jitsi_server:
* @config_dir: CoreDesktop's configuration directory
* @host: the host name of a CalDAV server
*
* Looks for the Jitsi server of the Core whose Nextcloud is at @host. Every
* Core runs Jitsi at jitsi.<domain>.
*
* Returns: (transfer full) (nullable): the address of the Jitsi server, or
* %NULL if @host isn't the Nextcloud of a Core set up on this computer
*/
gchar *
gcal_federated_core_find_jitsi_server (const gchar *config_dir,
const gchar *host)
{
g_autoptr (CoreConf) conf = NULL;
if (out_email)
*out_email = g_strdup (conf->email);
if (out_name)
*out_name = g_strdup (conf->name);
g_return_val_if_fail (config_dir != NULL, NULL);
return TRUE;
}
conf = find_core_conf (config_dir, host);
if (!conf)
return NULL;
return FALSE;
return g_strconcat ("https://jitsi.", conf->domain, NULL);
}
/**
* gcal_federated_core_get_jitsi_server:
* @calendar: a #GcalCalendar
*
* Checks whether @calendar is on the Nextcloud of a Federated Computer Core
* set up on this computer, whose events can have a video conference on the
* Core's Jitsi server.
*
* Returns: (transfer full) (nullable): the address of the Core's Jitsi
* server, or %NULL if @calendar isn't on a Core
*/
gchar *
gcal_federated_core_get_jitsi_server (GcalCalendar *calendar)
{
#ifdef ENABLE_FEDERATED_CORE
g_autoptr (CoreConf) conf = NULL;
g_return_val_if_fail (GCAL_IS_CALENDAR (calendar), NULL);
conf = find_calendar_core_conf (calendar, NULL);
if (!conf)
return NULL;
return g_strconcat ("https://jitsi.", conf->domain, NULL);
#else
return NULL;
#endif
}
/**
@@ -210,30 +311,17 @@ gcal_federated_core_get_organizer (GcalCalendar *calendar,
gchar **out_name)
{
#ifdef ENABLE_FEDERATED_CORE
g_autofree gchar *config_dir = NULL;
g_autofree gchar *server_email = NULL;
g_autofree gchar *core_email = NULL;
g_autofree gchar *core_name = NULL;
g_autoptr (GUri) uri = NULL;
ESourceWebdav *webdav;
ESource *source;
g_autoptr (CoreConf) conf = NULL;
ESourceWebdav *webdav = NULL;
g_return_val_if_fail (GCAL_IS_CALENDAR (calendar), FALSE);
if (gcal_calendar_is_read_only (calendar))
return FALSE;
source = gcal_calendar_get_source (calendar);
if (!source || !e_source_has_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND))
return FALSE;
webdav = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
uri = e_source_webdav_dup_uri (webdav);
/* CoreDesktop writes to ~/.config, even where XDG_CONFIG_HOME is elsewhere (e.g. Flatpak) */
config_dir = g_build_filename (g_get_home_dir (), ".config", "coredesktop", NULL);
if (!uri || !gcal_federated_core_find_core (config_dir, g_uri_get_host (uri), &core_email, &core_name))
conf = find_calendar_core_conf (calendar, &webdav);
if (!conf)
return FALSE;
/*
@@ -244,9 +332,9 @@ gcal_federated_core_get_organizer (GcalCalendar *calendar,
server_email = e_source_webdav_dup_email_address (webdav);
if (out_email)
*out_email = (server_email && *server_email) ? g_steal_pointer (&server_email) : g_steal_pointer (&core_email);
*out_email = (server_email && *server_email) ? g_steal_pointer (&server_email) : g_strdup (conf->email);
if (out_name)
*out_name = g_steal_pointer (&core_name);
*out_name = g_strdup (conf->name);
return TRUE;
#else
+5
View File
@@ -31,4 +31,9 @@ gboolean gcal_federated_core_find_core (const gchar
gchar **out_email,
gchar **out_name);
gchar* gcal_federated_core_get_jitsi_server (GcalCalendar *calendar);
gchar* gcal_federated_core_find_jitsi_server (const gchar *config_dir,
const gchar *host);
G_END_DECLS
+452
View File
@@ -0,0 +1,452 @@
/* gcal-jitsi.c
*
* Copyright (C) 2026 David Young <david@federated.computer>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define G_LOG_DOMAIN "GcalJitsi"
#include "config.h"
#include "gcal-jitsi.h"
#include <errno.h>
#include <glib/gi18n.h>
#include <string.h>
#include <sys/random.h>
/**
* SECTION:gcal-jitsi
* @short_description: Jitsi video conferences
* @title:GcalJitsi
*
* Every Federated Computer Core runs Jitsi, so an event on a Core calendar
* can have a video conference in a Jitsi room on the Core. Anyone who knows
* a room's name can join it, so the names are made unguessable.
*
* The room's link goes in the event's description, which every mail client
* shows in the invitation, and in its iCalendar CONFERENCE property
* (RFC 7986) for the calendar apps that read it.
*/
/*
* Each list has 64 words, so that a random byte picks one without bias.
* Together they make names like BraveOttersSing.
*/
static const gchar * const adjectives[] = {
"Amber", "Ancient", "Autumn", "Bold", "Brave", "Bright", "Calm", "Clever",
"Cosmic", "Crimson", "Curious", "Daring", "Dusty", "Eager", "Early", "Electric",
"Emerald", "Fancy", "Gentle", "Gilded", "Golden", "Grand", "Happy", "Hidden",
"Honest", "Humble", "Icy", "Jolly", "Keen", "Kind", "Lively", "Lucky",
"Lunar", "Mellow", "Merry", "Misty", "Modest", "Noble", "Nimble", "Olive",
"Patient", "Polar", "Proud", "Quiet", "Rapid", "Rosy", "Royal", "Rustic",
"Silver", "Sleepy", "Smooth", "Solar", "Sunny", "Swift", "Tidy", "Tiny",
"Velvet", "Vivid", "Warm", "Wild", "Wise", "Witty", "Young", "Zesty",
};
static const gchar * const nouns[] = {
"Apples", "Badgers", "Beacons", "Bears", "Bees", "Birches", "Bridges", "Brooks",
"Cabins", "Canyons", "Cedars", "Clouds", "Comets", "Coves", "Daisies", "Dolphins",
"Eagles", "Ferns", "Fjords", "Foxes", "Gardens", "Geysers", "Glaciers", "Harbors",
"Hawks", "Herons", "Hills", "Islands", "Kites", "Lagoons", "Lanterns", "Lemons",
"Lynxes", "Maples", "Meadows", "Moons", "Oaks", "Orchards", "Otters", "Owls",
"Pebbles", "Pines", "Planets", "Ponds", "Puffins", "Ravens", "Rivers", "Robins",
"Sails", "Seals", "Sparrows", "Stars", "Streams", "Swans", "Tigers", "Trails",
"Tulips", "Valleys", "Violins", "Waves", "Whales", "Willows", "Wolves", "Wrens",
};
static const gchar * const verbs[] = {
"Bloom", "Bounce", "Breathe", "Chatter", "Climb", "Dance", "Dream", "Drift",
"Explore", "Float", "Flourish", "Fly", "Gather", "Glide", "Glow", "Grow",
"Hop", "Hum", "Jump", "Laugh", "Leap", "Linger", "Listen", "March",
"Meander", "Mingle", "Nap", "Paddle", "Ponder", "Prance", "Race", "Ramble",
"Rest", "Ripple", "Rise", "Roam", "Roll", "Run", "Sail", "Shimmer",
"Shine", "Sing", "Skate", "Sketch", "Smile", "Soar", "Sparkle", "Spin",
"Splash", "Sprint", "Stroll", "Swim", "Swing", "Swirl", "Thrive", "Travel",
"Tumble", "Twinkle", "Waltz", "Wander", "Whistle", "Wink", "Yodel", "Zoom",
};
G_STATIC_ASSERT (G_N_ELEMENTS (adjectives) == 64);
G_STATIC_ASSERT (G_N_ELEMENTS (nouns) == 64);
G_STATIC_ASSERT (G_N_ELEMENTS (verbs) == 64);
/* 32 letters and digits, leaving out the easily confused l, o, 0 and 1 */
static const gchar suffix_chars[] = "abcdefghijkmnpqrstuvwxyz23456789";
G_STATIC_ASSERT (sizeof (suffix_chars) - 1 == 32);
#define SUFFIX_LENGTH 8
/* Hosts of Jitsi servers other than the Cores' jitsi.<domain> */
static const gchar * const jitsi_hosts[] = {
"meet.jit.si",
"8x8.vc",
};
static gboolean
fill_random (guint8 *buffer,
gsize length)
{
gsize filled = 0;
while (filled < length)
{
gssize n = getrandom (buffer + filled, length - filled, 0);
if (n < 0)
{
if (errno == EINTR)
continue;
g_warning ("Could not get random bytes: %s", g_strerror (errno));
return FALSE;
}
filled += n;
}
return TRUE;
}
static gboolean
is_url_end (gchar c)
{
return c == '\0' || g_ascii_isspace (c) || strchr ("<>\"'", c) != NULL;
}
/**
* gcal_jitsi_generate_room_name:
*
* Makes up a name for a new Jitsi room that's easy to read out, like
* BraveOttersSing-k3f9x2m7. Three words and a suffix give 58 random bits,
* which nobody will guess.
*
* Returns: (transfer full) (nullable): a room name, or %NULL if no random
* numbers were available
*/
gchar *
gcal_jitsi_generate_room_name (void)
{
guint8 random[3 + SUFFIX_LENGTH];
GString *name;
if (!fill_random (random, sizeof (random)))
return NULL;
name = g_string_new (NULL);
g_string_append (name, adjectives[random[0] & 63]);
g_string_append (name, nouns[random[1] & 63]);
g_string_append (name, verbs[random[2] & 63]);
g_string_append_c (name, '-');
for (gsize i = 0; i < SUFFIX_LENGTH; i++)
g_string_append_c (name, suffix_chars[random[3 + i] & 31]);
memset (random, 0, sizeof (random));
return g_string_free (name, FALSE);
}
/**
* gcal_jitsi_build_room_url:
* @server: the Jitsi server, e.g. https://jitsi.example.com
* @room_name: the name of a room
*
* Returns: (transfer full): the address of the room @room_name on @server
*/
gchar *
gcal_jitsi_build_room_url (const gchar *server,
const gchar *room_name)
{
g_autofree gchar *escaped = NULL;
gsize len;
g_return_val_if_fail (server != NULL, NULL);
g_return_val_if_fail (room_name != NULL && *room_name, NULL);
escaped = g_uri_escape_string (room_name, NULL, FALSE);
len = strlen (server);
if (len > 0 && server[len - 1] == '/')
return g_strconcat (server, escaped, NULL);
return g_strconcat (server, "/", escaped, NULL);
}
/**
* gcal_jitsi_is_room_url:
* @url: (nullable): a URL
*
* Checks whether @url is a room on a Jitsi server: a Core's
* jitsi.<domain>, or one of the public Jitsi servers.
*
* Returns: %TRUE if @url is a Jitsi room
*/
gboolean
gcal_jitsi_is_room_url (const gchar *url)
{
g_autoptr (GUri) uri = NULL;
const gchar *scheme;
const gchar *host;
const gchar *path;
if (!url)
return FALSE;
uri = g_uri_parse (url, G_URI_FLAGS_NONE, NULL);
if (!uri)
return FALSE;
scheme = g_uri_get_scheme (uri);
host = g_uri_get_host (uri);
path = g_uri_get_path (uri);
if (g_ascii_strcasecmp (scheme, "https") != 0 && g_ascii_strcasecmp (scheme, "http") != 0)
return FALSE;
/* The server's front page isn't a room */
if (!host || !path || !path[0] || g_str_equal (path, "/"))
return FALSE;
if (g_ascii_strncasecmp (host, "jitsi.", strlen ("jitsi.")) == 0 && strchr (host + strlen ("jitsi."), '.'))
return TRUE;
for (gsize i = 0; i < G_N_ELEMENTS (jitsi_hosts); i++)
{
if (g_ascii_strcasecmp (host, jitsi_hosts[i]) == 0)
return TRUE;
}
return FALSE;
}
/**
* gcal_jitsi_find_room_url:
* @text: (nullable): some text, like the description of an event
*
* Looks for the address of a Jitsi room in @text.
*
* Returns: (transfer full) (nullable): the first Jitsi room in @text, or %NULL
*/
gchar *
gcal_jitsi_find_room_url (const gchar *text)
{
const gchar *start;
if (!text)
return NULL;
for (start = text; (start = strstr (start, "http")) != NULL; start++)
{
g_autofree gchar *url = NULL;
const gchar *end;
if (g_ascii_strncasecmp (start, "https://", strlen ("https://")) != 0 &&
g_ascii_strncasecmp (start, "http://", strlen ("http://")) != 0)
continue;
for (end = start; !is_url_end (*end); end++)
;
/* Punctuation after a link ends the sentence, not the link */
while (end > start && strchr (".,;:!?)]", end[-1]))
end--;
url = g_strndup (start, end - start);
if (gcal_jitsi_is_room_url (url))
return g_steal_pointer (&url);
}
return NULL;
}
/**
* gcal_jitsi_find_event_conference:
* @event: a #GcalEvent
*
* Finds the video conference of @event, so that it isn't offered a second
* one. That's the event's CONFERENCE property, if it has one, or else a
* Jitsi room in its description or location.
*
* Returns: (transfer full) (nullable): the conference's URL, or %NULL
*/
gchar *
gcal_jitsi_find_event_conference (GcalEvent *event)
{
gchar *url;
g_return_val_if_fail (GCAL_IS_EVENT (event), NULL);
url = gcal_event_dup_conference_url (event);
if (!url)
url = gcal_jitsi_find_room_url (gcal_event_get_description (event));
if (!url)
url = gcal_jitsi_find_room_url (gcal_event_get_location (event));
return url;
}
/**
* gcal_jitsi_add_to_description:
* @description: (nullable): the description of an event
* @url: the URL of a video conference
*
* Adds a line inviting people to join the conference at @url to the end of
* @description, unless @url is in it already.
*
* Returns: (transfer full): the new description
*/
gchar *
gcal_jitsi_add_to_description (const gchar *description,
const gchar *url)
{
g_autofree gchar *text = NULL;
g_autofree gchar *line = NULL;
g_return_val_if_fail (url != NULL, NULL);
if (description && strstr (description, url))
return g_strdup (description);
/* Translators: %s is the address of a video conference room */
line = g_strdup_printf (_("Join the video conference: %s"), url);
text = g_strchomp (g_strdup (description ? description : ""));
if (!*text)
return g_steal_pointer (&line);
return g_strconcat (text, "\n\n", line, NULL);
}
/**
* gcal_jitsi_remove_from_description:
* @description: (nullable): the description of an event
* @url: the URL of a video conference
*
* Takes the lines that mention @url out of @description.
*
* Returns: (transfer full): the new description
*/
gchar *
gcal_jitsi_remove_from_description (const gchar *description,
const gchar *url)
{
g_auto (GStrv) lines = NULL;
GString *text;
g_return_val_if_fail (url != NULL, NULL);
if (!description)
return g_strdup ("");
if (!strstr (description, url))
return g_strdup (description);
lines = g_strsplit (description, "\n", -1);
text = g_string_new (NULL);
for (gsize i = 0; lines[i]; i++)
{
if (strstr (lines[i], url))
{
/* Don't leave two blank lines where the link was */
if (text->len >= 2 && g_str_has_suffix (text->str, "\n\n") && (!lines[i + 1] || !*lines[i + 1]))
g_string_truncate (text, text->len - 1);
continue;
}
g_string_append (text, lines[i]);
g_string_append_c (text, '\n');
}
return g_strchomp (g_string_free (text, FALSE));
}
/**
* gcal_jitsi_add_conference:
* @event: a #GcalEvent
* @url: the URL of a Jitsi room
*
* Adds the video conference at @url to @event: a CONFERENCE property, and
* a link in the description for the people invited.
*/
void
gcal_jitsi_add_conference (GcalEvent *event,
const gchar *url)
{
g_autofree gchar *description = NULL;
g_return_if_fail (GCAL_IS_EVENT (event));
g_return_if_fail (url != NULL);
gcal_event_add_conference (event, url, _("Jitsi Video Conference"));
description = gcal_jitsi_add_to_description (gcal_event_get_description (event), url);
gcal_event_set_description (event, description);
}
/**
* gcal_jitsi_remove_conference:
* @event: a #GcalEvent
* @url: the URL of a video conference
*
* Takes the video conference at @url out of @event's CONFERENCE properties
* and description.
*/
void
gcal_jitsi_remove_conference (GcalEvent *event,
const gchar *url)
{
g_autofree gchar *description = NULL;
g_return_if_fail (GCAL_IS_EVENT (event));
g_return_if_fail (url != NULL);
gcal_event_remove_conference (event, url);
description = gcal_jitsi_remove_from_description (gcal_event_get_description (event), url);
gcal_event_set_description (event, description);
}
/**
* gcal_jitsi_ensure_description:
* @event: a #GcalEvent
*
* Puts the link to @event's Jitsi conference back in its description, if it
* was taken out, so that the people invited get it. Mail clients show the
* description, but few show the CONFERENCE property.
*/
void
gcal_jitsi_ensure_description (GcalEvent *event)
{
g_autofree gchar *description = NULL;
g_autofree gchar *url = NULL;
g_return_if_fail (GCAL_IS_EVENT (event));
url = gcal_event_dup_conference_url (event);
/* Other apps' conferences are their business */
if (!gcal_jitsi_is_room_url (url))
return;
description = gcal_jitsi_add_to_description (gcal_event_get_description (event), url);
gcal_event_set_description (event, description);
}
+50
View File
@@ -0,0 +1,50 @@
/* gcal-jitsi.h
*
* Copyright (C) 2026 David Young <david@federated.computer>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "gcal-event.h"
G_BEGIN_DECLS
gchar* gcal_jitsi_generate_room_name (void);
gchar* gcal_jitsi_build_room_url (const gchar *server,
const gchar *room_name);
gboolean gcal_jitsi_is_room_url (const gchar *url);
gchar* gcal_jitsi_find_room_url (const gchar *text);
gchar* gcal_jitsi_find_event_conference (GcalEvent *event);
gchar* gcal_jitsi_add_to_description (const gchar *description,
const gchar *url);
gchar* gcal_jitsi_remove_from_description (const gchar *description,
const gchar *url);
void gcal_jitsi_add_conference (GcalEvent *event,
const gchar *url);
void gcal_jitsi_remove_conference (GcalEvent *event,
const gchar *url);
void gcal_jitsi_ensure_description (GcalEvent *event);
G_END_DECLS
+1
View File
@@ -2,4 +2,5 @@ calendar_incs += include_directories('.')
sources += files(
'gcal-federated-core.c',
'gcal-jitsi.c',
)
@@ -29,6 +29,7 @@
#include "gcal-event-editor-section.h"
#include "gcal-event.h"
#include "gcal-federated-core.h"
#include "gcal-jitsi.h"
#include "gcal-notes-section.h"
#include "gcal-reminders-section.h"
#include "gcal-schedule-section.h"
@@ -171,6 +172,29 @@ update_invite_state (GcalEventEditorDialog *self)
gtk_widget_set_visible (GTK_WIDGET (self->attendees_section), organizer != NULL || can_invite);
}
/*
* Events on the calendars of a Federated Computer Core can have a video
* conference on the Core's Jitsi server.
*/
static void
update_conference_state (GcalEventEditorDialog *self)
{
g_autofree gchar *server = NULL;
GcalCalendar *calendar;
if (!self->edited_event)
return;
calendar = gcal_calendar_combo_row_get_calendar (self->calendar_combo_row);
if (!calendar)
calendar = gcal_event_get_calendar (self->edited_event);
if (self->writable && calendar)
server = gcal_federated_core_get_jitsi_server (calendar);
gcal_summary_section_set_conference_server (GCAL_SUMMARY_SECTION (self->summary_section), server);
}
static void
set_event (GcalEventEditorDialog *self,
GcalEvent *event,
@@ -209,6 +233,7 @@ set_event (GcalEventEditorDialog *self,
set_writable (self, !gcal_calendar_is_read_only (calendar));
update_invite_state (self);
update_conference_state (self);
gtk_widget_set_visible (self->cancel_button, self->writable);
@@ -280,6 +305,10 @@ apply_event_properties_to_template_event (GcalEvent *template_event,
if (!gcal_event_attendees_equal (template_event, event))
gcal_event_copy_attendees (template_event, event);
/* A conference added to one occurrence is for the whole series */
if (!gcal_event_conferences_equal (template_event, event))
gcal_event_copy_conferences (template_event, event);
}
static void
@@ -320,7 +349,7 @@ save_event (GcalEventEditorDialog *self,
GcalContext *context;
GcalManager *manager;
gboolean calendar_equal, alarms_equal, schedule_equal, strings_equal, attendees_equal, event_equal;
gboolean calendar_equal, alarms_equal, schedule_equal, strings_equal, attendees_equal, conferences_equal, event_equal;
GCAL_ENTRY;
@@ -337,12 +366,16 @@ save_event (GcalEventEditorDialog *self,
gcal_event_set_organizer (self->edited_event, NULL, NULL);
}
/* The people invited get the conference's link in the description */
gcal_jitsi_ensure_description (self->edited_event);
calendar_equal = selected_calendar && calendar == selected_calendar;
alarms_equal = gcal_event_alarms_equal (self->event, self->edited_event);
schedule_equal = gcal_event_schedule_equal (self->event, self->edited_event);
strings_equal = gcal_event_strings_equal (self->event, self->edited_event);
attendees_equal = gcal_event_attendees_equal (self->event, self->edited_event);
event_equal = calendar_equal && alarms_equal && schedule_equal && strings_equal && attendees_equal;
conferences_equal = gcal_event_conferences_equal (self->event, self->edited_event);
event_equal = calendar_equal && alarms_equal && schedule_equal && strings_equal && attendees_equal && conferences_equal;
if (self->event_is_new)
{
@@ -428,6 +461,7 @@ static void
on_calendar_selected_cb (GcalEventEditorDialog *self)
{
update_invite_state (self);
update_conference_state (self);
}
static void
+71 -10
View File
@@ -29,14 +29,64 @@ struct _GcalNotesSection
GtkTextView *notes_text;
GtkLabel *placeholder;
GcalEvent *event;
gulong description_changed_id;
};
G_DEFINE_FINAL_TYPE (GcalNotesSection, gcal_notes_section, GCAL_TYPE_EVENT_EDITOR_SECTION)
/*
* Auxiliary methods
*/
static void on_notes_text_changed_cb (GcalNotesSection *self);
static void
set_text (GcalNotesSection *self,
const gchar *text)
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer (self->notes_text);
g_signal_handlers_block_by_func (buffer, on_notes_text_changed_cb, self);
gtk_text_buffer_set_text (buffer, text, -1);
g_signal_handlers_unblock_by_func (buffer, on_notes_text_changed_cb, self);
}
static void
disconnect_event (GcalNotesSection *self)
{
if (self->event)
g_clear_signal_handler (&self->description_changed_id, self->event);
self->description_changed_id = 0;
g_clear_weak_pointer (&self->event);
}
/*
* Callbacks
*/
/*
* The description changes as people type here, but also elsewhere, e.g.
* when a video conference's link is added to it.
*/
static void
on_event_description_changed_cb (GcalNotesSection *self)
{
g_autofree char *text = NULL;
GtkTextIter start, end;
GtkTextBuffer *buffer;
buffer = gtk_text_view_get_buffer (self->notes_text);
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE);
if (g_strcmp0 (text, gcal_event_get_description (self->event)) != 0)
set_text (self, gcal_event_get_description (self->event));
}
static void
on_notes_text_changed_cb (GcalNotesSection *self)
{
@@ -102,20 +152,20 @@ gcal_notes_section_event_set_cb (GcalEventEditorSection *section,
GcalEvent *event)
{
GcalNotesSection *self = GCAL_NOTES_SECTION (section);
GtkTextIter start, end;
GtkTextBuffer *buffer;
buffer = gtk_text_view_get_buffer (self->notes_text);
gtk_text_buffer_get_bounds (buffer, &start, &end);
disconnect_event (self);
g_signal_handlers_block_by_func (buffer, on_notes_text_changed_cb, self);
set_text (self, event ? gcal_event_get_description (event) : "");
if (event)
gtk_text_buffer_set_text (buffer, gcal_event_get_description (event), -1);
else
gtk_text_buffer_delete (buffer, &start, &end);
g_signal_handlers_unblock_by_func (buffer, on_notes_text_changed_cb, self);
{
g_set_weak_pointer (&self->event, event);
self->description_changed_id = g_signal_connect_object (event,
"notify::description",
G_CALLBACK (on_event_description_changed_cb),
self,
G_CONNECT_SWAPPED);
}
}
@@ -123,12 +173,23 @@ gcal_notes_section_event_set_cb (GcalEventEditorSection *section,
* GObject overrides
*/
static void
gcal_notes_section_dispose (GObject *object)
{
disconnect_event (GCAL_NOTES_SECTION (object));
G_OBJECT_CLASS (gcal_notes_section_parent_class)->dispose (object);
}
static void
gcal_notes_section_class_init (GcalNotesSectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GcalEventEditorSectionClass *section_class = GCAL_EVENT_EDITOR_SECTION_CLASS (klass);
object_class->dispose = gcal_notes_section_dispose;
section_class->event_set_cb = gcal_notes_section_event_set_cb;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/event-editor/gcal-notes-section.ui");
@@ -13,4 +13,59 @@ template $GcalSummarySection: $GcalEventEditorSection {
notify::text => $on_location_entry_changed_cb(template);
editable: bind template.dialog as <$GcalEventEditorDialog>.writable;
}
Adw.ButtonRow add_conference_row {
visible: false;
title: _("Add _Video Conference");
use-underline: true;
start-icon-name: "camera-web-symbolic";
tooltip-text: _("Make a room on your Core’s Jitsi server, and send its link to the people invited");
activated => $on_add_conference_row_activated_cb(template);
}
Adw.ActionRow conference_row {
visible: false;
title: _("Video Conference");
use-markup: false;
subtitle-selectable: true;
[prefix]
Image {
icon-name: "camera-web-symbolic";
accessible-role: presentation;
}
[suffix]
Button copy_conference_button {
valign: center;
icon-name: "edit-copy-symbolic";
tooltip-text: _("Copy Link");
clicked => $on_copy_conference_button_clicked_cb(template);
accessibility {
label: _("Copy Link");
}
styles [
"flat",
]
}
[suffix]
Button remove_conference_button {
valign: center;
icon-name: "edit-delete-symbolic";
tooltip-text: _("Remove Video Conference");
visible: bind template.dialog as <$GcalEventEditorDialog>.writable;
clicked => $on_remove_conference_button_clicked_cb(template);
accessibility {
label: _("Remove Video Conference");
}
styles [
"flat",
]
}
}
}
+201 -1
View File
@@ -21,6 +21,7 @@
#define G_LOG_DOMAIN "GcalSummarySection"
#include "gcal-debug.h"
#include "gcal-jitsi.h"
#include "gcal-summary-section.h"
#include "gcal-utils.h"
@@ -32,15 +33,155 @@ struct _GcalSummarySection
AdwEntryRow *summary_entry;
AdwEntryRow *location_entry;
AdwButtonRow *add_conference_row;
AdwActionRow *conference_row;
GtkButton *copy_conference_button;
GtkButton *remove_conference_button;
/* The Jitsi server of the event's Core, if a conference can be added */
gchar *conference_server;
/* The event's conference */
gchar *conference_url;
guint copied_timeout_id;
};
G_DEFINE_FINAL_TYPE (GcalSummarySection, gcal_summary_section, GCAL_TYPE_EVENT_EDITOR_SECTION)
/*
* Auxiliary methods
*/
static void
update_conference_rows (GcalSummarySection *self)
{
gboolean has_conference = self->conference_url != NULL;
adw_action_row_set_subtitle (self->conference_row, has_conference ? self->conference_url : "");
gtk_widget_set_visible (GTK_WIDGET (self->conference_row), has_conference);
gtk_widget_set_visible (GTK_WIDGET (self->add_conference_row), !has_conference && self->conference_server);
}
static void
announce (GcalSummarySection *self,
const gchar *message)
{
gtk_accessible_announce (GTK_ACCESSIBLE (self), message, GTK_ACCESSIBLE_ANNOUNCEMENT_PRIORITY_MEDIUM);
}
static void
reset_copy_button (GcalSummarySection *self)
{
g_clear_handle_id (&self->copied_timeout_id, g_source_remove);
gtk_button_set_icon_name (self->copy_conference_button, "edit-copy-symbolic");
gtk_widget_set_tooltip_text (GTK_WIDGET (self->copy_conference_button), _("Copy Link"));
}
/*
* Callbacks
*/
static gboolean
on_copied_timeout_cb (gpointer user_data)
{
GcalSummarySection *self = GCAL_SUMMARY_SECTION (user_data);
self->copied_timeout_id = 0;
reset_copy_button (self);
return G_SOURCE_REMOVE;
}
static void
on_add_conference_row_activated_cb (GcalSummarySection *self)
{
g_autofree gchar *room_name = NULL;
GcalEvent *event;
event = gcal_event_editor_section_get_event (GCAL_EVENT_EDITOR_SECTION (self));
if (!event || !self->conference_server || self->conference_url)
return;
room_name = gcal_jitsi_generate_room_name ();
if (!room_name)
return;
self->conference_url = gcal_jitsi_build_room_url (self->conference_server, room_name);
gcal_jitsi_add_conference (event, self->conference_url);
update_conference_rows (self);
/* The button that had the focus is gone */
gtk_widget_grab_focus (GTK_WIDGET (self->copy_conference_button));
announce (self, _("Video conference added"));
}
static void
on_copy_conference_button_clicked_cb (GcalSummarySection *self)
{
if (!self->conference_url)
return;
gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (self)), self->conference_url);
gtk_button_set_icon_name (self->copy_conference_button, "object-select-symbolic");
gtk_widget_set_tooltip_text (GTK_WIDGET (self->copy_conference_button), _("Copied"));
g_clear_handle_id (&self->copied_timeout_id, g_source_remove);
self->copied_timeout_id = g_timeout_add_seconds (2, on_copied_timeout_cb, self);
announce (self, _("Link copied"));
}
static void
on_remove_conference_button_clicked_cb (GcalSummarySection *self)
{
g_autofree gchar *other_url = NULL;
g_autofree gchar *location = NULL;
GcalEvent *event;
event = gcal_event_editor_section_get_event (GCAL_EVENT_EDITOR_SECTION (self));
if (!event || !self->conference_url)
return;
gcal_jitsi_remove_conference (event, self->conference_url);
/* The conference could have been in the location */
location = g_strdup (gcal_event_get_location (event));
if (location && g_str_equal (g_strstrip (location), self->conference_url))
gtk_editable_set_text (GTK_EDITABLE (self->location_entry), "");
/* There could be another one, e.g. a different room in the location */
other_url = gcal_jitsi_find_event_conference (event);
/* A link amid other words in the location is the person's to edit */
if (g_strcmp0 (other_url, self->conference_url) == 0)
g_clear_pointer (&other_url, g_free);
g_free (self->conference_url);
self->conference_url = g_steal_pointer (&other_url);
reset_copy_button (self);
update_conference_rows (self);
if (gtk_widget_get_visible (GTK_WIDGET (self->add_conference_row)))
gtk_widget_grab_focus (GTK_WIDGET (self->add_conference_row));
else if (self->conference_url)
gtk_widget_grab_focus (GTK_WIDGET (self->copy_conference_button));
else
gtk_widget_grab_focus (GTK_WIDGET (self->location_entry));
announce (self, _("Video conference removed"));
}
static void
on_summary_entry_text_changed_cb (GcalSummarySection *self)
{
@@ -107,6 +248,13 @@ gcal_summary_section_event_set_cb (GcalEventEditorSection *section,
g_signal_handlers_unblock_by_func (self->location_entry, on_location_entry_changed_cb, self);
gtk_widget_remove_css_class (GTK_WIDGET (self->summary_entry), "error");
g_clear_pointer (&self->conference_url, g_free);
if (event)
self->conference_url = gcal_jitsi_find_event_conference (event);
reset_copy_button (self);
update_conference_rows (self);
}
@@ -137,12 +285,37 @@ gcal_summary_section_unmap (GtkWidget *widget)
* GObject overrides
*/
static void
gcal_summary_section_dispose (GObject *object)
{
GcalSummarySection *self = GCAL_SUMMARY_SECTION (object);
g_clear_handle_id (&self->copied_timeout_id, g_source_remove);
G_OBJECT_CLASS (gcal_summary_section_parent_class)->dispose (object);
}
static void
gcal_summary_section_finalize (GObject *object)
{
GcalSummarySection *self = GCAL_SUMMARY_SECTION (object);
g_clear_pointer (&self->conference_server, g_free);
g_clear_pointer (&self->conference_url, g_free);
G_OBJECT_CLASS (gcal_summary_section_parent_class)->finalize (object);
}
static void
gcal_summary_section_class_init (GcalSummarySectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GcalEventEditorSectionClass *section_class = GCAL_EVENT_EDITOR_SECTION_CLASS (klass);
object_class->dispose = gcal_summary_section_dispose;
object_class->finalize = gcal_summary_section_finalize;
widget_class->grab_focus = gcal_summary_section_grab_focus;
widget_class->unmap = gcal_summary_section_unmap;
@@ -150,11 +323,18 @@ gcal_summary_section_class_init (GcalSummarySectionClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/event-editor/gcal-summary-section.ui");
gtk_widget_class_bind_template_child (widget_class, GcalSummarySection, add_conference_row);
gtk_widget_class_bind_template_child (widget_class, GcalSummarySection, conference_row);
gtk_widget_class_bind_template_child (widget_class, GcalSummarySection, copy_conference_button);
gtk_widget_class_bind_template_child (widget_class, GcalSummarySection, location_entry);
gtk_widget_class_bind_template_child (widget_class, GcalSummarySection, remove_conference_button);
gtk_widget_class_bind_template_child (widget_class, GcalSummarySection, summary_entry);
gtk_widget_class_bind_template_callback (widget_class, on_summary_entry_text_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_add_conference_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, on_copy_conference_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_location_entry_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_remove_conference_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_summary_entry_text_changed_cb);
}
static void
@@ -162,3 +342,23 @@ gcal_summary_section_init (GcalSummarySection *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
/**
* gcal_summary_section_set_conference_server:
* @self: a #GcalSummarySection
* @server: (nullable): the address of a Jitsi server
*
* Offers to add a video conference on @server to the event, unless it has
* one already. %NULL hides the offer, e.g. for calendars that aren't on a
* Federated Computer Core.
*/
void
gcal_summary_section_set_conference_server (GcalSummarySection *self,
const gchar *server)
{
g_return_if_fail (GCAL_IS_SUMMARY_SECTION (self));
g_set_str (&self->conference_server, server);
update_conference_rows (self);
}
@@ -29,4 +29,7 @@ G_BEGIN_DECLS
#define GCAL_TYPE_SUMMARY_SECTION (gcal_summary_section_get_type())
G_DECLARE_FINAL_TYPE (GcalSummarySection, gcal_summary_section, GCAL, SUMMARY_SECTION, GcalEventEditorSection)
void gcal_summary_section_set_conference_server (GcalSummarySection *self,
const gchar *server);
G_END_DECLS
+35 -2
View File
@@ -442,8 +442,25 @@ static void
add_meeting (GcalEventPopover *self,
const gchar *url)
{
GtkWidget *child;
GtkWidget *row;
/* The same conference can be in the CONFERENCE property, description and location */
for (child = gtk_widget_get_first_child (GTK_WIDGET (self->meetings_listbox));
child;
child = gtk_widget_get_next_sibling (child))
{
g_autofree gchar *row_url = NULL;
if (!GCAL_IS_MEETING_ROW (child))
continue;
g_object_get (child, "url", &row_url, NULL);
if (g_strcmp0 (row_url, url) == 0)
return;
}
row = gcal_meeting_row_new (url);
g_signal_connect (row, "join-meeting", G_CALLBACK (on_join_meeting_cb), self);
gtk_list_box_append (self->meetings_listbox, row);
@@ -478,12 +495,27 @@ set_up_location_label (GcalEventPopover *self)
location = g_string_free (string, FALSE);
}
/*
* A link in the location is shown as a meeting instead. A place stays,
* even when the meeting is in the description.
*/
gtk_widget_set_visible (self->location_box,
location && g_utf8_strlen (location, -1) > 0 &&
!gtk_widget_get_visible (GTK_WIDGET (self->meetings_box)));
!guri && location && g_utf8_strlen (location, -1) > 0);
gtk_label_set_markup (self->location_label, location);
}
static void
set_up_conference (GcalEventPopover *self)
{
g_autofree gchar *url = NULL;
url = gcal_event_dup_conference_url (self->event);
/* Only links can be joined, not e.g. tel: dial-in numbers */
if (url && (g_str_has_prefix (url, "https://") || g_str_has_prefix (url, "http://")))
add_meeting (self, url);
}
static void
set_up_description_label (GcalEventPopover *self)
{
@@ -514,6 +546,7 @@ set_event_internal (GcalEventPopover *self,
gtk_label_set_label (self->summary_label, gcal_event_get_summary (event));
set_up_conference (self);
set_up_description_label (self);
set_up_location_label (self);
update_placeholder_label (self);
+5 -2
View File
@@ -26,6 +26,7 @@
#include "gcal-application.h"
#include "gcal-context.h"
#include "gcal-enums.h"
#include "gcal-jitsi.h"
#include "gcal-utils.h"
#include "gcal-event-widget.h"
#include "gcal-view.h"
@@ -805,7 +806,8 @@ gcal_util_extract_teams_section (const gchar *description,
* @out_description: (nullable)(transfer full): return location for a parsed description
* @out_meeting_url: (nullable)(transfer full): return location for the parsed meeting url
*
* Parses @description for meeting URLs.
* Parses @description for meeting URLs: the sections that Google Meet and
* Microsoft Teams add to descriptions, and links to Jitsi rooms.
*/
void
gcal_util_extract_meeting_url (const char *description,
@@ -818,8 +820,9 @@ gcal_util_extract_meeting_url (const char *description,
if (out_description)
*out_description = g_strdup (description);
/* Jitsi rooms are a link in the description, not a section of their own */
if (out_meeting_url)
*out_meeting_url = NULL;
*out_meeting_url = gcal_jitsi_find_room_url (description);
}
}