Back to index

citadel  8.12
Functions
serv_notes.c File Reference
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <pwd.h>
#include <errno.h>
#include <sys/types.h>
#include <time.h>
#include <sys/wait.h>
#include <string.h>
#include <limits.h>
#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "support.h"
#include "config.h"
#include "user_ops.h"
#include "database.h"
#include "msgbase.h"
#include "ctdl_module.h"

Go to the source code of this file.

Functions

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)
int serv_notes_beforesave (struct CtdlMessage *msg)
 CTDL_MODULE_INIT (notes)

Function Documentation

CTDL_MODULE_INIT ( notes  )

Definition at line 178 of file serv_notes.c.

{
       if (!threading)
       {
              CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE);
       }
       
       /* return our module name for the log */
       return "notes";
}

Here is the call graph for this function:

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 
)

Definition at line 61 of file serv_notes.c.

{
       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);
              }
              *v = vnote_new_from_str(content);
       }
}

Here is the caller graph for this function:

int serv_notes_beforesave ( struct CtdlMessage msg)

Definition at line 83 of file serv_notes.c.

{
       char *p;
       int a, i;
       char uuid[512];
       struct vnote *v = NULL;

       /* First determine if this room has the "notes" view set */

       if (CC->room.QRdefaultview != 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! */
       }
       
       /*
        * 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['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; uuid[i]; ++i) {
                            if ( (uuid[i] == '\r') || (uuid[i] == '\n') ) {
                                   uuid[i] = 0;
                                   break;
                            }
                     }

                     syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid);
                     if (!IsEmptyStr(uuid)) {

                            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++;
       }

       /* Modern clients are using vNote format.  Check for one... */

       mime_parser(msg->cm_fields['M'],
              NULL,
              *notes_extract_vnote,
              NULL, NULL,
              &v,           /* user data ptr - put the vnote here */
              0
       );

       if (v == NULL) return(0);   /* no vNotes were found in this message */

       /* Set the message EUID to the vNote UID */

       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']);
              }
              msg->cm_fields['E'] = 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']);
              }
              msg->cm_fields['U'] = strdup(v->summary);
              if (strlen(msg->cm_fields['U']) > 72) {
                     strcpy(&msg->cm_fields['U'][68], "...");
              }
       }

       vnote_free(v);
       
       return(0);
}

Here is the call graph for this function:

Here is the caller graph for this function: