Completed a pair of functions to fetch the user preferences at the beginning of an...
authorArt Cancro <ajc@uncensored.citadel.org>
Fri, 22 Feb 2013 20:11:21 +0000 (15:11 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Fri, 22 Feb 2013 20:11:21 +0000 (15:11 -0500)
citadel/modules/fulltext/serv_fulltext.c
citadel/modules/smtp/serv_smtp.c

index b0e3d5e7b3941b3c6eed1e0bac68155879a5506a..8e668778817a405208c55cc6ab3ffd7e34f217ad 100644 (file)
@@ -142,9 +142,8 @@ void ft_index_message(long msgnum, int op) {
        CtdlFreeMessage(msg);
        msgtext = CC->redirect_buffer;
        CC->redirect_buffer = NULL;
-       syslog(LOG_DEBUG, "Wordbreaking message %ld...", msgnum);
-       if ((msgtext == NULL) || (StrLength(msgtext) == 0)) {
-               syslog(LOG_ALERT, "This message has a zero length.  Probable data corruption.");
+       if (msgtext != NULL) {
+               syslog(LOG_DEBUG, "Wordbreaking message %ld (%d bytes)", msgnum, StrLength(msgtext));
        }
        txt = SmashStrBuf(&msgtext);
        wordbreaker(txt, &num_tokens, &tokens);
index 49169b6f365501a27ed056321392078e67174e35..297dad260c3c4045d395867cee607456ceef71f3 100644 (file)
@@ -303,21 +303,60 @@ void smtp_hello(long offset, long which_command)
 }
 
 
+/*
+ * Backend function for smtp_webcit_preferences_hack().
+ * Look at a message and determine if it's the preferences file.
+ */
+void smtp_webcit_preferences_hack_backend(long msgnum, void *userdata) {
+       struct CtdlMessage *msg;
+       char **webcit_conf = (char **) userdata;
+
+       if (*webcit_conf) {
+               return; // already got it
+       }
+
+       msg = CtdlFetchMessage(msgnum, 1);
+       if (msg == NULL) {
+               return;
+       }
+
+       if ( (msg->cm_fields['U']) && (!strcasecmp(msg->cm_fields['U'], "__ WebCit Preferences __")) ) {
+               /* This is it!  Change ownership of the message text so it doesn't get freed. */
+               *webcit_conf = (char *)msg->cm_fields['M'];
+               msg->cm_fields['M'] = NULL;
+       }
+       CtdlFreeMessage(msg);
+}
+
+
 /*
  * The configuration item for the user's preferred display name for outgoing email is, unfortunately,
  * stored in the account's WebCit configuration.  We have to fetch it now.
+ */
 void smtp_webcit_preferences_hack(void) {
        char config_roomname[ROOMNAMELEN];
+       char *webcit_conf = NULL;
 
        snprintf(config_roomname, sizeof config_roomname, "%010ld.%s", CC->user.usernum, USERCONFIGROOM);
        if (CtdlGetRoom(&CC->room, config_roomname) != 0) {
                return;
        }
 
-       // FIXME ... finish this
+       /*
+        * Find the WebCit configuration message
+        */
+
+       CtdlForEachMessage(MSGS_ALL, 1, NULL, NULL, NULL, smtp_webcit_preferences_hack_backend, (void *)&webcit_conf);
 
+       if (!webcit_conf) {
+               return;
+       }
+
+       /* FIXME : now do something with this data */
+
+       free(webcit_conf);
+       abort();
 }
- */
 
 
 
@@ -405,7 +444,7 @@ void smtp_try_plain(long offset, long Flags)
 
        if (result == login_ok) {
                if (CtdlTryPassword(pass, len) == pass_ok) {
-                       /* smtp_webcit_preferences_hack(); */
+                       smtp_webcit_preferences_hack();
                        smtp_auth_greeting(offset, Flags);
                        return;
                }