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 "sysdep_decls.h"
35 #include "citserver.h"
38 #include "serv_extensions.h"
48 * If we are in a "notes" view room, and the client has sent an RFC822
49 * message containing an X-KOrg-Note-Id: field (Aethera does this, as
50 * do some Kolab clients) then set both the Subject and the Exclusive ID
51 * of the message to that. It's going to be a UUID so we want to replace
52 * any existing message containing that UUID.
54 int serv_notes_beforesave(struct CtdlMessage *msg)
60 /* First determine if this room has the "notes" view set */
62 if (CC->room.QRdefaultview != VIEW_NOTES) {
63 return(0); /* not notes; do nothing */
66 /* It must be an RFC822 message! */
67 if (msg->cm_format_type != 4) {
68 return(0); /* You tried to save a non-RFC822 message! */
71 /* Find the X-KOrg-Note-Id: header */
73 p = msg->cm_fields['M'];
76 if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */
77 safestrncpy(uuid, p + 16, sizeof(uuid));
78 for (i = 0; i<strlen(uuid); ++i) {
79 if ( (uuid[i] == '\r') || (uuid[i] == '\n') ) {
84 lprintf(9, "UUID of note is: %s\n", uuid);
85 if (strlen(uuid) > 0) {
87 if (msg->cm_fields['E'] != NULL) {
88 free(msg->cm_fields['E']);
90 msg->cm_fields['E'] = strdup(uuid);
92 if (msg->cm_fields['U'] != NULL) {
93 free(msg->cm_fields['U']);
95 msg->cm_fields['U'] = strdup(uuid);
105 char *serv_notes_init(void)
107 CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE);