]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtp.c
Began writing a routine to fetch the user's preferred display name for authenticated...
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index e40e4c7edca5e97492850ecf5c7a73c0648642a8..49169b6f365501a27ed056321392078e67174e35 100644 (file)
@@ -303,6 +303,23 @@ void smtp_hello(long offset, long which_command)
 }
 
 
+/*
+ * 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];
+
+       snprintf(config_roomname, sizeof config_roomname, "%010ld.%s", CC->user.usernum, USERCONFIGROOM);
+       if (CtdlGetRoom(&CC->room, config_roomname) != 0) {
+               return;
+       }
+
+       // FIXME ... finish this
+
+}
+ */
+
+
 
 /*
  * Implement HELP command.
@@ -388,6 +405,7 @@ void smtp_try_plain(long offset, long Flags)
 
        if (result == login_ok) {
                if (CtdlTryPassword(pass, len) == pass_ok) {
+                       /* smtp_webcit_preferences_hack(); */
                        smtp_auth_greeting(offset, Flags);
                        return;
                }
@@ -411,10 +429,10 @@ void smtp_auth(long offset, long Flags)
                return;
        }
 
-       extract_token(method, ChrPtr(sSMTP->Cmd), 0, ' ', sizeof method);
+       extract_token(method, ChrPtr(sSMTP->Cmd) + offset, 0, ' ', sizeof method);
 
        if (!strncasecmp(method, "login", 5) ) {
-               if (StrLength(sSMTP->Cmd) >= 7) {
+               if (StrLength(sSMTP->Cmd) - offset >= 7) {
                        smtp_get_user(6);
                }
                else {
@@ -427,18 +445,18 @@ void smtp_auth(long offset, long Flags)
 
        if (!strncasecmp(method, "plain", 5) ) {
                long len;
-               if (num_tokens(ChrPtr(sSMTP->Cmd), ' ') < 2) {
+               if (num_tokens(ChrPtr(sSMTP->Cmd) + offset, ' ') < 2) {
                        cprintf("334 \r\n");
                        SMTP->command_state = smtp_plain;
                        return;
                }
 
                len = extract_token(encoded_authstring, 
-                                   ChrPtr(sSMTP->Cmd),
+                                   ChrPtr(sSMTP->Cmd) + offset,
                                    1, ' ',
                                    sizeof encoded_authstring);
                StrBufPlain(sSMTP->Cmd, encoded_authstring, len);
-               smtp_try_plain(offset, Flags);
+               smtp_try_plain(0, Flags);
                return;
        }
 
@@ -1007,6 +1025,7 @@ CTDL_MODULE_INIT(smtp)
        if (!threading)
        {
                SMTPCmds = NewHash(1, NULL);
+               
                RegisterSmtpCMD("AUTH", smtp_auth, 0);
                RegisterSmtpCMD("DATA", smtp_data, 0);
                RegisterSmtpCMD("HELO", smtp_hello, HELO);
@@ -1060,6 +1079,7 @@ CTDL_MODULE_INIT(smtp)
                                        NULL,
                                        CitadelServiceSMTP_LMTP_UNF);
 
+               CtdlRegisterCleanupHook(smtp_cleanup);
                CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP, PRIO_STOP + 250);
        }