* added message subject to all those tiny messages
[citadel.git] / citadel / serv_vcard.c
index c7cc076a2759ad9f144e0981152b05a918fd6afc..f2205b687b6d26177f05f621ccc39a32c6d8bd24 100644 (file)
@@ -189,7 +189,7 @@ void cmd_igab(char *argbuf) {
        CtdlDirectoryInit();
 
        /* We want *all* vCards in this room */
-       CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard",
+       CtdlForEachMessage(MSGS_ALL, 0, NULL, "text/x-vcard",
                NULL, vcard_add_to_directory, NULL);
 
        getroom(&CC->room, hold_rm);    /* return to saved room */
@@ -323,7 +323,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", 1);
+                                               NULL, 0, "text/x-vcard", 1);
 
                                /* Make the author of the message the name of the user.
                                 */
@@ -522,7 +522,7 @@ struct vCard *vcard_get_user(struct ctdluser *u) {
 
        /* We want the last (and probably only) vcard in this room */
        VCmsgnum = (-1);
-       CtdlForEachMessage(MSGS_LAST, 1, "text/x-vcard",
+       CtdlForEachMessage(MSGS_LAST, 1, NULL, "text/x-vcard",
                NULL, vcard_gu_backend, (void *)&VCmsgnum );
        getroom(&CC->room, hold_rm);    /* return to saved room */
 
@@ -876,6 +876,56 @@ void cmd_qdir(char *argbuf) {
        cprintf("%d %s\n", CIT_OK, citadel_addr);
 }
 
+/*
+ * Query Directory, in fact an alias to match postfix tcp auth.
+ */
+void check_get(void) {
+       char internet_addr[256];
+
+       char cmdbuf[SIZ];
+
+       time(&CC->lastcmd);
+       memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
+       if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
+               lprintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               CC->kill_me = 1;
+               return;
+       }
+       lprintf(CTDL_INFO, ": %s\n", cmdbuf);
+       while (strlen(cmdbuf) < 3) strcat(cmdbuf, " ");
+
+       if (strcasecmp(cmdbuf, "GET "));
+       {
+               struct recptypes *rcpt;
+               char *argbuf = &cmdbuf[4];
+               
+               extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
+               rcpt = validate_recipients(internet_addr);
+               if ((rcpt != NULL)&&
+                       (
+                        (*rcpt->recp_local != '\0')||
+                        (*rcpt->recp_room != '\0')||
+                        (*rcpt->recp_ignet != '\0')))
+               {
+
+                       cprintf("200 OK %s\n", internet_addr);
+                       lprintf(CTDL_INFO, "sending 200 OK for the room %s\n", rcpt->display_recp);
+               }
+               else 
+               {
+                       cprintf("500 REJECT noone here by that name.\n");
+                       
+                       lprintf(CTDL_INFO, "sending 500 REJECT noone here by that name: %s\n", internet_addr);
+               }
+               if (rcpt != NULL) free (rcpt);
+       }
+///    CC->kill_me = 1;
+}
+
+void check_get_greeting(void) {
+/* dummy function, we have no greeting in this verry simple protocol. */
+}
+
 
 /*
  * We don't know if the Contacts room exists so we just create it at login
@@ -1009,7 +1059,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) {
 
        /* First remove any addresses we already have in the address book */
        usergoto(aptr->roomname, 0, 0, NULL, NULL);
-       CtdlForEachMessage(MSGS_ALL, 0, "text/x-vcard", NULL,
+       CtdlForEachMessage(MSGS_ALL, 0, NULL, "text/x-vcard", NULL,
                strip_addresses_already_have, aptr->collected_addresses);
 
        if (strlen(aptr->collected_addresses) > 0)
@@ -1073,7 +1123,7 @@ void store_harvested_addresses(void) {
 
 
 /* 
- * Function to output a vCard as plain text.  Nobody uses MSG0 anymore, so
+ * Function to output vCard data as plain text.  Nobody uses MSG0 anymore, so
  * really this is just so we expose the vCard data to the full text indexer.
  */
 void vcard_fixed_output(char *ptr, int len) {
@@ -1082,7 +1132,6 @@ void vcard_fixed_output(char *ptr, int len) {
        char *key, *value;
        int i = 0;
 
-       cprintf("vCard:\n");
        serialized_vcard = malloc(len + 1);
        safestrncpy(serialized_vcard, ptr, len+1);
        v = vcard_load(serialized_vcard);
@@ -1091,7 +1140,7 @@ void vcard_fixed_output(char *ptr, int len) {
        i = 0;
        while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) {
                value = vcard_get_prop(v, "", 0, i++, 0);
-               cprintf("%20s : %s\n", key, value);
+               cprintf("%s\n", value);
        }
 
        vcard_free(v);
@@ -1138,7 +1187,19 @@ char *serv_vcard_init(void)
                assoc_file_name(filename, sizeof filename, &qr, ctdl_netcfg_dir);
                fp = fopen(filename, "a");
                if (fp != NULL) fclose(fp);
+               chown(filename, CTDLUID, (-1));
        }
 
        return "$Id$";
 }
+
+
+char *serv_postfix_tcpdict(void)
+{
+       CtdlRegisterServiceHook(config.c_pftcpdict_port,        /* Postfix */
+                               NULL,
+                               check_get_greeting,
+                               check_get,
+                               NULL);
+       return "$Id$";
+}