Skip to content
Snippets Groups Projects
Commit 9a83d624 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Do the SMB msghdr netattr MSG_* -> NETMSG_* conversion dance

Sorry Nightfox, this might break your scripts
parent b121ab99
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
......@@ -143,7 +143,7 @@ function sendfiles()
, to_net_type: NET_INTERNET
, to_net_addr: address
, attr: MSG_NOREPLY // Suppress bounce messages
, netattr: MSG_KILLSENT
, netattr: NETMSG_KILLSENT
, auxattr: MSG_FILEATTACH
};
var msgbody = format(options.msgbody || "Your requested file (%u of %u) is attached." +
......
......@@ -1033,31 +1033,31 @@ function parse_flags(inflags)
break;
case 'LOCAL':
flags.netattr |= MSG_LOCAL;
flags.netattr |= NETMSG_LOCAL;
break;
case 'INTRANSIT':
flags.netattr |= MSG_INTRANSIT;
flags.netattr |= NETMSG_INTRANSIT;
break;
case 'SENT':
flags.netattr |= MSG_SENT;
flags.netattr |= NETMSG_SENT;
break;
case 'KILLSENT':
flags.netattr |= MSG_KILLSENT;
flags.netattr |= NETMSG_KILLSENT;
break;
case 'ARCHIVESENT':
flags.netattr |= MSG_ARCHIVESENT;
flags.netattr |= NETMSG_ARCHIVESENT;
break;
case 'HOLD':
flags.netattr |= MSG_HOLD;
flags.netattr |= NETMSG_HOLD;
break;
case 'CRASH':
flags.netattr |= MSG_CRASH;
flags.netattr |= NETMSG_CRASH;
break;
case 'IMMEDIATE':
flags.netattr |= MSG_IMMEDIATE;
flags.netattr |= NETMSG_IMMEDIATE;
break;
case 'DIRECT':
flags.netattr |= MSG_DIRECT;
flags.netattr |= NETMSG_DIRECT;
break;
}
}
......@@ -1123,21 +1123,21 @@ function calc_msgflags(attr, netattr, num, msg, readonly)
if(attr & MSG_NOREPLY)
flags += "NOREPLY ";
if(netattr & MSG_INTRANSIT)
if(netattr & NETMSG_INTRANSIT)
flags += "INTRANSIT ";
if(netattr & MSG_SENT)
if(netattr & NETMSG_SENT)
flags += "SENT ";
if(netattr & MSG_KILLSENT)
if(netattr & NETMSG_KILLSENT)
flags += "KILLSENT ";
if(netattr & MSG_ARCHIVESENT)
if(netattr & NETMSG_ARCHIVESENT)
flags += "ARCHIVESENT ";
if(netattr & MSG_HOLD)
if(netattr & NETMSG_HOLD)
flags += "HOLD ";
if(netattr & MSG_CRASH)
if(netattr & NETMSG_CRASH)
flags += "CRASH ";
if(netattr & MSG_IMMEDIATE)
if(netattr & NETMSG_IMMEDIATE)
flags += "IMMEDIATE ";
if(netattr & MSG_DIRECT)
if(netattr & NETMSG_DIRECT)
flags += "DIRECT ";
if(attr==0xffff || orig_ptrs[num] < msg) {
......
......@@ -80,15 +80,15 @@ const POLL_RESULTS_SHIFT = 30;
/* Message network attributes */
const MSG_LOCAL = (1<<0); // Msg created locally
const MSG_INTRANSIT = (1<<1); // Msg is in-transit
const MSG_SENT = (1<<2); // Sent to remote
const MSG_KILLSENT = (1<<3); // Kill when sent
const MSG_ARCHIVESENT = (1<<4); // Archive when sent
const MSG_HOLD = (1<<5); // Hold for pick-up
const MSG_CRASH = (1<<6); // Crash
const MSG_IMMEDIATE = (1<<7); // Send Msg now, ignore restrictions
const MSG_DIRECT = (1<<8); // Send directly to destination
const NETMSG_LOCAL = (1<<0); // Msg created locally
const NETMSG_INTRANSIT = (1<<1); // Msg is in-transit
const NETMSG_SENT = (1<<2); // Sent to remote
const NETMSG_KILLSENT = (1<<3); // Kill when sent
const NETMSG_ARCHIVESENT = (1<<4); // Archive when sent
const NETMSG_HOLD = (1<<5); // Hold for pick-up
const NETMSG_CRASH = (1<<6); // Crash
const NETMSG_IMMEDIATE = (1<<7); // Send Msg now, ignore restrictions
const NETMSG_DIRECT = (1<<8); // Send directly to destination
/* Net types */
const NET_NONE = 0; // Local message
......
......@@ -713,14 +713,14 @@ function mail_reply(msg, reply_all)
return success;
}
function download_msg(msg, plain_text)
function download_msg(msg, msgbase, plain_text)
{
var fname = system.temp_dir + "msg_" + msg.number + ".txt";
var f = new File(fname);
if(!f.open("wb"))
return false;
var text = msgbase.get_msg_body(msg
,/* strip ctrl-a */false
,/* strip ctrl-a */plain_text
,/* dot-stuffing */false
,/* tails */true
,plain_text);
......@@ -731,6 +731,30 @@ function download_msg(msg, plain_text)
return bbs.send_file(fname);
}
function download_thread(thread_id, msgbase, plain_text)
{
var fname = system.temp_dir + "thread_" + thread_id + ".txt";
var f = new File(fname);
if(!f.open("wb"))
return false;
const total_msgs = msgbase.total_msgs;
for (var i = 0; i < total_msgs; ++i) {
var msg = msgbase.get_msg_header(true, i);
if (msg == null || msg.thread_id !== thread_id)
continue;
var text = msgbase.get_msg_body(msg
,/* strip ctrl-a */plain_text
,/* dot-stuffing */false
,/* tails */true
,plain_text);
f.write(msg.get_rfc822_header(/* force_update: */false, /* unfold: */false
,/* default_content_type */!plain_text));
f.writeln(text);
}
f.close();
return bbs.send_file(fname);
}
function content_description(msg)
{
var desc = [];
......@@ -1132,7 +1156,11 @@ function list_msgs(msgbase, list, current, preview, grp_name, sub_name)
break;
case 'D':
console.clearline();
if(!console.noyes("Download message", P_NOCRLF)) {
if(list[current].thread_id && !console.noyes("Download thread", P_NOCRLF)) {
if(!download_thread(list[current].thread_id, msgbase, console.yesno("Plain-text only")))
alert("failed");
}
else if(!console.noyes("Download message", P_NOCRLF)) {
if(!download_msg(list[current], msgbase, console.yesno("Plain-text only")))
alert("failed");
}
......@@ -1489,9 +1517,9 @@ function msg_attributes(msg, msgbase, short)
if(msg.attr&MSG_VALIDATED) result.push(options.attr_valid || "Valid"), str += 'V';
if(msg.attr&MSG_PRIVATE) result.push(options.attr_private || "Priv"), str += 'p';
if(msg.attr&MSG_POLL) result.push(options.attr_poll || "Poll"), str += '?';
if(msg.netattr&MSG_SENT) result.push(options.attr_sent || "Sent"), str += 's';
if(msg.netattr&MSG_KILLSENT) result.push(options.attr_sent || "KS"), str += 'k';
if(msg.netattr&MSG_INTRANSIT) result.push(options.attr_intransit || "InTransit"), str += 'T';
if(msg.netattr&NETMSG_SENT) result.push(options.attr_sent || "Sent"), str += 's';
if(msg.netattr&NETMSG_KILLSENT) result.push(options.attr_sent || "KS"), str += 'k';
if(msg.netattr&NETMSG_INTRANSIT) result.push(options.attr_intransit || "InTransit"), str += 'T';
/*
if(sub_op(subnum) && msg->hdr.attr&MSG_ANONYMOUS) return 'A';
*/
......
......@@ -16,8 +16,8 @@ for(i=0;i<total_msgs;i++) {
/* offset: */ i,
/* expand_fields: */ false);
printf("#%lu from: %-30s %08lx\r\n",hdr.number,hdr.from,hdr.netattr);
if(hdr && hdr.netattr&MSG_INTRANSIT) {
hdr.netattr&=~MSG_INTRANSIT;
if(hdr && hdr.netattr&NETMSG_INTRANSIT) {
hdr.netattr&=~NETMSG_INTRANSIT;
printf("Removing in-transit attribute from message #%lu\r\n",hdr.number);
if(!mail.put_msg_header(true,i,hdr))
alert(mail.last_error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment