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 e25619bc authored by Deucе's avatar Deucе 👌🏾

Fix removal of non-timer events

js_callback_t was not being properly retreived.
parent d7624e83
Pipeline #1780 passed with stage
in 12 minutes and 54 seconds
......@@ -2209,6 +2209,7 @@ js_clear_console_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
enum js_event_type et;
char operation[16];
size_t slen;
sbbs_t *sbbs;
if (argc != 2) {
JS_ReportError(cx, "console.clearOn() and console.clearOnce() require exactly two parameters");
......@@ -2227,7 +2228,7 @@ js_clear_console_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
return JS_TRUE;
}
return js_clear_event(cx, argc, arglist, et);
return js_clear_event(cx, arglist, &sbbs->js_callback, et, 1);
}
static JSBool
......
......@@ -761,26 +761,16 @@ js_setTimeout(JSContext *cx, uintN argc, jsval *arglist)
}
JSBool
js_clear_event(JSContext *cx, uintN argc, jsval *arglist, enum js_event_type et)
js_clear_event(JSContext *cx, jsval *arglist, js_callback_t *cb, enum js_event_type et, int ididx)
{
jsval *argv=JS_ARGV(cx, arglist);
int32 id;
js_callback_t* cb;
jsval *argv=JS_ARGV(cx, arglist);
struct js_event_list *ev;
struct js_event_list *nev;
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if (argc < 1) {
JS_ReportError(cx, "js.clearTimeout() requires an id");
return JS_FALSE;
}
if (!JS_ValueToInt32(cx, argv[0], &id)) {
if (!JS_ValueToInt32(cx, argv[ididx], &id)) {
return JS_FALSE;
}
if((cb=(js_callback_t*)JS_GetPrivate(cx, obj))==NULL)
return(JS_FALSE);
if (!cb->events_supported) {
JS_ReportError(cx, "events not supported");
return JS_FALSE;
......@@ -803,16 +793,34 @@ js_clear_event(JSContext *cx, uintN argc, jsval *arglist, enum js_event_type et)
return JS_TRUE;
}
static JSBool
js_internal_clear_event(JSContext *cx, uintN argc, jsval *arglist, enum js_event_type et)
{
js_callback_t* cb;
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if (argc < 1) {
JS_ReportError(cx, "js.clearTimeout() requires an id");
return JS_FALSE;
}
if((cb=(js_callback_t*)JS_GetPrivate(cx, obj))==NULL)
return(JS_FALSE);
return js_clear_event(cx, arglist, cb, et, 0);
}
static JSBool
js_clearTimeout(JSContext *cx, uintN argc, jsval *arglist)
{
return js_clear_event(cx, argc, arglist, JS_EVENT_TIMEOUT);
return js_internal_clear_event(cx, argc, arglist, JS_EVENT_TIMEOUT);
}
static JSBool
js_clearInterval(JSContext *cx, uintN argc, jsval *arglist)
{
return js_clear_event(cx, argc, arglist, JS_EVENT_INTERVAL);
return js_internal_clear_event(cx, argc, arglist, JS_EVENT_INTERVAL);
}
static JSBool
......
......@@ -2152,6 +2152,7 @@ js_clear_socket_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
enum js_event_type et;
char operation[16];
size_t slen;
js_callback_t* cb;
if (argc != 2) {
JS_ReportError(cx, "js.clearOn() and js.clearOnce() require exactly two parameters");
......@@ -2176,7 +2177,11 @@ js_clear_socket_event(JSContext *cx, uintN argc, jsval *arglist, BOOL once)
return JS_TRUE;
}
return js_clear_event(cx, argc, arglist, et);
cb = js_get_callback(cx);
if (cb == NULL) {
return JS_FALSE;
}
return js_clear_event(cx, arglist, cb, et, 1);
}
static JSBool
......
......@@ -1382,7 +1382,7 @@ extern "C" {
DLLEXPORT void DLLCALL js_PrepareToExecute(JSContext*, JSObject*, const char *filename, const char* startup_dir, JSObject *);
DLLEXPORT char* DLLCALL js_getstring(JSContext *cx, JSString *str);
DLLEXPORT JSBool js_handle_events(JSContext *cx, js_callback_t *cb, volatile int *terminated);
DLLEXPORT JSBool js_clear_event(JSContext *cx, uintN argc, jsval *arglist, enum js_event_type et);
DLLEXPORT JSBool js_clear_event(JSContext *cx, jsval *arglist, js_callback_t *cb, enum js_event_type et, int ididx);
/* js_system.c */
DLLEXPORT JSObject* DLLCALL js_CreateSystemObject(JSContext* cx, JSObject* parent
......
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