From 94267831ba06be96909f10cb64541a80ee93fc90 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 27 Mar 2024 13:14:41 -0700 Subject: [PATCH] serv_notes.c: cleanup --- citadel/server/modules/notes/serv_notes.c | 68 +++++++++-------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/citadel/server/modules/notes/serv_notes.c b/citadel/server/modules/notes/serv_notes.c index dfa3e597e..593ea3367 100644 --- a/citadel/server/modules/notes/serv_notes.c +++ b/citadel/server/modules/notes/serv_notes.c @@ -1,16 +1,7 @@ -/* - * Handles functions related to yellow sticky notes. - * - * Copyright (c) 2007-2023 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * - * 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. - */ +// Handles functions related to yellow sticky notes. +// +// Copyright (c) 2007-2024 by the citadel.org team +// This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License v3. #include "../../sysdep.h" #include @@ -37,9 +28,7 @@ #include "../../ctdl_module.h" -/* - * Callback function for serv_notes_beforesave() hunts for a vNote in the MIME structure - */ +// Callback function for serv_notes_beforesave() hunts for a vNote in the MIME structure void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *cbuserdata) @@ -47,7 +36,6 @@ void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp, struct vnote **v = (struct vnote **) cbuserdata; if (!strcasecmp(cbtype, "text/vnote")) { - syslog(LOG_DEBUG, "Part %s contains a vNote! Loading...\n", partnum); if (*v != NULL) { vnote_free(*v); @@ -57,41 +45,36 @@ void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp, } -/* - * Before-save hook searches for two different types of notes (legacy Kolab/Aethera notes - * and modern vNote format notes) and does its best to learn the subject (summary) - * and EUID (uid) of the note for Citadel's own nefarious purposes. - */ -int serv_notes_beforesave(struct CtdlMessage *msg, struct recptypes *recp) -{ +// Before-save hook searches for two different types of notes (legacy Kolab/Aethera notes +// and modern vNote format notes) and does its best to learn the subject (summary) +// and EUID (uid) of the note for Citadel's own nefarious purposes. +int serv_notes_beforesave(struct CtdlMessage *msg, struct recptypes *recp) { char *p; int a, i; char uuid[512]; struct vnote *v = NULL; - /* First determine if this room has the "notes" view set */ + // First determine if this room has the "notes" view set if (CC->room.QRdefaultview != VIEW_NOTES) { - return(0); /* not notes; do nothing */ + return(0); // not notes; do nothing } - /* It must be an RFC822 message! */ + // It must be an RFC822 message! if (msg->cm_format_type != 4) { - return(0); /* You tried to save a non-RFC822 message! */ + return(0); // You tried to save a non-RFC822 message! } - /* - * If we are in a "notes" view room, and the client has sent an RFC822 - * message containing an X-KOrg-Note-Id: field (Aethera does this, as - * do some Kolab clients) then set both the Subject and the Exclusive ID - * of the message to that. It's going to be a UUID so we want to replace - * any existing message containing that UUID. - */ + // If we are in a "notes" view room, and the client has sent an RFC822 + // message containing an X-KOrg-Note-Id: field (Aethera does this, as + // do some Kolab clients) then set both the Subject and the Exclusive ID + // of the message to that. It's going to be a UUID so we want to replace + // any existing message containing that UUID. strcpy(uuid, ""); p = msg->cm_fields[eMessageText]; a = msg->cm_lengths[eMessageText]; while (--a > 0) { - if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */ + if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { // Found it safestrncpy(uuid, p + 16, sizeof(uuid)); for (i = 0; uuid[i]; ++i) { if ( (uuid[i] == '\r') || (uuid[i] == '\n') ) { @@ -103,32 +86,31 @@ int serv_notes_beforesave(struct CtdlMessage *msg, struct recptypes *recp) syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid); if (!IsEmptyStr(uuid)) { CM_SetField(msg, eExclusiveID, uuid); - CM_CopyField(msg, eMsgSubject, eExclusiveID); } } p++; } - /* Modern clients are using vNote format. Check for one... */ + // Modern clients are using vNote format. Check for one... mime_parser(CM_RANGE(msg, eMessageText), *notes_extract_vnote, NULL, NULL, - &v, /* user data ptr - put the vnote here */ + &v, // user data ptr - put the vnote here 0 ); - if (v == NULL) return(0); /* no vNotes were found in this message */ + if (v == NULL) return(0); // no vNotes were found in this message - /* Set the message EUID to the vNote UID */ + // Set the message EUID to the vNote UID if ((v->uid) && (!IsEmptyStr(v->uid))) { syslog(LOG_DEBUG, "UID of vNote is: %s\n", v->uid); CM_SetField(msg, eExclusiveID, v->uid); } - /* Set the message Subject to the vNote Summary */ + // Set the message Subject to the vNote Summary if ((v->summary) && (!IsEmptyStr(v->summary))) { CM_SetField(msg, eMsgSubject, v->summary); @@ -151,6 +133,6 @@ char *ctdl_module_init_notes(void) { CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE); } - /* return our module name for the log */ + // return our module name for the log return "notes"; } -- 2.30.2