]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_vcard.c
* Restructured cmd_auto() to be able to search vCards in more than one room.
[citadel.git] / citadel / serv_vcard.c
index d1f747e69cc97909eb046667dae76b4b99cf2fe8..25b561d9cd1d324cd725bc146fab8c8660cf1533 100644 (file)
@@ -7,13 +7,6 @@
  * Copyright (c) 1999-2002 / released under the GNU General Public License
  */
 
-/*
- * Where we keep messages containing the vCards that source our directory.  It
- * makes no sense to change this, because you'd have to change it on every
- * system on the network.  That would be stupid.
- */
-#define ADDRESS_BOOK_ROOM      "Global Address Book"
-
 /*
  * Format of the "Exclusive ID" field of the message containing a user's
  * vCard.  Doesn't matter what it really looks like as long as it's both
@@ -128,7 +121,6 @@ void vcard_extract_internet_addresses(struct CtdlMessage *msg,
 /*
  * Callback for vcard_add_to_directory()
  * (Lotsa ugly nested callbacks.  Oh well.)
- * This little shim function makes sure we're not 
  */
 void vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
        char buf[SIZ];
@@ -139,7 +131,7 @@ void vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
         */
        if (CC->logged_in) {
                lprintf(CTDL_DEBUG, "Checking for <%s>...\n", internet_addr);
-               if (CtdlDirectoryLookup(buf, internet_addr) == 0) {
+               if (CtdlDirectoryLookup(buf, internet_addr, sizeof buf) == 0) {
                        if (strcasecmp(buf, citadel_addr)) {
                                /* This address belongs to someone else.
                                 * Bail out silently without saving.
@@ -323,7 +315,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
                                 * vCard in the user's config room at all times.
                                 */
                                CtdlDeleteMessages(CC->room.QRname,
-                                               0L, "text/x-vcard");
+                                               0L, "text/x-vcard", 1);
 
                                /* Make the author of the message the name of the user.
                                 */
@@ -368,7 +360,6 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
 
                                /* 
                                 * Set the EUID of the message to the UID of the vCard.
-                                * Also set the Subject if there isn't already one.
                                 */
                                if (msg->cm_fields['E'] != NULL) free(msg->cm_fields['E']);
                                s = vcard_get_prop(v, "UID", 0, 0, 0);
@@ -379,6 +370,20 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
                                        }
                                }
 
+                               /*
+                                * Set the Subject to the name in the vCard.
+                                */
+                               s = vcard_get_prop(v, "FN", 0, 0, 0);
+                               if (s == NULL) {
+                                       s = vcard_get_prop(v, "N", 0, 0, 0);
+                               }
+                               if (s != NULL) {
+                                       if (msg->cm_fields['U'] != NULL) {
+                                               free(msg->cm_fields['U']);
+                                       }
+                                       msg->cm_fields['U'] = strdup(s);
+                               }
+
                                /* Re-serialize it back into the msg body */
                                ser = vcard_serialize(v);
                                if (ser != NULL) {
@@ -902,7 +907,7 @@ void cmd_qdir(char *argbuf) {
 
        extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
 
-       if (CtdlDirectoryLookup(citadel_addr, internet_addr) != 0) {
+       if (CtdlDirectoryLookup(citadel_addr, internet_addr, sizeof citadel_addr) != 0) {
                cprintf("%d %s was not found.\n",
                        ERROR + NO_SUCH_USER, internet_addr);
                return;