From da51bd3d0b6f95c853c9dda6380deca6b03f81b1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 4 Dec 2024 10:13:28 +1100 Subject: [PATCH] Implemented saving a frame to the message base and frame_import --- load/msgbases.js | 64 +++++++-- load/page.js | 293 ++++++++++++++---------------------------- tools/frame_get.js | 2 +- tools/frame_import.js | 32 +++++ tools/frame_load.js | 42 ------ 5 files changed, 183 insertions(+), 250 deletions(-) create mode 100644 tools/frame_import.js delete mode 100644 tools/frame_load.js 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