Skip to content

Commit

Permalink
Working on #222; making some progress, not debugged
Browse files Browse the repository at this point in the history
  • Loading branch information
dgets committed Aug 14, 2015
1 parent 3235fc2 commit 44d946b
Showing 1 changed file with 48 additions and 29 deletions.
77 changes: 48 additions & 29 deletions load/dmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ uMail = {
++i) {*/
for (var i = 0; i < mmBase.total_msgs; i++) {
if (userSettings.debug.message_scan) {
console.putmsg(red + i + " ");
console.putmsg(red + (i + 1) + " ");
}

try {
Expand All @@ -54,7 +54,7 @@ uMail = {
if ((mHdr.to_ext == user.number) ||
(mHdr.from_ext == user.number)) {
if (userSettings.debug.message_scan) {
console.putmsg("Pushing " + i + " to list\n");
console.putmsg("Pushing " + (i + 1) + " to list\n");
}
applicableMailList.push(i);
}
Expand All @@ -68,6 +68,39 @@ uMail = {
}

return applicableMailList;
},
getCurMailScanPtr : function(ptrArray, mmBase) {
var mHdr;

if (userSettings.debug.message_scan) {
console.putmsg(blue + high_intensity +
"Entered getCurMailScanPtr()\n");
}

for each (var cPtr in ptrArray) {
try {
mHdr = mmBase.get_msg_header(true, cPtr, true);
} catch (e) {
console.putmsg(magenta + "Unable to obtain header: " + cPtr +
"\n");
throw new docIface.dDocException("getCurMailScanPtr() Exception",
"Unable to obtain header: " + cPtr + " Msg: " + e.message , 1);
}

if (!(mHdr.attr & MSG_READ)) {
if (userSettings.debug.message_scan) {
console.putmsg(blue + "Found unread message @ " + cPtr +
"\n");
}
return ptrArray.indexOf(cPtr);
}
}

if (userSettings.debug.message_scan) {
console.putmsg(blue + "Found no unread messages\n");
}

return null;
},
/*
* summary:
Expand All @@ -84,8 +117,8 @@ uMail = {
*/
readMail : function() {
var mmBase = new MsgBase("mail");
var fuggit = false, displayed = true, increment = 1, mNdx = 0;
var uChoice, mHdr, mBody, mailList;
var fuggit = false, displayed = true, increment = 1;
var uChoice, mHdr, mBody, mailList, mNdx;

try {
mmBase.open();
Expand All @@ -101,24 +134,12 @@ uMail = {
//so that mess should have gotten us the current message index scan
//pointer (or pseudo-version thereof); now we can start
mailList = this.getMailScanPtr(mmBase);

/* if (((mNdx = msg_area.sub["mail"].scan_ptr) < 0) ||
(mNdx > mmBase.last_msg)) {
if (userSettings.debug.message_scan) {
console.putmsg(green + "Dbg:\t" + high_intensity +
"mNdx being reset to 0\n");
}
if ((mNdx = this.getCurMailScanPtr(mailList, mmBase)) == null) {
mNdx = 0;
}
if ((mailList.findIndex(mNdx)) == -1) {
if (userSettings.debug.message_scan) {
console.putmsg(cyan + "Dbg:\t" + high_intensity +
"mNdx being reset to 0 (at 2nd opportunity)\n");
console.putmsg(magenta + high_intensity + "No unread found\n");
}
mNdx = 0; //we should have a better way to find a closer message
//to whatever they wanted, but not today
} */
}

console.putmsg(yellow + high_intensity + "Mail> ");

Expand Down Expand Up @@ -206,16 +227,14 @@ uMail = {
}

//if (breaks) {
console.putmsg(fHdr + mBody, P_WORDWRAP); // add fHdr into
// putmsg here so it gets included in the line count for
// breaks
/*} else {
if (userSettings.debug.message_scan) {
console.putmsg("Putting out message next:\n");
}
console.putmsg(fHdr + mBody, (P_NOPAUSE | P_WORDWRAP));
} */
console.putmsg(fHdr + mBody, P_WORDWRAP); // add fHdr into
// putmsg here so it gets included in the line count for
// breaks

//mark the message read
mHdr.attr |= MSG_READ;
mmBase.put_msg_header(mailList[mNdx], mHdr);


//display prompt
msg_base.doMprompt(mmBase, mNdx);
Expand Down

0 comments on commit 44d946b

Please sign in to comment.