]> code.citadel.org Git - citadel.git/commitdiff
* serv_notes.c: finished. When saving a message in a room whose view
authorArt Cancro <ajc@citadel.org>
Sat, 23 Oct 2004 14:33:44 +0000 (14:33 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 23 Oct 2004 14:33:44 +0000 (14:33 +0000)
  is set to "notes," look for an X-KOrg-Note-Id: header, and if one is
  present, set both the Extended ID and the Subject to that.  This is for
  Aethera compatibility.

citadel/ChangeLog
citadel/room_ops.c
citadel/serv_notes.c
citadel/server.h

index 79e570c92edd0b8ce1399014d6ed41c6f4da7da9..21bd15fadaf4e5e02471c9c63f74a082293dfb65 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 626.15  2004/10/23 14:33:44  ajc
+ * serv_notes.c: finished.  When saving a message in a room whose view
+   is set to "notes," look for an X-KOrg-Note-Id: header, and if one is
+   present, set both the Extended ID and the Subject to that.  This is for
+   Aethera compatibility.
+
  Revision 626.14  2004/10/22 14:49:25  ajc
  * newinstall.sh: Be more careful about locating make/gmake on the host
    system.  Also now tries to use curl if wget is not available.
@@ -6172,4 +6178,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 1f19e320ac27ca1699b093c35595e45d246b2aaa..6a946041e5e06a1942b9dc76c7395afbcc246c15 100644 (file)
@@ -847,6 +847,8 @@ void usergoto(char *where, int display_result, int transiently,
                new_messages, total_messages
        );
 
+       CC->curr_view = (int)vbuf.v_view;
+
        if (display_result) {
                cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d|%d|\n",
                        CIT_OK, CtdlCheckExpress(),
index c5d537dc40ed53455d1507e2c5fb09e54740aa7a..322550df5be6aa076eee6b9245f74fda63563323 100644 (file)
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
+#include "tools.h"
+
+
+/*
+ * 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 Extended ID
+ * of the message to that.  It's going to be a UUID so we want to replace
+ * any existing message containing that UUID.
+ */
+int serv_notes_beforesave(struct CtdlMessage *msg)
+{
+       char *p;
+       int a, i;
+       char uuid[SIZ];
+
+       /* First determine if this room has the "notes" view set */
+
+       if (CC->curr_view != VIEW_NOTES) {
+               return(0);                      /* not notes; do nothing */
+       }
+
+       /* It must be an RFC822 message! */
+       if (msg->cm_format_type != 4) {
+               return(0);      /* You tried to save a non-RFC822 message! */
+       }
+       
+       /* Find the X-KOrg-Note-Id: header */
+       strcpy(uuid, "");
+       p = msg->cm_fields['M'];
+       a = strlen(p);
+       while (--a > 0) {
+               if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) {  /* Found it */
+                       safestrncpy(uuid, p + 16, sizeof(uuid));
+                       for (i = 0; i<strlen(uuid); ++i) {
+                               if ( (uuid[i] == '\r') || (uuid[i] == '\n') ) {
+                                       uuid[i] = 0;
+                               }
+                       }
+
+                       lprintf(9, "UUID of note is: %s\n", uuid);
+                       if (strlen(uuid) > 0) {
+
+                               if (msg->cm_fields['E'] != NULL) {
+                                       free(msg->cm_fields['E']);
+                               }
+                               msg->cm_fields['E'] = strdup(uuid);
+
+                               if (msg->cm_fields['U'] != NULL) {
+                                       free(msg->cm_fields['U']);
+                               }
+                               msg->cm_fields['U'] = strdup(uuid);
+                       }
+               }
+               p++;
+       }
+       
+       return(0);
+}
 
 
 char *serv_notes_init(void)
 {
-   return "$Id$";
+       CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE);
+       return "$Id$";
 }
index 2dbfd1882de1ad7834adafe7f78a6c8f95499ab9..c1761e30bba520a0738ff5038ee218ef81fe0769 100644 (file)
@@ -82,6 +82,7 @@ struct CitContext {
        char temp[PATH_MAX];    /* temp file name */
        int nologin;            /* not allowed to log in */
        int is_local_socket;    /* set to 1 if client is on unix domain sock */
+       int curr_view;          /* The view type for the current user/room */
 
        char net_node[PATH_MAX];/* Is the client another Citadel server? */
        int client_socket;