use an Enum for the cm_fields vector instead of nameless chars
[citadel.git] / citadel / modules / notes / serv_notes.c
index db8474b1ace28dd9604369e92143ec002bace775..bf1de8d0606c3a3a87270eb66d205e35fbfbe258 100644 (file)
@@ -1,21 +1,21 @@
 /*
  * Handles functions related to yellow sticky notes.
  *
- * Copyright (c) 2007-2009 by the citadel.org team
+ * Copyright (c) 2007-2012 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ *  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.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  
+ *  
+ *  
  */
 
 #include "sysdep.h"
@@ -106,7 +106,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
         * any existing message containing that UUID.
         */
        strcpy(uuid, "");
-       p = msg->cm_fields['M'];
+       p = msg->cm_fields[eMesageText];
        a = strlen(p);
        while (--a > 0) {
                if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) {  /* Found it */
@@ -121,15 +121,15 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
                        syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid);
                        if (!IsEmptyStr(uuid)) {
 
-                               if (msg->cm_fields['E'] != NULL) {
-                                       free(msg->cm_fields['E']);
+                               if (msg->cm_fields[eExclusiveID] != NULL) {
+                                       free(msg->cm_fields[eExclusiveID]);
                                }
-                               msg->cm_fields['E'] = strdup(uuid);
+                               msg->cm_fields[eExclusiveID] = strdup(uuid);
 
-                               if (msg->cm_fields['U'] != NULL) {
-                                       free(msg->cm_fields['U']);
+                               if (msg->cm_fields[eMsgSubject] != NULL) {
+                                       free(msg->cm_fields[eMsgSubject]);
                                }
-                               msg->cm_fields['U'] = strdup(uuid);
+                               msg->cm_fields[eMsgSubject] = strdup(uuid);
                        }
                }
                p++;
@@ -137,7 +137,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
 
        /* Modern clients are using vNote format.  Check for one... */
 
-       mime_parser(msg->cm_fields['M'],
+       mime_parser(msg->cm_fields[eMesageText],
                NULL,
                *notes_extract_vnote,
                NULL, NULL,
@@ -151,21 +151,21 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
 
        if (v->uid) if (!IsEmptyStr(v->uid)) {
                syslog(LOG_DEBUG, "UID of vNote is: %s\n", v->uid);
-               if (msg->cm_fields['E'] != NULL) {
-                       free(msg->cm_fields['E']);
+               if (msg->cm_fields[eExclusiveID] != NULL) {
+                       free(msg->cm_fields[eExclusiveID]);
                }
-               msg->cm_fields['E'] = strdup(v->uid);
+               msg->cm_fields[eExclusiveID] = strdup(v->uid);
        }
 
        /* Set the message Subject to the vNote Summary */
 
        if (v->summary) if (!IsEmptyStr(v->summary)) {
-               if (msg->cm_fields['U'] != NULL) {
-                       free(msg->cm_fields['U']);
+               if (msg->cm_fields[eMsgSubject] != NULL) {
+                       free(msg->cm_fields[eMsgSubject]);
                }
-               msg->cm_fields['U'] = strdup(v->summary);
-               if (strlen(msg->cm_fields['U']) > 72) {
-                       strcpy(&msg->cm_fields['U'][68], "...");
+               msg->cm_fields[eMsgSubject] = strdup(v->summary);
+               if (strlen(msg->cm_fields[eMsgSubject]) > 72) {
+                       strcpy(&msg->cm_fields[eMsgSubject][68], "...");
                }
        }
 
@@ -182,6 +182,6 @@ CTDL_MODULE_INIT(notes)
                CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE);
        }
        
-       /* return our Subversion id for the Log */
+       /* return our module name for the log */
        return "notes";
 }