major change for plugin handle

This commit is contained in:
lxsang
2016-10-29 15:02:16 +02:00
parent ccbf742713
commit 88e284e12b
19 changed files with 89 additions and 11 deletions

View File

@ -29,4 +29,15 @@ void get(int client,const char* method,dictionary rq)
{
}
void handler(int client, const char* method, const char* rqpth, dictionary rq)
{
if(EQU(rqpth,"default"))
{
execute(client,method,rq);
}
else
{
unknow(client);
}
}

View File

@ -128,3 +128,26 @@ void jsonex(int client,const char* method,dictionary rq)
jpeg(client);
__f(client,htdocs("images/ex.jpg"));
}
void handler(int client, const char* method, const char* rqpth, dictionary rq)
{
if(EQU(rqpth,"default"))
{
execute(client,method,rq);
}
else if(EQU(rqpth,"delete"))
{
delete(client,method,rq);
}
else if(EQU(rqpth,"update"))
{
execute(client,method,rq);
}
else if(EQU(rqpth,"jsonex"))
{
execute(client,method,rq);
}
else
{
unknow(client);
}
}

View File

@ -189,4 +189,27 @@ void rmfolder(int c, const char* m, dictionary rq)
void pexit()
{
LOG("Exit file manager,plugins\n");
}
void handler(int client, const char* method, const char* rqpth, dictionary rq)
{
if(EQU(rqpth,"default"))
{
execute(client,method,rq);
}
else if(EQU(rqpth,"add"))
{
add(client,method,rq);
}
else if(EQU(rqpth,"rmfolder"))
{
rmfolder(client,method,rq);
}
else if(EQU(rqpth,"mkfolder"))
{
mkfolder(client,method,rq);
}
else
{
unknow(client);
}
}

Binary file not shown.

View File

@ -138,8 +138,8 @@ void pexit()
{
LOG("%s","EXIT daemon");
}
void execute(int c, const char* m, dictionary d)
void handler(int c, const char* m, const char* rqp, dictionary d)
{
text(c);
__t(c,"This is a system plugin. It cant be acessed from the web");
}
}

View File

@ -250,4 +250,9 @@ char* config_dir()
if (stat(path, &st) == -1)
mkdir(path, 0755);
return path;
}
void unknow(int client)
{
html(client);
__t(client,"404 API not found");
}

View File

@ -59,4 +59,5 @@ sqldb getdb();
void set_cookie(int,dictionary);
/*Default function for plugin*/
void execute(int, const char*,dictionary);
void handler(int, const char*,const char*,dictionary);
void unknow(int);

View File

@ -74,3 +74,18 @@ void install(int c, const char* m, dictionary rq)
__t(c,result,0,"This is not a plugin file");
}
void handler(int client, const char* method, const char* rqpth, dictionary rq)
{
if(EQU(rqpth,"default"))
{
execute(client,method,rq);
}
else if(EQU(rqpth,"install"))
{
install(client,method,rq);
}
else
{
unknow(client);
}
}

Binary file not shown.

View File

@ -37,7 +37,7 @@ int read_buf(int fd, char*buf,int size)
buf[i] = '\0';
return i;
}
void execute(int client, const char* m, dictionary rq)
void handler(int client, const char* m, const char* rqp, dictionary rq)
{
textstream(client);
int filedes[2];