[Commits] [SCM] claws branch, master, updated. 4.3.0-36-g93e856cf6

colin at claws-mail.org colin at claws-mail.org
Wed Aug 28 15:23:02 UTC 2024


The branch, master has been updated
       via  93e856cf6e569681ad4c65808d3a136589330cab (commit)
      from  dd0921d2805f60cbb477c50e419e170253dea242 (commit)

Summary of changes:
 src/plugins/vcalendar/vcal_folder.c      | 21 ++++++++++++++++++--
 src/plugins/vcalendar/vcal_manager.c     | 34 +++++++++++++++++++++++++++-----
 src/plugins/vcalendar/vcal_manager.h     |  6 +++++-
 src/plugins/vcalendar/vcal_meeting_gtk.c | 19 ++++++++++++++----
 src/plugins/vcalendar/vcalendar.c        |  6 +++++-
 5 files changed, 73 insertions(+), 13 deletions(-)


- Log -----------------------------------------------------------------
commit 93e856cf6e569681ad4c65808d3a136589330cab
Author: Colin Leroy-Mira <colin at colino.net>
Date:   Wed Aug 28 17:22:49 2024 +0200

    Handle CREATED/LAST_MODIFIED correctly

diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c
index 1581691a8..ae1d43817 100644
--- a/src/plugins/vcalendar/vcal_folder.c
+++ b/src/plugins/vcalendar/vcal_folder.c
@@ -805,7 +805,8 @@ GSList *vcal_get_events_list(FolderItem *item)
 								event->location, event->summary, event->description, 
 								new_start, new_end, NULL, 
 								event->tzid, event->url, event->method, 
-								event->sequence, event->type);
+								event->sequence, event->created, event->last_modified,
+								event->type);
 					g_free(uid);
 					vcal_manager_copy_attendees(event, nevent);
 					nevent->rec_occurrence = TRUE;
@@ -2294,6 +2295,8 @@ VCalEvent *vcal_get_event_from_ical(const gchar *ical, const gchar *charset)
 	gchar *tzid = NULL;
 	gchar *recur = NULL;
 	int sequence = 0;
+	gchar *created = NULL;
+	gchar *last_modified = NULL;
 	enum icalproperty_method method = ICAL_METHOD_REQUEST;
 	enum icalcomponent_kind type = ICAL_VEVENT_COMPONENT;
 	GSList *attendees = NULL;
@@ -2358,6 +2361,18 @@ VCalEvent *vcal_get_event_from_ical(const gchar *ical, const gchar *charset)
 		sequence = icalproperty_get_sequence(prop);
 		icalproperty_free(prop);
 	}
+	GET_PROP(comp, prop, ICAL_CREATED_PROPERTY);
+	if (prop) {
+		created = g_strdup(icaltime_as_ical_string(icalproperty_get_created(prop)));
+		TO_UTF8(created);
+		icalproperty_free(prop);
+	}
+	GET_PROP(comp, prop, ICAL_LASTMODIFIED_PROPERTY);
+	if (prop) {
+		last_modified = g_strdup(icaltime_as_ical_string(icalproperty_get_lastmodified(prop)));
+		TO_UTF8(last_modified);
+		icalproperty_free(prop);
+	}
 	GET_PROP(comp, prop, ICAL_METHOD_PROPERTY);
 	if (prop) {
 		method = icalproperty_get_method(prop);
@@ -2436,13 +2451,15 @@ VCalEvent *vcal_get_event_from_ical(const gchar *ical, const gchar *charset)
 					 location, summary, description,
 					 dtstart, dtend, recur,
 					 tzid, url,
-					 method, sequence, type);
+					 method, sequence, created, last_modified, type);
 	event->answers = attendees;
 	g_free(uid);
 	g_free(location);
 	g_free(summary);
 	g_free(dtstart);
 	g_free(dtend);
+	g_free(created);
+	g_free(last_modified);
 	g_free(org_email);
 	g_free(org_name);
 	g_free(description);
diff --git a/src/plugins/vcalendar/vcal_manager.c b/src/plugins/vcalendar/vcal_manager.c
index b7f6c6d25..4e008a332 100644
--- a/src/plugins/vcalendar/vcal_manager.c
+++ b/src/plugins/vcalendar/vcal_manager.c
@@ -414,6 +414,7 @@ gchar *vcal_manager_event_dump(VCalEvent *event, gboolean is_reply, gboolean is_
 		icalproperty_new_class(ICAL_CLASS_PUBLIC));
 	icalcomponent_add_property(ievent,
 		icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
+
 	if (event->location && *event->location)
 		icalcomponent_add_property(ievent,
 			icalproperty_new_location(event->location));
@@ -422,10 +423,20 @@ gchar *vcal_manager_event_dump(VCalEvent *event, gboolean is_reply, gboolean is_
 			icalproperty_new_location(""));
 	icalcomponent_add_property(ievent,
 		icalproperty_new_status(ICAL_STATUS_CONFIRMED));
-	icalcomponent_add_property(ievent,
-		icalproperty_vanew_created(icaltime_from_timet_with_zone(time(NULL), TRUE, NULL), (void*)0));
-	icalcomponent_add_property(ievent,
-		icalproperty_vanew_lastmodified(icaltime_from_timet_with_zone(time(NULL), TRUE, NULL), (void*)0));
+	if (event->created != NULL && event->created[0] != '\0') {
+		icalcomponent_add_property(ievent,
+			icalproperty_vanew_created(icaltime_from_string(event->created), (void*)0));
+	} else {
+		icalcomponent_add_property(ievent,
+			icalproperty_vanew_created(icaltime_from_timet_with_zone(time(NULL), FALSE, NULL), (void*)0));
+	}
+	if (event->last_modified != NULL && event->last_modified[0] != '\0' && !modif) {
+		icalcomponent_add_property(ievent,
+			icalproperty_vanew_lastmodified(icaltime_from_string(event->last_modified), (void*)0));
+	} else {
+		icalcomponent_add_property(ievent,
+			icalproperty_vanew_lastmodified(icaltime_from_timet_with_zone(time(NULL), FALSE, NULL), (void*)0));
+	}
 	icalcomponent_add_property(ievent,		
                 orgprop);
 
@@ -794,6 +805,8 @@ VCalEvent * vcal_manager_new_event	(const gchar 	*uid,
 					 const gchar	*url,
 					 icalproperty_method method,
 					 gint 		 sequence,
+					 const gchar    *created,
+					 const gchar    *last_modified,
 					 icalcomponent_kind type)
 {
 	VCalEvent *event = g_new0(VCalEvent, 1);
@@ -825,6 +838,8 @@ VCalEvent * vcal_manager_new_event	(const gchar 	*uid,
 	event->tzid		= g_strdup(tzid?tzid:"");
 	event->method		= method;
 	event->sequence		= sequence;
+	event->created          = g_strdup(created?created:"");
+	event->last_modified    = g_strdup(last_modified?last_modified:"");
 	event->type		= type;
 	event->rec_occurrence		= FALSE;
 	while (strchr(event->summary, '\n'))
@@ -932,6 +947,8 @@ void vcal_manager_save_event (VCalEvent *event, gboolean export_after)
 
 	tmp = g_strdup_printf("%d", event->sequence);
 	xml_tag_add_attr(tag, xml_attr_new("sequence", tmp));
+	xml_tag_add_attr(tag, xml_attr_new("created", event->created));
+	xml_tag_add_attr(tag, xml_attr_new("last_modified", event->last_modified));
 	g_free(tmp);
 	
 	tmp = g_strdup_printf("%d", event->type);
@@ -1004,6 +1021,7 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node)
 	GList *list;
 	gchar *org = NULL, *location = NULL, *summary = NULL, *orgname = NULL;
 	gchar *dtstart = NULL, *dtend = NULL, *tzid = NULL;
+	gchar *created = NULL, *last_modified = NULL;
 	gchar *description = NULL, *url = NULL, *recur = NULL;
 	VCalEvent *event = NULL;
 	icalproperty_method method = ICAL_METHOD_REQUEST;
@@ -1050,6 +1068,10 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node)
 			method = atoi(attr->value);
 		if (!strcmp(attr->name, "sequence"))
 			sequence = atoi(attr->value);
+		if (!strcmp(attr->name, "created"))
+			created = g_strdup(attr->value);
+		if (!strcmp(attr->name, "last_modified"))
+			last_modified = g_strdup(attr->value);
 		if (!strcmp(attr->name, "postponed"))
 			postponed = atoi(attr->value);
 		if (!strcmp(attr->name, "rec_occurrence"))
@@ -1058,7 +1080,7 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node)
 
 	event = vcal_manager_new_event(uid, org, orgname, location, summary, description, 
 					dtstart, dtend, recur, tzid, url, method, 
-					sequence, type);
+					sequence, created, last_modified, type);
 
 	event->postponed = postponed;
 	event->rec_occurrence = rec_occurrence;
@@ -1073,6 +1095,8 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node)
 	g_free(dtend);
 	g_free(recur);
 	g_free(tzid);
+	g_free(created);
+	g_free(last_modified);
 
 	node = node->children;
 	while (node != NULL) {
diff --git a/src/plugins/vcalendar/vcal_manager.h b/src/plugins/vcalendar/vcal_manager.h
index e0bcdcad4..6b8038b32 100644
--- a/src/plugins/vcalendar/vcal_manager.h
+++ b/src/plugins/vcalendar/vcal_manager.h
@@ -49,7 +49,9 @@ struct _VCalEvent
 	gchar *description;
 	GSList *answers;
 	enum icalproperty_method method;
-	gint sequence;	
+	gint sequence;
+	gchar *created;
+	gchar *last_modified;
 	gchar *url;
 	enum icalcomponent_kind type;
 	time_t postponed;
@@ -85,6 +87,8 @@ VCalEvent *vcal_manager_new_event	(const gchar 	*uid,
 					 const gchar	*url,
 					 enum icalproperty_method method,
 					 gint		 sequence,
+					 const gchar    *created,
+					 const gchar    *last_modified,
 					 enum icalcomponent_kind type);
 					 
 void vcal_manager_free_event (VCalEvent *event);
diff --git a/src/plugins/vcalendar/vcal_meeting_gtk.c b/src/plugins/vcalendar/vcal_meeting_gtk.c
index 96779cfce..309a1b118 100644
--- a/src/plugins/vcalendar/vcal_meeting_gtk.c
+++ b/src/plugins/vcalendar/vcal_meeting_gtk.c
@@ -89,6 +89,8 @@ struct _VCalMeeting
 	GtkWidget *total_avail_msg;
 	PrefsAccount *account;
 	gboolean visible;
+	gchar     *created;
+	gchar     *last_modified;
 };
 
 struct _VCalAttendee {
@@ -1242,11 +1244,17 @@ static gboolean send_meeting_cb(GtkButton *widget, gpointer data)
 	location	= get_location(meet);
 	summary		= get_summary(meet);
 	description	= get_description(meet);
-	
+
+	if (meet->created == NULL) {
+		meet->created = g_strdup(icaltime_as_ical_string(icaltime_from_timet_with_zone(time(NULL), FALSE, NULL)));
+	}
+	if (meet->last_modified == NULL) {
+		meet->last_modified = g_strdup(icaltime_as_ical_string(icaltime_from_timet_with_zone(time(NULL), FALSE, NULL)));
+	}
 	event = vcal_manager_new_event(uid, organizer, organizer_name, location, summary, description,
 					dtstart, dtend, NULL, tzid, NULL, meet->method, 
 					meet->sequence,
-					ICAL_VEVENT_COMPONENT);
+					meet->created, meet->last_modified, ICAL_VEVENT_COMPONENT);
 	
 	vcal_manager_update_answer(event, organizer, organizer_name, 
 				   ICAL_PARTSTAT_ACCEPTED,
@@ -1381,15 +1389,18 @@ static VCalMeeting *vcal_meeting_create_real(VCalEvent *event, gboolean visible)
 	if (event) {
 		meet->uid = g_strdup(event->uid);
 		meet->sequence = event->sequence + 1;
+		meet->created = event->created ? g_strdup(event->created) : NULL;
+		meet->last_modified = NULL; /* Make sure to update modification time */
+
 		meet->method = (event->method == ICAL_METHOD_CANCEL ?
 				ICAL_METHOD_CANCEL:ICAL_METHOD_REQUEST);
 
 		gtk_entry_set_text(GTK_ENTRY(meet->location), event->location);
 		gtk_entry_set_text(GTK_ENTRY(meet->summary), event->summary);	
 		gtk_text_buffer_set_text(buffer, event->description, -1);	
-	} else 
+	} else {
 		meet->method = ICAL_METHOD_REQUEST;
-	
+	}
 	meet->save_btn		= gtk_button_new_with_label(_("Save & Send"));
 	meet->avail_btn		= gtk_button_new_with_label(_("Check availability"));
 
diff --git a/src/plugins/vcalendar/vcalendar.c b/src/plugins/vcalendar/vcalendar.c
index 4223f6f7f..e1cd8952e 100644
--- a/src/plugins/vcalendar/vcalendar.c
+++ b/src/plugins/vcalendar/vcalendar.c
@@ -162,6 +162,8 @@ static void create_meeting_from_message_cb_ui(GtkAction *action, gpointer data)
 			gchar *url = NULL;
 			gint method = ICAL_METHOD_REQUEST;
 			gint sequence = 1;
+			gchar *created = g_strdup(icaltime_as_ical_string(icaltime_from_timet_with_zone(time(NULL), FALSE, NULL)));
+			gchar *last_modified = g_strdup(icaltime_as_ical_string(icaltime_from_timet_with_zone(time(NULL), FALSE, NULL)));
 			PrefsAccount *account = NULL;
 			
 			claws_fclose(fp);
@@ -182,7 +184,7 @@ static void create_meeting_from_message_cb_ui(GtkAction *action, gpointer data)
 			event = vcal_manager_new_event(uid,
 					org, NULL, NULL/*location*/, summary, description, 
 					dtstart, dtend, recur, tzid, url, method, sequence, 
-					ICAL_VTODO_COMPONENT);
+					created, last_modified, ICAL_VTODO_COMPONENT);
 			g_free(uid);
 			
 			/* hack to get default hours */
@@ -204,6 +206,8 @@ bail:
 			g_free(recur);
 			g_free(tzid);
 			g_free(url);
+			g_free(created);
+			g_free(last_modified);
 		}
 
 		procmsg_msginfo_free(&msginfo);

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list