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 293b550f authored by rswindell's avatar rswindell

Make the auto-hangup-after-transfer feature disable-able on a per-call basis

(defauls to enabled, for backward compatibility).
Added new autohang args to bbs.send_file() and bbs.receive_file() (default:true)
Added support for "description" argument to bbs.send_file() as well.
parent 54e6060d
...@@ -193,7 +193,7 @@ const char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type) ...@@ -193,7 +193,7 @@ const char* sbbs_t::protcmdline(prot_t* prot, enum XFER_TYPE type)
/* Handles start and stop routines for transfer protocols */ /* Handles start and stop routines for transfer protocols */
/****************************************************************************/ /****************************************************************************/
int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type
,char *fpath, char *fspec, bool cd) ,char *fpath, char *fspec, bool cd, bool autohangup)
{ {
char protlog[256],*p; char protlog[256],*p;
char* cmdline; char* cmdline;
...@@ -204,14 +204,14 @@ int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type ...@@ -204,14 +204,14 @@ int sbbs_t::protocol(prot_t* prot, enum XFER_TYPE type
SAFEPRINTF(protlog,"%sPROTOCOL.LOG",cfg.node_dir); SAFEPRINTF(protlog,"%sPROTOCOL.LOG",cfg.node_dir);
remove(protlog); /* Deletes the protocol log */ remove(protlog); /* Deletes the protocol log */
if(useron.misc&AUTOHANG) autohang=false;
autohang=true; if(autohangup) {
else if(text[HangUpAfterXferQ][0]) if(useron.misc&AUTOHANG)
autohang=yesno(text[HangUpAfterXferQ]); autohang=true;
else else if(text[HangUpAfterXferQ][0])
autohang=false; autohang=yesno(text[HangUpAfterXferQ]);
}
if(sys_status&SS_ABORT || !online) { /* if ctrl-c or hangup */ if(sys_status&SS_ABORT || !online) { /* if ctrl-c or hangup */
autohang=false;
return(-1); return(-1);
} }
bputs(text[StartXferNow]); bputs(text[StartXferNow]);
...@@ -445,7 +445,7 @@ void sbbs_t::seqwait(uint devnum) ...@@ -445,7 +445,7 @@ void sbbs_t::seqwait(uint devnum)
} }
bool sbbs_t::sendfile(char* fname, char prot, const char* desc) bool sbbs_t::sendfile(char* fname, char prot, const char* desc, bool autohang)
{ {
char keys[128]; char keys[128];
char ch; char ch;
...@@ -473,7 +473,7 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc) ...@@ -473,7 +473,7 @@ bool sbbs_t::sendfile(char* fname, char prot, const char* desc)
break; break;
if(i >= cfg.total_prots) if(i >= cfg.total_prots)
return false; return false;
error = protocol(cfg.prot[i],XFER_DOWNLOAD,fname,fname,false); error = protocol(cfg.prot[i], XFER_DOWNLOAD, fname, fname, false, autohang);
if(cfg.prot[i]->misc&PROT_DSZLOG) if(cfg.prot[i]->misc&PROT_DSZLOG)
result = checkdszlog(fname); result = checkdszlog(fname);
else else
......
...@@ -2150,6 +2150,8 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -2150,6 +2150,8 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist); jsval *argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs; sbbs_t* sbbs;
char prot=0; char prot=0;
char* desc=NULL;
bool autohang = true;
char* p; char* p;
jsrefcount rc; jsrefcount rc;
char* cstr; char* cstr;
...@@ -2166,14 +2168,24 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -2166,14 +2168,24 @@ js_sendfile(JSContext *cx, uintN argc, jsval *arglist)
JSVALUE_TO_ASTRING(cx, argv[1], p, 2, NULL); JSVALUE_TO_ASTRING(cx, argv[1], p, 2, NULL);
if(p!=NULL) if(p!=NULL)
prot=*p; prot=*p;
uintN argn = 2;
if(argc > argn && JSVAL_IS_STRING(argv[argn])) {
JSVALUE_TO_MSTRING(cx, argv[argn], desc, NULL);
argn++;
}
if(argc > argn && JSVAL_IS_BOOLEAN(argv[argn])) {
autohang = JSVAL_TO_BOOLEAN(argv[argn]);
argn++;
}
} }
JSVALUE_TO_MSTRING(cx, argv[0], cstr, NULL); JSVALUE_TO_MSTRING(cx, argv[0], cstr, NULL);
if(cstr==NULL) if(cstr==NULL)
return JS_FALSE; return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->sendfile(cstr,prot))); JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->sendfile(cstr, prot, desc, autohang)));
free(cstr); free(cstr);
FREE_AND_NULL(desc);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE); return(JS_TRUE);
...@@ -2185,6 +2197,7 @@ js_recvfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -2185,6 +2197,7 @@ js_recvfile(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist); jsval *argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs; sbbs_t* sbbs;
char prot=0; char prot=0;
bool autohang = true;
char* p; char* p;
char* cstr; char* cstr;
jsrefcount rc; jsrefcount rc;
...@@ -2201,13 +2214,15 @@ js_recvfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -2201,13 +2214,15 @@ js_recvfile(JSContext *cx, uintN argc, jsval *arglist)
JSVALUE_TO_ASTRING(cx, argv[1], p, 2, NULL); JSVALUE_TO_ASTRING(cx, argv[1], p, 2, NULL);
if(p!=NULL) if(p!=NULL)
prot=*p; prot=*p;
if(argc > 2)
autohang = JSVAL_TO_BOOLEAN(argv[2]);
} }
JSVALUE_TO_MSTRING(cx, argv[0], cstr, NULL); JSVALUE_TO_MSTRING(cx, argv[0], cstr, NULL);
if(cstr==NULL) if(cstr==NULL)
return JS_FALSE; return JS_FALSE;
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->recvfile(cstr,prot))); JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->recvfile(cstr, prot, autohang)));
free(cstr); free(cstr);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
...@@ -4152,14 +4167,19 @@ static jsSyncMethodSpec js_bbs_functions[] = { ...@@ -4152,14 +4167,19 @@ static jsSyncMethodSpec js_bbs_functions[] = {
,JSDOCSTR("add file list to batch download queue") ,JSDOCSTR("add file list to batch download queue")
,310 ,310
}, },
{"send_file", js_sendfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,protocol]") {"send_file", js_sendfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,protocol] [,description] [,autohang=true]")
,JSDOCSTR("send specified filename (complete path) to user via user-prompted " ,JSDOCSTR("send specified filename (complete path) to user via user-prompted "
"(or optionally specified) protocol") "(or optionally specified) protocol.<br>"
"The optional <i>description</i> string is used for logging purposes.<br>"
"When <i>autohang=true</i>, disconnect after transfer based on user's default setting."
)
,314 ,314
}, },
{"receive_file", js_recvfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,protocol]") {"receive_file", js_recvfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,protocol] [,autohang=true]")
,JSDOCSTR("received specified filename (complete path) frome user via user-prompted " ,JSDOCSTR("received specified filename (complete path) from user via user-prompted "
"(or optionally specified) protocol") "(or optionally specified) protocol.<br>"
"When <i>autohang=true</i>, disconnect after transfer based on user's default setting."
)
,314 ,314
}, },
{"temp_xfer", js_temp_xfer, 0, JSTYPE_VOID, JSDOCSTR("") {"temp_xfer", js_temp_xfer, 0, JSTYPE_VOID, JSDOCSTR("")
......
...@@ -884,14 +884,14 @@ public: ...@@ -884,14 +884,14 @@ public:
/* download.cpp */ /* download.cpp */
void downloadfile(file_t* f); void downloadfile(file_t* f);
void notdownloaded(ulong size, time_t start, time_t end); void notdownloaded(ulong size, time_t start, time_t end);
int protocol(prot_t* prot, enum XFER_TYPE, char *fpath, char *fspec, bool cd); int protocol(prot_t* prot, enum XFER_TYPE, char *fpath, char *fspec, bool cd, bool autohangup=true);
const char* protcmdline(prot_t* prot, enum XFER_TYPE type); const char* protcmdline(prot_t* prot, enum XFER_TYPE type);
void seqwait(uint devnum); void seqwait(uint devnum);
void autohangup(void); void autohangup(void);
bool checkdszlog(const char*); bool checkdszlog(const char*);
bool checkprotresult(prot_t*, int error, file_t*); bool checkprotresult(prot_t*, int error, file_t*);
bool sendfile(char* fname, char prot=0, const char* description = NULL); bool sendfile(char* fname, char prot=0, const char* description = NULL, bool autohang=true);
bool recvfile(char* fname, char prot=0); bool recvfile(char* fname, char prot=0, bool autohang=true);
/* file.cpp */ /* file.cpp */
void fileinfo(file_t* f); void fileinfo(file_t* f);
......
...@@ -605,7 +605,7 @@ bool sbbs_t::bulkupload(uint dirnum) ...@@ -605,7 +605,7 @@ bool sbbs_t::bulkupload(uint dirnum)
return(false); return(false);
} }
bool sbbs_t::recvfile(char *fname, char prot) bool sbbs_t::recvfile(char *fname, char prot, bool autohang)
{ {
char keys[32]; char keys[32];
char ch; char ch;
...@@ -631,7 +631,7 @@ bool sbbs_t::recvfile(char *fname, char prot) ...@@ -631,7 +631,7 @@ bool sbbs_t::recvfile(char *fname, char prot)
if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client)) if(cfg.prot[i]->mnemonic==ch && chk_ar(cfg.prot[i]->ar,&useron,&client))
break; break;
if(i<cfg.total_prots) { if(i<cfg.total_prots) {
if(protocol(cfg.prot[i],XFER_UPLOAD,fname,fname,true)==0) if(protocol(cfg.prot[i], XFER_UPLOAD, fname, fname, true, autohang)==0)
result=true; result=true;
autohangup(); autohangup();
} }
......
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