diff --git a/load/msgbases.js b/load/msgbases.js index f8fa905..35261b1 100644 --- a/load/msgbases.js +++ b/load/msgbases.js @@ -143,19 +143,27 @@ function MsgArea() { // Get all frames that are tagged Object.defineProperty(this,'frames',{ get: function() { - if (! this.managed) + var msgbase; + var regex = false; + + if (this.code === FRAMES_MSG_BASE) { + msgbase = this.msgbase; + + } else if (this.managed) { + msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase; + regex = this.page_prefix_regex; + + } else return undefined; - var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase; var frames = []; - var regex = this.page_prefix_regex; try { if (msgbase.open()) { var headers = msgbase.get_all_msg_headers(false,false) || []; for (var i in headers) { - if ((! (headers[i].attr&MSG_DELETE)) && headers[i].tags && regex.test(headers[i].tags)) + if ((! (headers[i].attr&MSG_DELETE)) && headers[i].tags && ((! regex) || regex.test(headers[i].tags))) frames.push(headers[i]); } @@ -208,7 +216,8 @@ function MsgArea() { } }); - Object.defineProperty(this,'last_tagged',{ + // Retrieve the last tagged frame + Object.defineProperty(this,'last_tagged_message',{ get: function() { var last_tag = this.frames.sort(function(a,b) { if (a.when_imported_time === b.when_imported_time) @@ -217,6 +226,9 @@ function MsgArea() { return (a.when_imported_time > b.when_imported_time); }).pop(); + if (last_tag === undefined) + return undefined; + var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase; try { @@ -230,7 +242,7 @@ function MsgArea() { } } catch (e) { - log(LOG_ERROR,this.code+' cannot be opened (last_tagged):'+e.message); + log(LOG_ERROR,this.code+' cannot be opened (last_tagged_message):'+e.message); return undefined; } @@ -248,7 +260,7 @@ function MsgArea() { } } catch (e) { - log(LOG_ERROR,this.code+' cannot be opened (last_tagged):'+e.message); + log(LOG_ERROR,this.code+' cannot be opened (last_tagged_message_base):'+e.message); return undefined; } @@ -257,7 +269,7 @@ function MsgArea() { } }) - // Is this area defined for videotex messages + // Is this area defined for ansitex messages Object.defineProperty(this,'managed',{ get: function() { return (this.zone_id !== undefined) && (this.area_id !== undefined); @@ -365,7 +377,7 @@ function MsgArea() { return undefined; var msgbase = this.msgbase; - var last_tag = this.last_tagged; + var last_tag = this.last_tagged_message; var msgs = []; try { @@ -401,6 +413,40 @@ function MsgArea() { } }); + // Get frame content + MsgArea.prototype.getContent = function(id) { + // @todo If this is for a echomail/netmail content, then we need to switch message bases + if (this.code !== FRAMES_MSG_BASE) + return undefined; + + var msgbase = this.msgbase; + + try { + if (msgbase.open()) { + var content = JSON.parse(LZString.decompressFromBase64(msgbase.get_msg_body(false,id,false,false,true,true))); + msgbase.close(); + + var i; + for (var i=0; i