diff --git a/src/filter.cpp b/src/filter.cpp index 89e162a7..73de46de 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -265,6 +265,20 @@ const char *Filter::description() { return ret; } +const char *Filter::author() { + const char *ret; +#ifdef WITH_FREI0R + if(backend==FREIOR) { + ret = freior->info.author; + } +#endif + if(backend==FREEFRAME) { + // TODO freeframe has no extentedinfostruct returned!? + ret = "freeframe authors"; + } + return ret; +} + int Filter::get_parameter_type(int i) { int ret; diff --git a/src/filter_js.cpp b/src/filter_js.cpp index 95827b56..edfcc30d 100644 --- a/src/filter_js.cpp +++ b/src/filter_js.cpp @@ -1,9 +1,10 @@ /* FreeJ - New Freior based Filter class - * (c) Copyright 2007 Denis Rojo + * + * (c) Copyright 2007-2010 Denis Roio * * This source code is free software; you can redistribute it and/or * modify it under the terms of the GNU Public License as published - * by the Free Software Foundation; either version 2 of the License, + * by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * * This source code is distributed in the hope that it will be useful, @@ -38,6 +39,8 @@ JSFunctionSpec filter_methods[] = { JSPropertySpec filter_properties[] = { // ro { "parameters", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY, filter_list_parameters, NULL }, + { "description", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY, filter_get_description, NULL }, + { "author", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY, filter_get_author, NULL }, {0} }; @@ -205,7 +208,7 @@ JSP(filter_list_parameters) { FilterDuo *duo = (FilterDuo*)JS_GetPrivate(cx, obj); if(!duo) { - error("%u:%s:%s :: Layer core data is NULL", + error("%u:%s:%s :: Filter core data is NULL", __LINE__,__FILE__,__FUNCTION__); JS_EndRequest(cx); //JS_ClearContextThread(cx); @@ -231,7 +234,50 @@ JSP(filter_list_parameters) { //JS_ClearContextThread(cx); return JS_TRUE; } + +JSP(filter_get_description) { + func("%u:%s:%s",__LINE__,__FILE__,__FUNCTION__); + + JSString *str; + + JS_BeginRequest(cx); + + FilterDuo *duo = (FilterDuo*)JS_GetPrivate(cx, obj); + if(!duo) { error("%u:%s:%s :: Filter core data is NULL", + __LINE__,__FILE__,__FUNCTION__); + JS_EndRequest(cx); + //JS_ClearContextThread(cx); + return JS_FALSE; + } + + str = JS_NewStringCopyZ(cx, duo->proto->description()); + *vp = STRING_TO_JSVAL(str); + JS_EndRequest(cx); + return JS_TRUE; +} + +JSP(filter_get_author) { + func("%u:%s:%s",__LINE__,__FILE__,__FUNCTION__); + + JSString *str; + + JS_BeginRequest(cx); + + FilterDuo *duo = (FilterDuo*)JS_GetPrivate(cx, obj); + if(!duo) { error("%u:%s:%s :: Filter core data is NULL", + __LINE__,__FILE__,__FUNCTION__); + JS_EndRequest(cx); + //JS_ClearContextThread(cx); + return JS_FALSE; + } + + str = JS_NewStringCopyZ(cx, duo->proto->author()); + *vp = STRING_TO_JSVAL(str); + + JS_EndRequest(cx); + return JS_TRUE; +} //////////////////////////////////// /// TODO: diff --git a/src/include/filter.h b/src/include/filter.h index 4e7c16d5..ae20c98e 100644 --- a/src/include/filter.h +++ b/src/include/filter.h @@ -48,6 +48,7 @@ class Filter : public Entry { FilterInstance *apply(Layer *lay); const char *description(); + const char *author(); int get_parameter_type(int i); diff --git a/src/include/jsparser_data.h b/src/include/jsparser_data.h index 0a44752e..05f85db9 100644 --- a/src/include/jsparser_data.h +++ b/src/include/jsparser_data.h @@ -338,7 +338,8 @@ JSP(parameter_get_type); JS(filter_set_parameter); JS(filter_activate); JSP(filter_list_parameters); - +JSP(filter_get_description); +JSP(filter_get_author); //////////////////////////////// // Controller methods