...
 
Commits (1)
  • Rob Swindell's avatar
    Store client terminal information in node#/terminal.ini · ff449a11
    Rob Swindell authored
    In preparation for node-spy applications that can support multiple terminal sizes/types (none exist yet). The file is updated whenever there is new/updated information about the client's terminal.
    
    Exposed as JS method: console.term_updated().
    ff449a11
......@@ -388,6 +388,7 @@ bool sbbs_t::answer()
else
SAFECOPY(terminal,"DUMB");
}
update_nodeterm();
/* AutoLogon via IP or Caller ID here */
if(!useron.number && !(sys_status&SS_RLOGIN)
......
......@@ -556,6 +556,32 @@ const char* sbbs_t::term_charset(long term)
return "CP437";
}
/****************************************************************************/
/* For node spying purposes */
/****************************************************************************/
bool sbbs_t::update_nodeterm(void)
{
str_list_t ini = strListInit();
iniSetInteger(&ini, ROOT_SECTION, "cols", cols, NULL);
iniSetInteger(&ini, ROOT_SECTION, "rows", rows, NULL);
iniSetString(&ini, ROOT_SECTION, "type", term_type(), NULL);
iniSetString(&ini, ROOT_SECTION, "chars", term_charset(), NULL);
iniSetHexInt(&ini, ROOT_SECTION, "flags", term_supports(), NULL);
iniSetHexInt(&ini, ROOT_SECTION, "mouse", mouse_mode, NULL);
iniSetHexInt(&ini, ROOT_SECTION, "console", console, NULL);
char path[MAX_PATH + 1];
SAFEPRINTF(path, "%sterminal.ini", cfg.node_dir);
FILE* fp = iniOpenFile(path, /* create: */TRUE);
bool result = false;
if(fp != NULL) {
result = iniWriteFile(fp, ini);
iniCloseFile(fp);
}
strListFree(&ini);
return result;
}
/****************************************************************************/
/* Outputs character */
/* Performs terminal translations (e.g. EXASCII-to-ASCII, FF->ESC[2J) */
......
......@@ -542,6 +542,8 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
/* Sanity check the coordinates in the response: */
if(useron.cols == TERM_COLS_AUTO && x >= TERM_COLS_MIN && x <= TERM_COLS_MAX) cols=x;
if(useron.rows == TERM_ROWS_AUTO && y >= TERM_ROWS_MIN && y <= TERM_ROWS_MAX) rows=y;
if(useron.cols == TERM_COLS_AUTO || useron.rows == TERM_ROWS_AUTO)
update_nodeterm();
}
}
return(0);
......
......@@ -2099,6 +2099,23 @@ js_term_supports(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
static JSBool
js_term_updated(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs;
jsrefcount rc;
if((sbbs=(sbbs_t*)js_GetClassPrivate(cx, JS_THIS_OBJECT(cx, arglist), &js_console_class))==NULL)
return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->update_nodeterm()));
JS_RESUMEREQUEST(cx, rc);
return JS_TRUE;
}
static jsSyncMethodSpec js_console_functions[] = {
{"inkey", js_inkey, 0, JSTYPE_STRING, JSDOCSTR("[mode=<tt>K_NONE</tt>] [,timeout=<tt>0</tt>]")
,JSDOCSTR("get a single key with optional <i>timeout</i> in milliseconds (defaults to 0, for no wait).<br>"
......@@ -2314,6 +2331,10 @@ static jsSyncMethodSpec js_console_functions[] = {
"<i>terminal_flags</i> (numeric bit-field) if no <i>terminal_flags</i> were specified")
,314
},
{"term_updated", js_term_updated, 1, JSTYPE_BOOLEAN, JSDOCSTR("")
,JSDOCSTR("update the node's <tt>terminal.ini</tt> file to match the current terminal settings")
,31802
},
{"backspace", js_backspace, 0, JSTYPE_VOID, JSDOCSTR("[count=<tt>1</tt>]")
,JSDOCSTR("send a destructive backspace sequence")
,315
......
......@@ -220,6 +220,7 @@ bool sbbs_t::logon()
rows = useron.rows;
if(useron.cols != TERM_COLS_AUTO)
cols = useron.cols;
update_nodeterm();
if(tm.tm_mon + 1 == getbirthmonth(&cfg, useron.birth) && tm.tm_mday == getbirthday(&cfg, useron.birth)
&& !(useron.rest&FLAG('Q'))) {
if(text[HappyBirthday][0]) {
......
......@@ -784,6 +784,7 @@ public:
long term_supports(long cmp_flags=0);
const char* term_type(long term_supports = -1);
const char* term_charset(long term_supports = -1);
bool update_nodeterm(void);
int backfill(const char* str, float pct, int full_attr, int empty_attr);
void progress(const char* str, int count, int total, int interval=1);
bool saveline(void);
......@@ -893,7 +894,7 @@ public:
char* parse_login(char*);
/* answer.cpp */
bool answer();
bool answer(void);
/* logon.ccp */
bool logon(void);
......
......@@ -811,6 +811,8 @@ void sbbs_t::maindflts(user_t* user)
if(user->cols != TERM_COLS_AUTO)
cols = user->cols;
bprintf(text[UserDefaultsHdr],user->alias,user->number);
if(user == &useron)
update_nodeterm();
long term = (user == &useron) ? term_supports() : user->misc;
if(term&PETSCII)
safe_snprintf(str,sizeof(str),"%sCBM/PETSCII"
......@@ -1189,7 +1191,7 @@ void sbbs_t::maindflts(user_t* user)
default:
clear_hotspots();
return;
}
}
}
}
......