Let plugins register rendezvous names

This commit is contained in:
Ron Pedde
2006-04-25 23:13:04 +00:00
parent 07857c6eba
commit 1ca265d4c5
6 changed files with 149 additions and 51 deletions

View File

@@ -442,6 +442,9 @@ int main(int argc, char *argv[]) {
iface = conf_alloc_string("general","interface","");
rend_register(servername,"_daap._tcp",ws_config.port,iface,txtrecord);
rend_register(servername,"_http._tcp",ws_config.port,iface,txtrecord);
plugin_rend_register(servername,ws_config.port,iface);
free(servername);
free(iface);
}

View File

@@ -37,6 +37,7 @@
#include "err.h"
#include "os.h"
#include "plugin.h"
#include "rend.h"
#include "smart-parser.h"
#include "xml-rpc.h"
#include "webserver.h"
@@ -47,6 +48,7 @@ typedef struct tag_pluginentry {
char *versionstring;
regex_t regex;
void *functions;
PLUGIN_REND_INFO **rend_info;
struct tag_pluginentry *next;
} PLUGIN_ENTRY;
@@ -236,6 +238,7 @@ int plugin_load(char **pe, char *path) {
}
}
ppi->functions = pinfo->handler_functions;
ppi->rend_info = pinfo->rend_info;
DPRINTF(E_INF,L_PLUG,"Loaded plugin %s (%s)\n",path,ppi->versionstring);
pinfo->pi = (void*)π
@@ -305,8 +308,8 @@ void plugin_url_handle(WS_CONNINFO *pwsc) {
_plugin_unlock();
return;
}
ppi = ppi->next;
}
ppi = ppi->next;
}
/* should 500 here or something */
@@ -315,6 +318,35 @@ void plugin_url_handle(WS_CONNINFO *pwsc) {
return;
}
/**
* walk through the plugins and register whatever rendezvous
* names the clients want
*/
int plugin_rend_register(char *name, int port, char *iface) {
PLUGIN_ENTRY *ppi;
PLUGIN_REND_INFO *pri;
_plugin_readlock();
ppi = _plugin_list.next;
while(ppi) {
DPRINTF(E_DBG,L_PLUG,"Checking %s\n",ppi->versionstring);
if(ppi->rend_info) {
pri = *(ppi->rend_info);
while(pri->type) {
DPRINTF(E_DBG,L_PLUG,"Registering %s\n",pri->type);
rend_register(name,pri->type,port,iface,pri->txt);
pri++;
}
}
ppi=ppi->next;
}
_plugin_unlock();
return TRUE;
}
/**
* Test password for the handled namespace
*
@@ -348,8 +380,8 @@ int plugin_auth_handle(WS_CONNINFO *pwsc, char *username, char *pw) {
return TRUE;
}
}
ppi = ppi->next;
}
ppi = ppi->next;
}
/* should 500 here or something */

View File

@@ -33,6 +33,8 @@ extern int plugin_deinit(void);
extern int plugin_url_candispatch(WS_CONNINFO *pwsc);
extern void plugin_url_handle(WS_CONNINFO *pwsc);
extern int plugin_auth_handle(WS_CONNINFO *pwsc, char *username, char *pw);
extern int plugin_rend_register(char *name, int port, char *iface);
#define PLUGIN_E_SUCCESS 0
#define PLUGIN_E_NOLOAD 1
@@ -52,6 +54,11 @@ typedef struct tag_plugin_output_fn {
} PLUGIN_OUTPUT_FN;
/* version 1 plugin info */
typedef struct tag_plugin_rend_info {
char *type;
char *txt;
} PLUGIN_REND_INFO;
typedef struct tag_plugin_info {
int version;
int type;
@@ -59,6 +66,7 @@ typedef struct tag_plugin_info {
char *url; /* for output plugins */
void *handler_functions;
void *pi; /* exported functions */
PLUGIN_REND_INFO **rend_info;
} PLUGIN_INFO;
/* version 1 plugin imports */

View File

@@ -23,6 +23,11 @@ typedef struct tag_plugin_output_fn {
int(*auth)(WS_CONNINFO *pwsc, char *username, char *pw);
} PLUGIN_OUTPUT_FN;
typedef struct tag_plugin_rend_info {
char *type;
char *txt;
} PLUGIN_REND_INFO;
typedef struct tag_plugin_info {
int version;
int type;
@@ -30,6 +35,7 @@ typedef struct tag_plugin_info {
char *url; /* regex of namespace to handle if OUTPUT type */
void *handler_functions;
void *fn; /* input functions*/
PLUGIN_REND_INFO **rend_info;
} PLUGIN_INFO;
/* xml helpers for output plugins */