Fossil SCM

Improved tracing capabilities for email notifications. Add the SelectAll button to the webmail display.

drh 2018-07-17 18:32 trunk
Commit f880aa82aad218ae64317f0338909da924f3004ef1abfa3976133ae1ac302d2c
4 files changed +1 -1 +31 -10 +3 -1 +10 -1
+1 -1
--- src/cgi.c
+++ src/cgi.c
@@ -344,11 +344,11 @@
344344
345345
/* After the webpage has been sent, do any useful background
346346
** processing.
347347
*/
348348
if( iReplyStatus==200 && fossil_strcmp(zContentType,"text/html")==0 ){
349
- email_auto_exec();
349
+ email_auto_exec(0);
350350
}
351351
}
352352
353353
/*
354354
** Do a redirect request to the URL given in the argument.
355355
--- src/cgi.c
+++ src/cgi.c
@@ -344,11 +344,11 @@
344
345 /* After the webpage has been sent, do any useful background
346 ** processing.
347 */
348 if( iReplyStatus==200 && fossil_strcmp(zContentType,"text/html")==0 ){
349 email_auto_exec();
350 }
351 }
352
353 /*
354 ** Do a redirect request to the URL given in the argument.
355
--- src/cgi.c
+++ src/cgi.c
@@ -344,11 +344,11 @@
344
345 /* After the webpage has been sent, do any useful background
346 ** processing.
347 */
348 if( iReplyStatus==200 && fossil_strcmp(zContentType,"text/html")==0 ){
349 email_auto_exec(0);
350 }
351 }
352
353 /*
354 ** Do a redirect request to the URL given in the argument.
355
+31 -10
--- src/email.c
+++ src/email.c
@@ -403,13 +403,14 @@
403403
char *zErr; /* Error message */
404404
u32 mFlags; /* Flags */
405405
int bImmediateFail; /* On any error, call fossil_fatal() */
406406
};
407407
408
-/* Allowed values for EmailSender flags */
408
+/* Allowed values for mFlags to email_sender_new().
409
+*/
409410
#define EMAIL_IMMEDIATE_FAIL 0x0001 /* Call fossil_fatal() on any error */
410
-#define EMAIL_SMTP_TRACE 0x0002 /* Write SMTP transcript to console */
411
+#define EMAIL_TRACE 0x0002 /* Log sending process on console */
411412
412413
#endif /* INTERFACE */
413414
414415
/*
415416
** Shutdown an emailer. Clear all information other than the error message.
@@ -536,11 +537,11 @@
536537
}else if( fossil_strcmp(p->zDest, "relay")==0 ){
537538
const char *zRelay = 0;
538539
emailerGetSetting(p, &zRelay, "email-send-relayhost");
539540
if( zRelay ){
540541
u32 smtpFlags = SMTP_DIRECT;
541
- if( mFlags & EMAIL_SMTP_TRACE ) smtpFlags |= SMTP_TRACE_STDOUT;
542
+ if( mFlags & EMAIL_TRACE ) smtpFlags |= SMTP_TRACE_STDOUT;
542543
p->pSmtp = smtp_session_new(p->zFrom, zRelay, smtpFlags);
543544
smtp_client_startup(p->pSmtp);
544545
}
545546
}
546547
return p;
@@ -694,10 +695,13 @@
694695
** not free them.
695696
*/
696697
void email_send(EmailSender *p, Blob *pHdr, Blob *pBody){
697698
Blob all, *pOut;
698699
u64 r1, r2;
700
+ if( p->mFlags & EMAIL_TRACE ){
701
+ fossil_print("Sending email\n");
702
+ }
699703
if( fossil_strcmp(p->zDest, "off")==0 ){
700704
return;
701705
}
702706
if( fossil_strcmp(p->zDest, "blob")==0 ){
703707
pOut = &p->out;
@@ -943,11 +947,11 @@
943947
int i;
944948
u32 mFlags = EMAIL_IMMEDIATE_FAIL;
945949
const char *zSubject = find_option("subject", "S", 1);
946950
const char *zSource = find_option("body", 0, 1);
947951
EmailSender *pSender;
948
- if( find_option("smtp-trace",0,0)!=0 ) mFlags |= EMAIL_SMTP_TRACE;
952
+ if( find_option("smtp-trace",0,0)!=0 ) mFlags |= EMAIL_TRACE;
949953
verify_all_options();
950954
blob_init(&prompt, 0, 0);
951955
blob_init(&body, 0, 0);
952956
blob_init(&hdr, 0, 0);
953957
blob_appendf(&hdr,"To: ");
@@ -1954,40 +1958,49 @@
19541958
}
19551959
19561960
/*
19571961
** COMMAND: test-add-alerts
19581962
**
1959
-** Usage: %fossil test-add-alerts EVENTID ...
1963
+** Usage: %fossil test-add-alerts [--autoexec] EVENTID ...
19601964
**
19611965
** Add one or more events to the pending_alert queue. Use this
19621966
** command during testing to force email notifications for specific
19631967
** events.
19641968
**
19651969
** EVENTIDs are text. The first character is 'c', 'w', or 't'
19661970
** for check-in, wiki, or ticket. The remaining text is a
19671971
** integer that references the EVENT.OBJID value for the event.
19681972
** Run /timeline?showid to see these OBJID values.
1973
+**
1974
+** If the --autoexec option is included, then email_auto_exec() is run
1975
+** after all alerts have been added. This will cause the alerts to
1976
+** be sent out with the SENDALERT_TRACE option.
19691977
*/
19701978
void test_add_alert_cmd(void){
19711979
int i;
1980
+ int doAuto = find_option("autoexec",0,0)!=0;
19721981
db_find_and_open_repository(0, 0);
19731982
verify_all_options();
1974
- db_begin_transaction();
1983
+ db_begin_write();
19751984
email_schema(0);
19761985
for(i=2; i<g.argc; i++){
19771986
db_multi_exec("REPLACE INTO pending_alert(eventId) VALUES(%Q)", g.argv[i]);
19781987
}
19791988
db_end_transaction(0);
1989
+ if( doAuto ){
1990
+ email_auto_exec(SENDALERT_TRACE);
1991
+ }
19801992
}
19811993
19821994
#if INTERFACE
19831995
/*
19841996
** Flags for email_send_alerts()
19851997
*/
19861998
#define SENDALERT_DIGEST 0x0001 /* Send a digest */
19871999
#define SENDALERT_PRESERVE 0x0002 /* Do not mark the task as done */
19882000
#define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */
2001
+#define SENDALERT_TRACE 0x0008 /* Trace operation for debugging */
19892002
19902003
#endif /* INTERFACE */
19912004
19922005
/*
19932006
** Send alert emails to all subscribers.
@@ -2001,10 +2014,11 @@
20012014
const char *zUrl;
20022015
const char *zRepoName;
20032016
const char *zFrom;
20042017
const char *zDest = (flags & SENDALERT_STDOUT) ? "stdout" : 0;
20052018
EmailSender *pSender = 0;
2019
+ u32 senderFlags = 0;
20062020
20072021
if( g.fSqlTrace ) fossil_trace("-- BEGIN email_send_alerts(%u)\n", flags);
20082022
db_begin_transaction();
20092023
if( !email_enabled() ) goto send_alerts_done;
20102024
zUrl = db_get("email-url",0);
@@ -2011,11 +2025,14 @@
20112025
if( zUrl==0 ) goto send_alerts_done;
20122026
zRepoName = db_get("email-subname",0);
20132027
if( zRepoName==0 ) goto send_alerts_done;
20142028
zFrom = db_get("email-self",0);
20152029
if( zFrom==0 ) goto send_alerts_done;
2016
- pSender = email_sender_new(zDest, 0);
2030
+ if( flags & SENDALERT_TRACE ){
2031
+ senderFlags |= EMAIL_TRACE;
2032
+ }
2033
+ pSender = email_sender_new(zDest, senderFlags);
20172034
db_multi_exec(
20182035
"DROP TABLE IF EXISTS temp.wantalert;"
20192036
"CREATE TEMP TABLE wantalert(eventId TEXT);"
20202037
);
20212038
if( flags & SENDALERT_DIGEST ){
@@ -2093,12 +2110,16 @@
20932110
** Check to see if any email notifications need to occur, and then
20942111
** do them.
20952112
**
20962113
** This routine is called after certain webpages have been run and
20972114
** have already responded.
2115
+**
2116
+** The mFlags option is zero or more of the SENDALERT_* flags. Normally
2117
+** this flag is zero, but the test-set-alert command sets it to
2118
+** SENDALERT_TRACE.
20982119
*/
2099
-void email_auto_exec(void){
2120
+void email_auto_exec(u32 mFlags){
21002121
int iJulianDay;
21012122
if( g.db==0 ) return;
21022123
if( db_transaction_nesting_depth()!=0 ){
21032124
fossil_warning("Called email_auto_exec() from within transaction "
21042125
"started at %z", db_transaction_start_point());
@@ -2105,18 +2126,18 @@
21052126
return;
21062127
}
21072128
if( !email_tables_exist() ) return;
21082129
if( !db_get_boolean("email-autoexec",0) ) return;
21092130
db_begin_write();
2110
- email_send_alerts(0);
2131
+ email_send_alerts(mFlags);
21112132
iJulianDay = db_int(0, "SELECT julianday('now')");
21122133
if( iJulianDay>db_get_int("email-last-digest",0) ){
21132134
if( db_transaction_nesting_depth()!=1 ){
21142135
fossil_warning("Transaction nesting error prior to digest processing");
21152136
}else{
21162137
db_set_int("email-last-digest",iJulianDay,0);
2117
- email_send_alerts(SENDALERT_DIGEST);
2138
+ email_send_alerts(SENDALERT_DIGEST|mFlags);
21182139
}
21192140
}
21202141
db_commit_transaction();
21212142
}
21222143
21232144
--- src/email.c
+++ src/email.c
@@ -403,13 +403,14 @@
403 char *zErr; /* Error message */
404 u32 mFlags; /* Flags */
405 int bImmediateFail; /* On any error, call fossil_fatal() */
406 };
407
408 /* Allowed values for EmailSender flags */
 
409 #define EMAIL_IMMEDIATE_FAIL 0x0001 /* Call fossil_fatal() on any error */
410 #define EMAIL_SMTP_TRACE 0x0002 /* Write SMTP transcript to console */
411
412 #endif /* INTERFACE */
413
414 /*
415 ** Shutdown an emailer. Clear all information other than the error message.
@@ -536,11 +537,11 @@
536 }else if( fossil_strcmp(p->zDest, "relay")==0 ){
537 const char *zRelay = 0;
538 emailerGetSetting(p, &zRelay, "email-send-relayhost");
539 if( zRelay ){
540 u32 smtpFlags = SMTP_DIRECT;
541 if( mFlags & EMAIL_SMTP_TRACE ) smtpFlags |= SMTP_TRACE_STDOUT;
542 p->pSmtp = smtp_session_new(p->zFrom, zRelay, smtpFlags);
543 smtp_client_startup(p->pSmtp);
544 }
545 }
546 return p;
@@ -694,10 +695,13 @@
694 ** not free them.
695 */
696 void email_send(EmailSender *p, Blob *pHdr, Blob *pBody){
697 Blob all, *pOut;
698 u64 r1, r2;
 
 
 
699 if( fossil_strcmp(p->zDest, "off")==0 ){
700 return;
701 }
702 if( fossil_strcmp(p->zDest, "blob")==0 ){
703 pOut = &p->out;
@@ -943,11 +947,11 @@
943 int i;
944 u32 mFlags = EMAIL_IMMEDIATE_FAIL;
945 const char *zSubject = find_option("subject", "S", 1);
946 const char *zSource = find_option("body", 0, 1);
947 EmailSender *pSender;
948 if( find_option("smtp-trace",0,0)!=0 ) mFlags |= EMAIL_SMTP_TRACE;
949 verify_all_options();
950 blob_init(&prompt, 0, 0);
951 blob_init(&body, 0, 0);
952 blob_init(&hdr, 0, 0);
953 blob_appendf(&hdr,"To: ");
@@ -1954,40 +1958,49 @@
1954 }
1955
1956 /*
1957 ** COMMAND: test-add-alerts
1958 **
1959 ** Usage: %fossil test-add-alerts EVENTID ...
1960 **
1961 ** Add one or more events to the pending_alert queue. Use this
1962 ** command during testing to force email notifications for specific
1963 ** events.
1964 **
1965 ** EVENTIDs are text. The first character is 'c', 'w', or 't'
1966 ** for check-in, wiki, or ticket. The remaining text is a
1967 ** integer that references the EVENT.OBJID value for the event.
1968 ** Run /timeline?showid to see these OBJID values.
 
 
 
 
1969 */
1970 void test_add_alert_cmd(void){
1971 int i;
 
1972 db_find_and_open_repository(0, 0);
1973 verify_all_options();
1974 db_begin_transaction();
1975 email_schema(0);
1976 for(i=2; i<g.argc; i++){
1977 db_multi_exec("REPLACE INTO pending_alert(eventId) VALUES(%Q)", g.argv[i]);
1978 }
1979 db_end_transaction(0);
 
 
 
1980 }
1981
1982 #if INTERFACE
1983 /*
1984 ** Flags for email_send_alerts()
1985 */
1986 #define SENDALERT_DIGEST 0x0001 /* Send a digest */
1987 #define SENDALERT_PRESERVE 0x0002 /* Do not mark the task as done */
1988 #define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */
 
1989
1990 #endif /* INTERFACE */
1991
1992 /*
1993 ** Send alert emails to all subscribers.
@@ -2001,10 +2014,11 @@
2001 const char *zUrl;
2002 const char *zRepoName;
2003 const char *zFrom;
2004 const char *zDest = (flags & SENDALERT_STDOUT) ? "stdout" : 0;
2005 EmailSender *pSender = 0;
 
2006
2007 if( g.fSqlTrace ) fossil_trace("-- BEGIN email_send_alerts(%u)\n", flags);
2008 db_begin_transaction();
2009 if( !email_enabled() ) goto send_alerts_done;
2010 zUrl = db_get("email-url",0);
@@ -2011,11 +2025,14 @@
2011 if( zUrl==0 ) goto send_alerts_done;
2012 zRepoName = db_get("email-subname",0);
2013 if( zRepoName==0 ) goto send_alerts_done;
2014 zFrom = db_get("email-self",0);
2015 if( zFrom==0 ) goto send_alerts_done;
2016 pSender = email_sender_new(zDest, 0);
 
 
 
2017 db_multi_exec(
2018 "DROP TABLE IF EXISTS temp.wantalert;"
2019 "CREATE TEMP TABLE wantalert(eventId TEXT);"
2020 );
2021 if( flags & SENDALERT_DIGEST ){
@@ -2093,12 +2110,16 @@
2093 ** Check to see if any email notifications need to occur, and then
2094 ** do them.
2095 **
2096 ** This routine is called after certain webpages have been run and
2097 ** have already responded.
 
 
 
 
2098 */
2099 void email_auto_exec(void){
2100 int iJulianDay;
2101 if( g.db==0 ) return;
2102 if( db_transaction_nesting_depth()!=0 ){
2103 fossil_warning("Called email_auto_exec() from within transaction "
2104 "started at %z", db_transaction_start_point());
@@ -2105,18 +2126,18 @@
2105 return;
2106 }
2107 if( !email_tables_exist() ) return;
2108 if( !db_get_boolean("email-autoexec",0) ) return;
2109 db_begin_write();
2110 email_send_alerts(0);
2111 iJulianDay = db_int(0, "SELECT julianday('now')");
2112 if( iJulianDay>db_get_int("email-last-digest",0) ){
2113 if( db_transaction_nesting_depth()!=1 ){
2114 fossil_warning("Transaction nesting error prior to digest processing");
2115 }else{
2116 db_set_int("email-last-digest",iJulianDay,0);
2117 email_send_alerts(SENDALERT_DIGEST);
2118 }
2119 }
2120 db_commit_transaction();
2121 }
2122
2123
--- src/email.c
+++ src/email.c
@@ -403,13 +403,14 @@
403 char *zErr; /* Error message */
404 u32 mFlags; /* Flags */
405 int bImmediateFail; /* On any error, call fossil_fatal() */
406 };
407
408 /* Allowed values for mFlags to email_sender_new().
409 */
410 #define EMAIL_IMMEDIATE_FAIL 0x0001 /* Call fossil_fatal() on any error */
411 #define EMAIL_TRACE 0x0002 /* Log sending process on console */
412
413 #endif /* INTERFACE */
414
415 /*
416 ** Shutdown an emailer. Clear all information other than the error message.
@@ -536,11 +537,11 @@
537 }else if( fossil_strcmp(p->zDest, "relay")==0 ){
538 const char *zRelay = 0;
539 emailerGetSetting(p, &zRelay, "email-send-relayhost");
540 if( zRelay ){
541 u32 smtpFlags = SMTP_DIRECT;
542 if( mFlags & EMAIL_TRACE ) smtpFlags |= SMTP_TRACE_STDOUT;
543 p->pSmtp = smtp_session_new(p->zFrom, zRelay, smtpFlags);
544 smtp_client_startup(p->pSmtp);
545 }
546 }
547 return p;
@@ -694,10 +695,13 @@
695 ** not free them.
696 */
697 void email_send(EmailSender *p, Blob *pHdr, Blob *pBody){
698 Blob all, *pOut;
699 u64 r1, r2;
700 if( p->mFlags & EMAIL_TRACE ){
701 fossil_print("Sending email\n");
702 }
703 if( fossil_strcmp(p->zDest, "off")==0 ){
704 return;
705 }
706 if( fossil_strcmp(p->zDest, "blob")==0 ){
707 pOut = &p->out;
@@ -943,11 +947,11 @@
947 int i;
948 u32 mFlags = EMAIL_IMMEDIATE_FAIL;
949 const char *zSubject = find_option("subject", "S", 1);
950 const char *zSource = find_option("body", 0, 1);
951 EmailSender *pSender;
952 if( find_option("smtp-trace",0,0)!=0 ) mFlags |= EMAIL_TRACE;
953 verify_all_options();
954 blob_init(&prompt, 0, 0);
955 blob_init(&body, 0, 0);
956 blob_init(&hdr, 0, 0);
957 blob_appendf(&hdr,"To: ");
@@ -1954,40 +1958,49 @@
1958 }
1959
1960 /*
1961 ** COMMAND: test-add-alerts
1962 **
1963 ** Usage: %fossil test-add-alerts [--autoexec] EVENTID ...
1964 **
1965 ** Add one or more events to the pending_alert queue. Use this
1966 ** command during testing to force email notifications for specific
1967 ** events.
1968 **
1969 ** EVENTIDs are text. The first character is 'c', 'w', or 't'
1970 ** for check-in, wiki, or ticket. The remaining text is a
1971 ** integer that references the EVENT.OBJID value for the event.
1972 ** Run /timeline?showid to see these OBJID values.
1973 **
1974 ** If the --autoexec option is included, then email_auto_exec() is run
1975 ** after all alerts have been added. This will cause the alerts to
1976 ** be sent out with the SENDALERT_TRACE option.
1977 */
1978 void test_add_alert_cmd(void){
1979 int i;
1980 int doAuto = find_option("autoexec",0,0)!=0;
1981 db_find_and_open_repository(0, 0);
1982 verify_all_options();
1983 db_begin_write();
1984 email_schema(0);
1985 for(i=2; i<g.argc; i++){
1986 db_multi_exec("REPLACE INTO pending_alert(eventId) VALUES(%Q)", g.argv[i]);
1987 }
1988 db_end_transaction(0);
1989 if( doAuto ){
1990 email_auto_exec(SENDALERT_TRACE);
1991 }
1992 }
1993
1994 #if INTERFACE
1995 /*
1996 ** Flags for email_send_alerts()
1997 */
1998 #define SENDALERT_DIGEST 0x0001 /* Send a digest */
1999 #define SENDALERT_PRESERVE 0x0002 /* Do not mark the task as done */
2000 #define SENDALERT_STDOUT 0x0004 /* Print emails instead of sending */
2001 #define SENDALERT_TRACE 0x0008 /* Trace operation for debugging */
2002
2003 #endif /* INTERFACE */
2004
2005 /*
2006 ** Send alert emails to all subscribers.
@@ -2001,10 +2014,11 @@
2014 const char *zUrl;
2015 const char *zRepoName;
2016 const char *zFrom;
2017 const char *zDest = (flags & SENDALERT_STDOUT) ? "stdout" : 0;
2018 EmailSender *pSender = 0;
2019 u32 senderFlags = 0;
2020
2021 if( g.fSqlTrace ) fossil_trace("-- BEGIN email_send_alerts(%u)\n", flags);
2022 db_begin_transaction();
2023 if( !email_enabled() ) goto send_alerts_done;
2024 zUrl = db_get("email-url",0);
@@ -2011,11 +2025,14 @@
2025 if( zUrl==0 ) goto send_alerts_done;
2026 zRepoName = db_get("email-subname",0);
2027 if( zRepoName==0 ) goto send_alerts_done;
2028 zFrom = db_get("email-self",0);
2029 if( zFrom==0 ) goto send_alerts_done;
2030 if( flags & SENDALERT_TRACE ){
2031 senderFlags |= EMAIL_TRACE;
2032 }
2033 pSender = email_sender_new(zDest, senderFlags);
2034 db_multi_exec(
2035 "DROP TABLE IF EXISTS temp.wantalert;"
2036 "CREATE TEMP TABLE wantalert(eventId TEXT);"
2037 );
2038 if( flags & SENDALERT_DIGEST ){
@@ -2093,12 +2110,16 @@
2110 ** Check to see if any email notifications need to occur, and then
2111 ** do them.
2112 **
2113 ** This routine is called after certain webpages have been run and
2114 ** have already responded.
2115 **
2116 ** The mFlags option is zero or more of the SENDALERT_* flags. Normally
2117 ** this flag is zero, but the test-set-alert command sets it to
2118 ** SENDALERT_TRACE.
2119 */
2120 void email_auto_exec(u32 mFlags){
2121 int iJulianDay;
2122 if( g.db==0 ) return;
2123 if( db_transaction_nesting_depth()!=0 ){
2124 fossil_warning("Called email_auto_exec() from within transaction "
2125 "started at %z", db_transaction_start_point());
@@ -2105,18 +2126,18 @@
2126 return;
2127 }
2128 if( !email_tables_exist() ) return;
2129 if( !db_get_boolean("email-autoexec",0) ) return;
2130 db_begin_write();
2131 email_send_alerts(mFlags);
2132 iJulianDay = db_int(0, "SELECT julianday('now')");
2133 if( iJulianDay>db_get_int("email-last-digest",0) ){
2134 if( db_transaction_nesting_depth()!=1 ){
2135 fossil_warning("Transaction nesting error prior to digest processing");
2136 }else{
2137 db_set_int("email-last-digest",iJulianDay,0);
2138 email_send_alerts(SENDALERT_DIGEST|mFlags);
2139 }
2140 }
2141 db_commit_transaction();
2142 }
2143
2144
+3 -1
--- src/smtp.c
+++ src/smtp.c
@@ -1093,10 +1093,12 @@
10931093
p->idTranscript = db_last_insert_rowid();
10941094
db_multi_exec(
10951095
"UPDATE emailblob SET enref=%d WHERE emailid=%lld",
10961096
p->nEts, p->idTranscript);
10971097
}
1098
+ smtp_server_send(p, "221-Transcript id %lld nref %d\r\n",
1099
+ p->idTranscript, p->nEts);
10981100
}
10991101
db_bind_int64(&s, ":ets", p->idTranscript);
11001102
db_bind_str(&s, ":etxt", &p->msg);
11011103
db_step(&s);
11021104
db_finalize(&s);
@@ -1283,15 +1285,15 @@
12831285
smtp_server_prepend_header_lines(&x);
12841286
smtp_server_capture_data(&x, z, sizeof(z));
12851287
smtp_server_send(&x, "250 ok\r\n");
12861288
}else
12871289
if( strncmp(z, "QUIT", 4)==0 && fossil_isspace(z[4]) ){
1288
- smtp_server_send(&x, "221 closing connection\r\n");
12891290
smtp_server_route_incoming(&x, 1);
1291
+ smtp_server_send(&x, "221 closing connection\r\n");
12901292
break;
12911293
}else
12921294
{
12931295
smtp_server_send(&x, "500 unknown command\r\n");
12941296
}
12951297
}
12961298
smtp_server_clear(&x, SMTPSRV_CLEAR_ALL);
12971299
}
12981300
--- src/smtp.c
+++ src/smtp.c
@@ -1093,10 +1093,12 @@
1093 p->idTranscript = db_last_insert_rowid();
1094 db_multi_exec(
1095 "UPDATE emailblob SET enref=%d WHERE emailid=%lld",
1096 p->nEts, p->idTranscript);
1097 }
 
 
1098 }
1099 db_bind_int64(&s, ":ets", p->idTranscript);
1100 db_bind_str(&s, ":etxt", &p->msg);
1101 db_step(&s);
1102 db_finalize(&s);
@@ -1283,15 +1285,15 @@
1283 smtp_server_prepend_header_lines(&x);
1284 smtp_server_capture_data(&x, z, sizeof(z));
1285 smtp_server_send(&x, "250 ok\r\n");
1286 }else
1287 if( strncmp(z, "QUIT", 4)==0 && fossil_isspace(z[4]) ){
1288 smtp_server_send(&x, "221 closing connection\r\n");
1289 smtp_server_route_incoming(&x, 1);
 
1290 break;
1291 }else
1292 {
1293 smtp_server_send(&x, "500 unknown command\r\n");
1294 }
1295 }
1296 smtp_server_clear(&x, SMTPSRV_CLEAR_ALL);
1297 }
1298
--- src/smtp.c
+++ src/smtp.c
@@ -1093,10 +1093,12 @@
1093 p->idTranscript = db_last_insert_rowid();
1094 db_multi_exec(
1095 "UPDATE emailblob SET enref=%d WHERE emailid=%lld",
1096 p->nEts, p->idTranscript);
1097 }
1098 smtp_server_send(p, "221-Transcript id %lld nref %d\r\n",
1099 p->idTranscript, p->nEts);
1100 }
1101 db_bind_int64(&s, ":ets", p->idTranscript);
1102 db_bind_str(&s, ":etxt", &p->msg);
1103 db_step(&s);
1104 db_finalize(&s);
@@ -1283,15 +1285,15 @@
1285 smtp_server_prepend_header_lines(&x);
1286 smtp_server_capture_data(&x, z, sizeof(z));
1287 smtp_server_send(&x, "250 ok\r\n");
1288 }else
1289 if( strncmp(z, "QUIT", 4)==0 && fossil_isspace(z[4]) ){
 
1290 smtp_server_route_incoming(&x, 1);
1291 smtp_server_send(&x, "221 closing connection\r\n");
1292 break;
1293 }else
1294 {
1295 smtp_server_send(&x, "500 unknown command\r\n");
1296 }
1297 }
1298 smtp_server_clear(&x, SMTPSRV_CLEAR_ALL);
1299 }
1300
+10 -1
--- src/webmail.c
+++ src/webmail.c
@@ -714,10 +714,11 @@
714714
if( d!=1 ){
715715
@ <input type="submit" name="unread" value="Mark as unread">
716716
}
717717
@ <input type="submit" name="read" value="Mark as read">
718718
}
719
+ @ <button onclick="webmailSelectAll(); return false;">Select All</button>
719720
@ <a href="%s(url_render(&url,0,0,0,0))">refresh</a>
720721
@ </td><td align="right">
721722
if( pg>0 ){
722723
sqlite3_snprintf(sizeof(zPPg), zPPg, "%d", pg-1);
723724
@ <a href="%s(url_render(&url,"pg",zPPg,0,0))">&lt; Newer</a>&nbsp;&nbsp;
@@ -732,11 +733,11 @@
732733
const char *zId = db_column_text(&q,0);
733734
const char *zFrom = db_column_text(&q, 1);
734735
const char *zDate = db_column_text(&q, 2);
735736
const char *zSubject = db_column_text(&q, 4);
736737
@ <tr>
737
- @ <td><input type="checkbox" name="e%s(zId)"></td>
738
+ @ <td><input type="checkbox" class="webmailckbox" name="e%s(zId)"></td>
738739
@ <td>%h(zFrom)</td>
739740
@ <td><a href="%s(url_render(&url,"id",zId,0,0))">%h(zSubject)</a> \
740741
@ %s(zDate)</td>
741742
if( showAll ){
742743
const char *zTo = db_column_text(&q,5);
@@ -746,10 +747,18 @@
746747
}
747748
db_finalize(&q);
748749
@ </table>
749750
@ </form>
750751
style_footer();
752
+ @ <script>
753
+ @ function webmailSelectAll(){
754
+ @ var x = document.getElementsByClassName("webmailckbox");
755
+ @ for(i=0; i<x.length; i++){
756
+ @ x[i].checked = true;
757
+ @ }
758
+ @ }
759
+ @ </script>
751760
db_end_transaction(0);
752761
}
753762
754763
/*
755764
** WEBPAGE: test-emailblob
756765
--- src/webmail.c
+++ src/webmail.c
@@ -714,10 +714,11 @@
714 if( d!=1 ){
715 @ <input type="submit" name="unread" value="Mark as unread">
716 }
717 @ <input type="submit" name="read" value="Mark as read">
718 }
 
719 @ <a href="%s(url_render(&url,0,0,0,0))">refresh</a>
720 @ </td><td align="right">
721 if( pg>0 ){
722 sqlite3_snprintf(sizeof(zPPg), zPPg, "%d", pg-1);
723 @ <a href="%s(url_render(&url,"pg",zPPg,0,0))">&lt; Newer</a>&nbsp;&nbsp;
@@ -732,11 +733,11 @@
732 const char *zId = db_column_text(&q,0);
733 const char *zFrom = db_column_text(&q, 1);
734 const char *zDate = db_column_text(&q, 2);
735 const char *zSubject = db_column_text(&q, 4);
736 @ <tr>
737 @ <td><input type="checkbox" name="e%s(zId)"></td>
738 @ <td>%h(zFrom)</td>
739 @ <td><a href="%s(url_render(&url,"id",zId,0,0))">%h(zSubject)</a> \
740 @ %s(zDate)</td>
741 if( showAll ){
742 const char *zTo = db_column_text(&q,5);
@@ -746,10 +747,18 @@
746 }
747 db_finalize(&q);
748 @ </table>
749 @ </form>
750 style_footer();
 
 
 
 
 
 
 
 
751 db_end_transaction(0);
752 }
753
754 /*
755 ** WEBPAGE: test-emailblob
756
--- src/webmail.c
+++ src/webmail.c
@@ -714,10 +714,11 @@
714 if( d!=1 ){
715 @ <input type="submit" name="unread" value="Mark as unread">
716 }
717 @ <input type="submit" name="read" value="Mark as read">
718 }
719 @ <button onclick="webmailSelectAll(); return false;">Select All</button>
720 @ <a href="%s(url_render(&url,0,0,0,0))">refresh</a>
721 @ </td><td align="right">
722 if( pg>0 ){
723 sqlite3_snprintf(sizeof(zPPg), zPPg, "%d", pg-1);
724 @ <a href="%s(url_render(&url,"pg",zPPg,0,0))">&lt; Newer</a>&nbsp;&nbsp;
@@ -732,11 +733,11 @@
733 const char *zId = db_column_text(&q,0);
734 const char *zFrom = db_column_text(&q, 1);
735 const char *zDate = db_column_text(&q, 2);
736 const char *zSubject = db_column_text(&q, 4);
737 @ <tr>
738 @ <td><input type="checkbox" class="webmailckbox" name="e%s(zId)"></td>
739 @ <td>%h(zFrom)</td>
740 @ <td><a href="%s(url_render(&url,"id",zId,0,0))">%h(zSubject)</a> \
741 @ %s(zDate)</td>
742 if( showAll ){
743 const char *zTo = db_column_text(&q,5);
@@ -746,10 +747,18 @@
747 }
748 db_finalize(&q);
749 @ </table>
750 @ </form>
751 style_footer();
752 @ <script>
753 @ function webmailSelectAll(){
754 @ var x = document.getElementsByClassName("webmailckbox");
755 @ for(i=0; i<x.length; i++){
756 @ x[i].checked = true;
757 @ }
758 @ }
759 @ </script>
760 db_end_transaction(0);
761 }
762
763 /*
764 ** WEBPAGE: test-emailblob
765

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button