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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user