diff --git a/src/sbbs3/exec.cpp b/src/sbbs3/exec.cpp index 5daaabdfb481ba6dab2794c0c299778afc41cbe5..806c49717286f35bc66ed6c73c2e6f66fd214b5e 100644 --- a/src/sbbs3/exec.cpp +++ b/src/sbbs3/exec.cpp @@ -1698,14 +1698,7 @@ int sbbs_t::exec(csi_t *csi) RESTORELINE; return(0); case CS_SELECT_SHELL: - csi->logic=LOGIC_TRUE; - for(i=0;i<cfg.total_shells;i++) - uselect(1,i,"Command Shell",cfg.shell[i]->name,cfg.shell[i]->ar); - if((i=uselect(0,useron.shell,0,0,0))>=0) { - useron.shell=i; - putuserrec(&cfg,useron.number,U_SHELL,8,cfg.shell[i]->code); } - else - csi->logic=LOGIC_FALSE; + csi->logic=select_shell() ? LOGIC_TRUE:LOGIC_FALSE; return(0); case CS_SET_SHELL: csi->logic=LOGIC_TRUE; @@ -1721,15 +1714,7 @@ int sbbs_t::exec(csi_t *csi) return(0); case CS_SELECT_EDITOR: - csi->logic=LOGIC_TRUE; - for(i=0;i<cfg.total_xedits;i++) - uselect(1,i,"External Editor",cfg.xedit[i]->name,cfg.xedit[i]->ar); - if(useron.xedit) useron.xedit--; - if((i=uselect(0,useron.xedit,0,0,0))>=0) { - useron.xedit=i+1; - putuserrec(&cfg,useron.number,U_XEDIT,8,cfg.xedit[i]->code); } - else - csi->logic=LOGIC_FALSE; + csi->logic=select_editor() ? LOGIC_TRUE:LOGIC_FALSE; return(0); case CS_SET_EDITOR: csi->logic=LOGIC_TRUE; @@ -1832,3 +1817,31 @@ int sbbs_t::exec(csi_t *csi) return(0); } } +bool sbbs_t::select_shell(void) +{ + int i; + + for(i=0;i<cfg.total_shells;i++) + uselect(1,i,"Command Shell",cfg.shell[i]->name,cfg.shell[i]->ar); + if((i=uselect(0,useron.shell,0,0,0))>=0) { + useron.shell=i; + putuserrec(&cfg,useron.number,U_SHELL,8,cfg.shell[i]->code); + return(true); + } + return(false); +} + +bool sbbs_t::select_editor(void) +{ + int i; + + for(i=0;i<cfg.total_xedits;i++) + uselect(1,i,"External Editor",cfg.xedit[i]->name,cfg.xedit[i]->ar); + if(useron.xedit) useron.xedit--; + if((i=uselect(0,useron.xedit,0,0,0))>=0) { + useron.xedit=i+1; + putuserrec(&cfg,useron.number,U_XEDIT,8,cfg.xedit[i]->code); + return(true); + } + return(false); +} \ No newline at end of file diff --git a/src/sbbs3/js_bbs.cpp b/src/sbbs3/js_bbs.cpp index cb651803c04decf8eb18fb4ac5963bd13a1d98c7..83fee562d630f424fe27192fe2828e70aaf93690 100644 --- a/src/sbbs3/js_bbs.cpp +++ b/src/sbbs3/js_bbs.cpp @@ -2437,6 +2437,30 @@ js_getnstime(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return(JS_TRUE); } +static JSBool +js_select_shell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + sbbs_t* sbbs; + + if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL) + return(JS_FALSE); + + *rval = BOOLEAN_TO_JSVAL(sbbs->select_shell()); + return(JS_TRUE); +} + +static JSBool +js_select_editor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + sbbs_t* sbbs; + + if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL) + return(JS_FALSE); + + *rval = BOOLEAN_TO_JSVAL(sbbs->select_editor()); + return(JS_TRUE); +} + static jsMethodSpec js_bbs_functions[] = { {"atcode", js_atcode, 1, JSTYPE_STRING, JSDOCSTR("string code") ,JSDOCSTR("return @-code value") @@ -2676,6 +2700,12 @@ static jsMethodSpec js_bbs_functions[] = { {"get_newscantime", js_getnstime, 1, JSTYPE_NUMBER, JSDOCSTR("number time") ,JSDOCSTR("get newscan time, returns new newscan time value (time_t)") }, + {"select_shell", js_select_shell, 0, JSTYPE_BOOLEAN, "" + ,JSDOCSTR("allows user to select a new command shell") + }, + {"select_editor", js_select_editor, 0, JSTYPE_BOOLEAN, "" + ,JSDOCSTR("allows user to select a new external message editor") + }, {0} }; diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 9dddb8846334df17e16deab88a991e40514142ce..9295f665026bb2148ca1ca16af74d495a8e222bd 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -361,6 +361,9 @@ public: bool ftp_get(csi_t* csi, SOCKET ctrl_sock, char* src, char* dest, bool dir=false); SOCKET ftp_data_sock(csi_t* csi, SOCKET ctrl_sock, SOCKADDR_IN*); + bool select_shell(void); + bool select_editor(void); + void sys_info(void); void user_info(void); void xfer_policy(void);