Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 8c198b45 authored by rswindell's avatar rswindell

nodesync/getsmsg/getnmsg all accept an optional clearline argument

parent 0052322b
......@@ -115,7 +115,7 @@ int sbbs_t::getnodedat(uint number, node_t *node, bool lockit)
/* Assumes that getnodedat(node_num,&thisnode,0) was called right before it */
/* is called. */
/****************************************************************************/
void sbbs_t::nodesync()
void sbbs_t::nodesync(bool clearline)
{
char str[256],today[32];
int atr=curatr;
......@@ -162,9 +162,9 @@ void sbbs_t::nodesync()
}
if(!(sys_status&SS_MOFF)) {
if(thisnode.misc&NODE_MSGW)
getsmsg(useron.number); /* getsmsg clears MSGW flag */
getsmsg(useron.number, clearline); /* getsmsg clears MSGW flag */
if(thisnode.misc&NODE_NMSG)
getnmsg(); /* getnmsg clears NMSG flag */
getnmsg(clearline); /* getnmsg clears NMSG flag */
}
}
......@@ -208,7 +208,7 @@ void sbbs_t::nodesync()
/****************************************************************************/
/* Prints short messages waiting for this node, if any... */
/****************************************************************************/
int sbbs_t::getnmsg()
int sbbs_t::getnmsg(bool clearline)
{
char str[MAX_PATH+1], *buf;
int file;
......@@ -248,7 +248,9 @@ int sbbs_t::getnmsg()
close(file);
buf[length]=0;
if(cols)
if(clearline)
this->clearline();
else if(cols)
CRLF;
putmsg(buf,P_NOATCODES);
free(buf);
......@@ -308,9 +310,9 @@ int sbbs_t::getnodeext(uint number, char *ext)
/****************************************************************************/
/* Prints short messages waiting for 'usernumber', if any... */
/* then deletes them. */
/* then truncates the file. */
/****************************************************************************/
int sbbs_t::getsmsg(int usernumber)
int sbbs_t::getsmsg(int usernumber, bool clearline)
{
char str[MAX_PATH+1], *buf;
int file;
......@@ -353,8 +355,11 @@ int sbbs_t::getsmsg(int usernumber)
close(file);
buf[length]=0;
getnodedat(cfg.node_num,&thisnode,0);
if(cols)
CRLF;
if(clearline)
this->clearline();
else
if(cols)
CRLF;
strip_invalid_attr(buf);
putmsg(buf,P_NOATCODES);
free(buf);
......
......@@ -1202,17 +1202,22 @@ js_hangup(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_nodesync(JSContext *cx, uintN argc, jsval *arglist)
{
jsval* argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs;
jsrefcount rc;
JSBool clearline = false;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((sbbs=js_GetPrivate(cx, JS_THIS_OBJECT(cx, arglist)))==NULL)
return(JS_FALSE);
if(argc > 0 && JSVAL_IS_BOOLEAN(argv[0]))
clearline = JSVAL_TO_BOOLEAN(argv[0]);
rc=JS_SUSPENDREQUEST(cx);
sbbs->getnodedat(sbbs->cfg.node_num,&sbbs->thisnode,0);
sbbs->nodesync();
sbbs->nodesync(clearline ? true : false);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
......@@ -2974,16 +2979,21 @@ js_private_chat(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_get_node_message(JSContext *cx, uintN argc, jsval *arglist)
{
jsval* argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs;
jsrefcount rc;
JSBool clearline = false;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((sbbs=js_GetPrivate(cx, JS_THIS_OBJECT(cx, arglist)))==NULL)
return(JS_FALSE);
if(argc > 0 && JSVAL_IS_BOOLEAN(argv[0]))
clearline = JSVAL_TO_BOOLEAN(argv[0]);
rc=JS_SUSPENDREQUEST(cx);
sbbs->getnmsg();
sbbs->getnmsg(clearline ? true : false);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
......@@ -3063,10 +3073,10 @@ js_put_node_message(JSContext *cx, uintN argc, jsval *arglist)
return JS_FALSE;
/* Send the message(s) */
BOOL result = TRUE;
BOOL success = TRUE;
rc=JS_SUSPENDREQUEST(cx);
if(nodenum < 0 ) { /* ALL */
for(int i=1; i<=sbbs->cfg.sys_nodes; i++) {
for(int i=1; i<=sbbs->cfg.sys_nodes && success; i++) {
if(i==sbbs->cfg.node_num)
continue;
sbbs->getnodedat(i, &node, false);
......@@ -3074,21 +3084,23 @@ js_put_node_message(JSContext *cx, uintN argc, jsval *arglist)
|| (sbbs->useron.level >= SYSOP_LEVEL && node.status==NODE_QUIET))
&& (sbbs->useron.level >= SYSOP_LEVEL || !(node.misc&NODE_POFF)))
if(putnmsg(&sbbs->cfg, i, msg) != 0)
result = FALSE;
success = FALSE;
}
if(success) {
sbbs->logline("C", "sent message to all nodes");
sbbs->logline(nulstr, msg);
}
sbbs->logline("C", "sent message to all nodes");
sbbs->logline(nulstr, msg);
} else {
result = putnmsg(&sbbs->cfg, nodenum, msg) == 0;
if(!(node.misc&NODE_ANON))
success = putnmsg(&sbbs->cfg, nodenum, msg) == 0;
if(success && !(node.misc&NODE_ANON))
sbbs->bprintf(sbbs->text[MsgSentToUser],"Message"
,username(&sbbs->cfg,usernumber,tmp), usernumber);
SAFEPRINTF2(str, "sent message to %s on node %d:"
,username(&sbbs->cfg, usernumber, tmp), nodenum);
SAFEPRINTF3(str, "%s message to %s on node %d:"
,success ? "sent" : "FAILED to send", username(&sbbs->cfg, usernumber, tmp), nodenum);
sbbs->logline("C",str);
sbbs->logline(nulstr, msg);
}
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(result));
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(success));
JS_RESUMEREQUEST(cx, rc);
free(msg);
......@@ -3102,6 +3114,7 @@ js_get_telegram(JSContext *cx, uintN argc, jsval *arglist)
sbbs_t* sbbs;
int32 usernumber;
jsrefcount rc;
JSBool clearline = false;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
......@@ -3113,9 +3126,11 @@ js_get_telegram(JSContext *cx, uintN argc, jsval *arglist)
if(!JS_ValueToInt32(cx,argv[0],&usernumber))
return JS_FALSE;
}
if(argc > 1 && JSVAL_IS_BOOLEAN(argv[1]))
clearline = JSVAL_TO_BOOLEAN(argv[1]);
rc=JS_SUSPENDREQUEST(cx);
sbbs->getsmsg(usernumber);
sbbs->getsmsg(usernumber, clearline ? true : false);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
......@@ -3182,8 +3197,8 @@ js_put_telegram(JSContext *cx, uintN argc, jsval *arglist)
int i=0;
while(sbbs->online && i<5) {
char line[256];
sbbs->bprintf("%4s",nulstr);
if(!sbbs->getstr(line, 70, K_WRAP|K_MSG))
sbbs->bputs("\1n: \1h");
if(!sbbs->getstr(line, 70, i < 4 ? (K_WRAP|K_MSG) : (K_MSG)))
break;
sprintf(str,"%4s%s\r\n",nulstr,line);
SAFECAT(buf, str);
......@@ -3206,15 +3221,17 @@ js_put_telegram(JSContext *cx, uintN argc, jsval *arglist)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(putsmsg(&sbbs->cfg,usernumber,msg)==0));
bool success = putsmsg(&sbbs->cfg,usernumber,msg)==0;
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(success));
free(msg);
SAFEPRINTF2(str,"sent telegram to %s #%u"
,username(&sbbs->cfg,usernumber,tmp), usernumber);
SAFEPRINTF3(str,"%s telegram to %s #%u"
,success ? "sent" : "FAILED to send", username(&sbbs->cfg,usernumber,tmp), usernumber);
sbbs->logline("C",str);
if(logbuf[0])
sbbs->logline(nulstr,logbuf);
sbbs->bprintf(sbbs->text[MsgSentToUser], "Telegram", username(&sbbs->cfg,usernumber,tmp), usernumber);
if(success)
sbbs->bprintf(sbbs->text[MsgSentToUser], "Telegram", username(&sbbs->cfg,usernumber,tmp), usernumber);
JS_RESUMEREQUEST(cx, rc);
......@@ -3896,9 +3913,10 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("hangup (disconnect) immediately")
,310
},
{"node_sync", js_nodesync, 0, JSTYPE_ALIAS },
{"nodesync", js_nodesync, 0, JSTYPE_VOID, JSDOCSTR("")
,JSDOCSTR("synchronize with node database, checks for messages, interruption, etc. (AKA node_sync)")
{"node_sync", js_nodesync, 1, JSTYPE_ALIAS },
{"nodesync", js_nodesync, 1, JSTYPE_VOID, JSDOCSTR("[clearline=<i>false</i>]")
,JSDOCSTR("synchronize with node database, checks for messages, interruption, etc. (AKA node_sync), "
"clears the current console line if there's a message to print when <i>clearline</i> is <i>true</i>.")
,310
},
{"auto_msg", js_automsg, 0, JSTYPE_VOID, JSDOCSTR("")
......@@ -4159,7 +4177,7 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("enter private inter-node chat, or local sysop chat (if <i>local</i>=<i>true</i>)")
,310
},
{"get_node_message",js_get_node_message,0, JSTYPE_VOID, JSDOCSTR("")
{"get_node_message",js_get_node_message,1, JSTYPE_VOID, JSDOCSTR("[clearline=<i>false</i>]")
,JSDOCSTR("receive and display an inter-node message")
,310
},
......@@ -4167,7 +4185,7 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("send an inter-node message (specify a <i>node_number</i> value of <tt>-1</tt> for 'all active nodes')")
,31700
},
{"get_telegram", js_get_telegram, 1, JSTYPE_VOID, JSDOCSTR("[user_number=<i>current</i>]")
{"get_telegram", js_get_telegram, 2, JSTYPE_VOID, JSDOCSTR("[user_number=<i>current</i>], [clearline=<i>false</i>]")
,JSDOCSTR("receive and display waiting telegrams for specified (or current) user")
,310
},
......
......@@ -752,13 +752,13 @@ public:
const char* atcode(char* sp, char* str, size_t maxlen);
/* getnode.cpp */
int getsmsg(int usernumber);
int getnmsg(void);
int getsmsg(int usernumber, bool clearline = false);
int getnmsg(bool clearline = false);
int whos_online(bool listself);/* Lists active nodes, returns active nodes */
void nodelist(void);
int getnodeext(uint number, char * str);
int getnodedat(uint number, node_t * node, bool lock);
void nodesync(void);
void nodesync(bool clearline = false);
user_t nodesync_user;
bool nodesync_inside;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment