]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/vcard/serv_vcard.c
* When translating the input from a REGI command into a vCard, set the telephone...
[citadel.git] / citadel / modules / vcard / serv_vcard.c
index 2f126f40852b3cae4e2e44225c715c6f1ab26064..3539c43d41fda9d77209ae82eba194ec2efd3967 100644 (file)
@@ -247,13 +247,16 @@ void ctdl_vcard_to_directory(struct CtdlMessage *msg, int op) {
                        }
                }
 
-               if (!strcasecmp(v->prop[i].name, "tel;home"))
+               if ( (!strcasecmp(v->prop[i].name, "tel;home"))
+                  || (!strcasecmp(v->prop[i].name, "tel;type=home")) )
                        (void) CtdlDoDirectoryServiceFunc("homePhone", v->prop[i].value, &objectlist, "ldap", DIRECTORY_ATTRIB_ADD);
                else
-               if (!strcasecmp(v->prop[i].name, "tel;fax"))
+               if ( (!strcasecmp(v->prop[i].name, "tel;fax"))
+                  || (!strcasecmp(v->prop[i].name, "tel;type=fax")) )
                        (void) CtdlDoDirectoryServiceFunc("facsimileTelephoneNumber", v->prop[i].value, &objectlist, "ldap", DIRECTORY_ATTRIB_ADD);
                else
-               if (!strcasecmp(v->prop[i].name, "tel;cell"))
+               if ( (!strcasecmp(v->prop[i].name, "tel;cell"))
+                  || (!strcasecmp(v->prop[i].name, "tel;type=cell")) )
                        (void) CtdlDoDirectoryServiceFunc("mobile", v->prop[i].value, &objectlist, "ldap", DIRECTORY_ATTRIB_ADD);
                else
                if ( (!strcasecmp(v->prop[i].name, "tel"))
@@ -458,7 +461,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;
 
@@ -718,8 +721,12 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
                         * 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)
+                       if (CC->user.axlevel >= 6) {
+                               lgetuser(&CC->user, CC->curr_user);
+                               CC->user.flags |= US_REGIS;
+                               lputuser(&CC->user);
                                return (0);
+                       }
                        
                        set_mm_valid();
 
@@ -794,22 +801,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
@@ -817,15 +815,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);
 }
 
 
@@ -883,7 +882,7 @@ void cmd_regi(char *argbuf) {
                                }
                        }
                }
-               if (a==5) vcard_set_prop(my_vcard, "tel;home", buf, 0);
+               if (a==5) vcard_set_prop(my_vcard, "tel", buf, 0);
                if (a==6) vcard_set_prop(my_vcard, "email;internet", buf, 0);
                if (a==7) strcpy(tmpcountry, buf);
                ++a;
@@ -949,7 +948,7 @@ void cmd_greg(char *argbuf)
        extract_token(buf, adr, 5, ';', sizeof buf);
        cprintf("%s\n", buf);                           /* zip */
 
-       s = vcard_get_prop(v, "tel;home", 0, 0, 0);
+       s = vcard_get_prop(v, "tel", 0, 0, 0);
        if (s == NULL) s = vcard_get_prop(v, "tel", 1, 0, 0);
        if (s != NULL) {
                cprintf("%s\n", s);
@@ -1001,8 +1000,9 @@ void vcard_newuser(struct ctdluser *usbuf) {
 #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) {
+               struct passwd *result = NULL;
+               CtdlLogPrintf(CTDL_DEBUG, "Searching for uid %d\n", usbuf->uid);
+               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);
@@ -1184,7 +1184,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];