4 * Handles functions related to yellow sticky notes.
16 #include <sys/types.h>
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
23 # include <sys/time.h>
34 #include "citserver.h"
44 #include "ctdl_module.h"
49 * If we are in a "notes" view room, and the client has sent an RFC822
50 * message containing an X-KOrg-Note-Id: field (Aethera does this, as
51 * do some Kolab clients) then set both the Subject and the Exclusive ID
52 * of the message to that. It's going to be a UUID so we want to replace
53 * any existing message containing that UUID.
55 int serv_notes_beforesave(struct CtdlMessage *msg)
61 /* First determine if this room has the "notes" view set */
63 if (CC->room.QRdefaultview != VIEW_NOTES) {
64 return(0); /* not notes; do nothing */
67 /* It must be an RFC822 message! */
68 if (msg->cm_format_type != 4) {
69 return(0); /* You tried to save a non-RFC822 message! */
72 /* Find the X-KOrg-Note-Id: header */
74 p = msg->cm_fields['M'];
77 if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */
78 safestrncpy(uuid, p + 16, sizeof(uuid));
79 for (i = 0; uuid[i]; ++i) {
80 if ( (uuid[i] == '\r') || (uuid[i] == '\n') ) {
86 lprintf(9, "UUID of note is: %s\n", uuid);
87 if (!IsEmptyStr(uuid)) {
89 if (msg->cm_fields['E'] != NULL) {
90 free(msg->cm_fields['E']);
92 msg->cm_fields['E'] = strdup(uuid);
94 if (msg->cm_fields['U'] != NULL) {
95 free(msg->cm_fields['U']);
97 msg->cm_fields['U'] = strdup(uuid);
107 CTDL_MODULE_INIT(notes)
109 CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE);
111 /* return our Subversion id for the Log */