Updated the MIME Parser API to include Content-ID in
[citadel.git] / citadel / modules / vcard / serv_vcard.c
index 2175cf0b9e8e739a559294677171a3c51e2f81ff..8561d43cec9ae7747a7208ceb6c05ed40c120e5a 100644 (file)
@@ -458,7 +458,7 @@ void extract_friendly_name(char *namebuf, size_t namebuf_len, struct vCard *v)
  */
 void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp,
                   void *content, char *cbtype, char *cbcharset, size_t length,
-                  char *encoding, void *cbuserdata)
+                  char *encoding, char *cbid, void *cbuserdata)
 {
        struct vCard **v = (struct vCard **) cbuserdata;
 
@@ -714,8 +714,13 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                        vcard_add_to_directory(I, NULL);
 
                        /* Some sites want an Aide to be notified when a
-                        * user registers or re-registers...
+                        * user registers or re-registers
+                        * But if the user was an Aide or was edited by an Aide then we can
+                        * Assume they don't need validating.
                         */
+                       if (CC->user.axlevel >= 6)
+                               return (0);
+                       
                        set_mm_valid();
 
                        /* ...which also means we need to flag the user */
@@ -789,22 +794,13 @@ struct vCard *vcard_get_user(struct ctdluser *u) {
  * Write our config to disk
  */
 void vcard_write_user(struct ctdluser *u, struct vCard *v) {
-       char temp[PATH_MAX];
-       FILE *fp;
        char *ser;
 
-       CtdlMakeTempFileName(temp, sizeof temp);
        ser = vcard_serialize(v);
-
-       fp = fopen(temp, "w");
-       if (fp == NULL) return;
        if (ser == NULL) {
-               fprintf(fp, "begin:vcard\r\nend:vcard\r\n");
-       } else {
-               fwrite(ser, strlen(ser), 1, fp);
-               free(ser);
+               ser = strdup("begin:vcard\r\nend:vcard\r\n");
        }
-       fclose(fp);
+       if (!ser) return;
 
        /* This handy API function does all the work for us.
         * NOTE: normally we would want to set that last argument to 1, to
@@ -812,15 +808,16 @@ void vcard_write_user(struct ctdluser *u, struct vCard *v) {
         * have to, because the vcard_upload_beforesave() hook above
         * is going to notice what we're trying to do, and delete the old vCard.
         */
-       CtdlWriteObject(USERCONFIGROOM, /* which room */
-                       VCARD_MIME_TYPE,/* MIME type */
-                       temp,           /* temp file */
-                       u,              /* which user */
-                       0,              /* not binary */
-                       0,              /* don't delete others of this type */
-                       0);             /* no flags */
-
-       unlink(temp);
+       CtdlWriteObject(USERCONFIGROOM,         /* which room */
+                       VCARD_MIME_TYPE,        /* MIME type */
+                       ser,                    /* data */
+                       strlen(ser)+1,          /* length */
+                       u,                      /* which user */
+                       0,                      /* not binary */
+                       0,                      /* don't delete others of this type */
+                       0);                     /* no flags */
+
+       free(ser);
 }
 
 
@@ -991,10 +988,14 @@ void vcard_newuser(struct ctdluser *usbuf) {
        /* If using host auth mode, we add an email address based on the login */
        if (config.c_auth_mode == AUTHMODE_HOST) {
                struct passwd pwd;
-               struct passwd **result = NULL;
                char pwd_buffer[SIZ];
-
+               
+#ifdef SOLARIS_GETPWUID
+               if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer) != NULL) {
+#else // SOLARIS_GETPWUID
+               struct passwd **result = NULL;
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, result) == 0) {
+#endif // HAVE_GETPWUID_R
                        snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, config.c_fqdn);
                        vcard_add_prop(v, "email;internet", buf);
                }
@@ -1175,7 +1176,7 @@ void cmd_gvea(char *argbuf)
  */
 void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp,
                void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
-               void *cbuserdata) {
+               char *cbid, void *cbuserdata) {
 
        struct vCard *v;
        char displayname[256];