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",""); iface = conf_alloc_string("general","interface","");
rend_register(servername,"_daap._tcp",ws_config.port,iface,txtrecord); rend_register(servername,"_daap._tcp",ws_config.port,iface,txtrecord);
rend_register(servername,"_http._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(servername);
free(iface); free(iface);
} }

View File

@ -37,6 +37,7 @@
#include "err.h" #include "err.h"
#include "os.h" #include "os.h"
#include "plugin.h" #include "plugin.h"
#include "rend.h"
#include "smart-parser.h" #include "smart-parser.h"
#include "xml-rpc.h" #include "xml-rpc.h"
#include "webserver.h" #include "webserver.h"
@ -47,6 +48,7 @@ typedef struct tag_pluginentry {
char *versionstring; char *versionstring;
regex_t regex; regex_t regex;
void *functions; void *functions;
PLUGIN_REND_INFO **rend_info;
struct tag_pluginentry *next; struct tag_pluginentry *next;
} PLUGIN_ENTRY; } PLUGIN_ENTRY;
@ -236,6 +238,7 @@ int plugin_load(char **pe, char *path) {
} }
} }
ppi->functions = pinfo->handler_functions; ppi->functions = pinfo->handler_functions;
ppi->rend_info = pinfo->rend_info;
DPRINTF(E_INF,L_PLUG,"Loaded plugin %s (%s)\n",path,ppi->versionstring); DPRINTF(E_INF,L_PLUG,"Loaded plugin %s (%s)\n",path,ppi->versionstring);
pinfo->pi = (void*)π pinfo->pi = (void*)π
@ -305,8 +308,8 @@ void plugin_url_handle(WS_CONNINFO *pwsc) {
_plugin_unlock(); _plugin_unlock();
return; return;
} }
ppi = ppi->next;
} }
ppi = ppi->next;
} }
/* should 500 here or something */ /* should 500 here or something */
@ -315,6 +318,35 @@ void plugin_url_handle(WS_CONNINFO *pwsc) {
return; 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 * Test password for the handled namespace
* *
@ -348,8 +380,8 @@ int plugin_auth_handle(WS_CONNINFO *pwsc, char *username, char *pw) {
return TRUE; return TRUE;
} }
} }
ppi = ppi->next;
} }
ppi = ppi->next;
} }
/* should 500 here or something */ /* 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 int plugin_url_candispatch(WS_CONNINFO *pwsc);
extern void plugin_url_handle(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_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_SUCCESS 0
#define PLUGIN_E_NOLOAD 1 #define PLUGIN_E_NOLOAD 1
@ -52,6 +54,11 @@ typedef struct tag_plugin_output_fn {
} PLUGIN_OUTPUT_FN; } PLUGIN_OUTPUT_FN;
/* version 1 plugin info */ /* version 1 plugin info */
typedef struct tag_plugin_rend_info {
char *type;
char *txt;
} PLUGIN_REND_INFO;
typedef struct tag_plugin_info { typedef struct tag_plugin_info {
int version; int version;
int type; int type;
@ -59,6 +66,7 @@ typedef struct tag_plugin_info {
char *url; /* for output plugins */ char *url; /* for output plugins */
void *handler_functions; void *handler_functions;
void *pi; /* exported functions */ void *pi; /* exported functions */
PLUGIN_REND_INFO **rend_info;
} PLUGIN_INFO; } PLUGIN_INFO;
/* version 1 plugin imports */ /* 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); int(*auth)(WS_CONNINFO *pwsc, char *username, char *pw);
} PLUGIN_OUTPUT_FN; } PLUGIN_OUTPUT_FN;
typedef struct tag_plugin_rend_info {
char *type;
char *txt;
} PLUGIN_REND_INFO;
typedef struct tag_plugin_info { typedef struct tag_plugin_info {
int version; int version;
int type; int type;
@ -30,6 +35,7 @@ typedef struct tag_plugin_info {
char *url; /* regex of namespace to handle if OUTPUT type */ char *url; /* regex of namespace to handle if OUTPUT type */
void *handler_functions; void *handler_functions;
void *fn; /* input functions*/ void *fn; /* input functions*/
PLUGIN_REND_INFO **rend_info;
} PLUGIN_INFO; } PLUGIN_INFO;
/* xml helpers for output plugins */ /* xml helpers for output plugins */

View File

@ -254,6 +254,9 @@
<File <File
RelativePath="..\src\os.h"> RelativePath="..\src\os.h">
</File> </File>
<File
RelativePath="..\src\plugin.h">
</File>
<File <File
RelativePath="..\src\rend.h"> RelativePath="..\src\rend.h">
</File> </File>

View File

@ -57,6 +57,10 @@ InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show ShowInstDetails show
ShowUnInstDetails show ShowUnInstDetails show
!define PROJROOT "..\..\.."
!define MTD_SOURCE "${PROJROOT}\mt-daapd\win32\Release"
!define DLL_SOURCE "${PROJROOT}\win32\dll"
!define ADMIN_ROOT "${PROJROOT}\mt-daapd\admin-root"
Section -Pre Section -Pre
nsSCM::QueryStatus "Bonjour Service" nsSCM::QueryStatus "Bonjour Service"
@ -73,61 +77,61 @@ SectionEnd
Section "MainSection" SEC01 Section "MainSection" SEC01
SetOutPath "$2" SetOutPath "$2"
SetOverwrite ifnewer SetOverwrite ifnewer
File "..\Release\mt-daapd.exe" File "${MTD_SOURCE}\mt-daapd.exe"
File "..\..\..\win32\dll\gnu_regex.dll" File "${DLL_SOURCE}\gnu_regex.dll"
File "..\..\..\win32\dll\pthreadVC2.dll" File "${DLL_SOURCE}\pthreadVC2.dll"
File "..\..\..\win32\dll\sqlite.dll" File "${DLL_SOURCE}\sqlite.dll"
File "..\..\..\win32\dll\sqlite3.dll" File "${DLL_SOURCE}\sqlite3.dll"
File "..\..\..\win32\dll\zlib.dll" File "${DLL_SOURCE}\zlib1.dll"
SetOutPath "$2\admin-root" SetOutPath "$2\admin-root"
File "..\..\admin-root\thanks.html" File "${ADMIN_ROOT}\thanks.html"
File "..\..\admin-root\status.html" File "${ADMIN_ROOT}\status.html"
File "..\..\admin-root\smartpopup.html" File "${ADMIN_ROOT}\smartpopup.html"
File "..\..\admin-root\smart.js" File "${ADMIN_ROOT}\smart.js"
File "..\..\admin-root\smart.html" File "${ADMIN_ROOT}\smart.html"
File "..\..\admin-root\required.gif" File "${ADMIN_ROOT}\required.gif"
File "..\..\admin-root\playlist.js" File "${ADMIN_ROOT}\playlist.js"
File "..\..\admin-root\playlist.html" File "${ADMIN_ROOT}\playlist.html"
File "..\..\admin-root\mt-daapd.png" File "${ADMIN_ROOT}\mt-daapd.png"
File "..\..\admin-root\mt-daapd.js" File "${ADMIN_ROOT}\mt-daapd.js"
File "..\..\admin-root\mt-daapd.css" File "${ADMIN_ROOT}\mt-daapd.css"
File "..\..\admin-root\linkTransparent.gif" File "${ADMIN_ROOT}\linkTransparent.gif"
File "..\..\admin-root\linkOpaque.gif" File "${ADMIN_ROOT}\linkOpaque.gif"
File "..\..\admin-root\index.html" File "${ADMIN_ROOT}\index.html"
File "..\..\admin-root\hdr.html" File "${ADMIN_ROOT}\hdr.html"
File "..\..\admin-root\gpl-license.txt" File "${ADMIN_ROOT}\gpl-license.txt"
File "..\..\admin-root\gpl-license.html" File "${ADMIN_ROOT}\gpl-license.html"
File "..\..\admin-root\ftr.html" File "${ADMIN_ROOT}\ftr.html"
File "..\..\admin-root\feedback.html" File "${ADMIN_ROOT}\feedback.html"
File "..\..\admin-root\favicon.ico" File "${ADMIN_ROOT}\favicon.ico"
File "..\..\admin-root\DAAPApplet-0.1.jar" File "${ADMIN_ROOT}\DAAPApplet-0.1.jar"
File "..\..\admin-root\CREDITS" File "${ADMIN_ROOT}\CREDITS"
File "..\..\admin-root\config-update.html" File "${ADMIN_ROOT}\config-update.html"
File "..\..\admin-root\config.html" File "${ADMIN_ROOT}\config.html"
File "..\..\admin-root\config.js" File "${ADMIN_ROOT}\config.js"
File "..\..\admin-root\aspl-license.txt" File "${ADMIN_ROOT}\aspl-license.txt"
File "..\..\admin-root\aspl-license.html" File "${ADMIN_ROOT}\aspl-license.html"
File "..\..\admin-root\applet.html" File "${ADMIN_ROOT}\applet.html"
File "..\..\admin-root\smart.js" File "${ADMIN_ROOT}\smart.js"
SetOutPath "$2\admin-root\lib-js" SetOutPath "$2\admin-root\lib-js"
File "..\..\admin-root\lib-js\prototype.js" File "${ADMIN_ROOT}\lib-js\prototype.js"
File "..\..\admin-root\lib-js\rico.js" File "${ADMIN_ROOT}\lib-js\rico.js"
SetOutPath "$2\admin-root\lib-js\script.aculo.us" SetOutPath "$2\admin-root\lib-js\script.aculo.us"
File "..\..\admin-root\lib-js\script.aculo.us\builder.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\builder.js"
File "..\..\admin-root\lib-js\script.aculo.us\controls.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\controls.js"
File "..\..\admin-root\lib-js\script.aculo.us\dragdrop.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\dragdrop.js"
File "..\..\admin-root\lib-js\script.aculo.us\effects.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\effects.js"
File "..\..\admin-root\lib-js\script.aculo.us\scriptaculous.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\scriptaculous.js"
File "..\..\admin-root\lib-js\script.aculo.us\slider.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\slider.js"
File "..\..\admin-root\lib-js\script.aculo.us\unittest.js" File "${ADMIN_ROOT}\lib-js\script.aculo.us\unittest.js"
SetOutPath "$2" SetOutPath "$2"
File "mt-daapd-example.conf" File "mt-daapd-example.conf"
IfFileExists "$2\mt-daapd.conf" HasConf IfFileExists "$2\mt-daapd.conf" HasConf
SetOverwrite off SetOverwrite off
CopyFiles "$2\mt-daapd-example.conf" "$2\mt-daapd.conf" CopyFiles "$2\mt-daapd-example.conf" "$2\mt-daapd.conf"
HasConf:
WriteINIStr "$2\mt-daapd.conf" "general" "mp3_dir" $3 WriteINIStr "$2\mt-daapd.conf" "general" "mp3_dir" $3
HasConf:
SetAutoClose False SetAutoClose False
SectionEnd SectionEnd
@ -160,6 +164,8 @@ Section -Post
MessageBox MB_OK "Error installing service: $1" MessageBox MB_OK "Error installing service: $1"
lbl_install_success: lbl_install_success:
nsSCM::Start "${PRODUCT_NAME}"
SectionEnd SectionEnd
@ -207,7 +213,7 @@ MusicDirectoryPage:
StrCpy $9 "2" StrCpy $9 "2"
!insertmacro MUI_HEADER_TEXT "Choose Music Location" "Choose the folder containing music to share." !insertmacro MUI_HEADER_TEXT "Choose Music Location" "Choose the folder containing music to share."
!insertmacro MUI_INNERDIALOG_TEXT 1041 "Music Folder" !insertmacro MUI_INNERDIALOG_TEXT 1041 "Music Folder"
!insertmacro MUI_INNERDIALOG_TEXT 1019 "C:\Documents and Settings" !insertmacro MUI_INNERDIALOG_TEXT 1019 "$DOCUMENTS\My Music"
!insertmacro MUI_INNERDIALOG_TEXT 1006 "Setup will share the music in the following folder.$\r$\n$\r$\nTo share a different folder, click Browse and select another folder. Click Install to start the installation." !insertmacro MUI_INNERDIALOG_TEXT 1006 "Setup will share the music in the following folder.$\r$\n$\r$\nTo share a different folder, click Browse and select another folder. Click Install to start the installation."
EndDirectoryShow: EndDirectoryShow:
FunctionEnd FunctionEnd
@ -222,7 +228,9 @@ SaveInstallDir:
Goto EndDirectoryLeave Goto EndDirectoryLeave
SaveMusicDir: SaveMusicDir:
StrCpy $3 $INSTDIR Push $INSTDIR
Call GetParent
Pop $3
EndDirectoryLeave: EndDirectoryLeave:
FunctionEnd FunctionEnd
@ -249,6 +257,44 @@ FunctionEnd
;-------------------------------- ;--------------------------------
;Helper Functions ;Helper Functions
; GetParent
; input, top of stack (e.g. C:\Program Files\Poop)
; output, top of stack (replaces, with e.g. C:\Program Files)
; modifies no other variables.
;
; Usage:
; Push "C:\Program Files\Directory\Whatever"
; Call GetParent
; Pop $R0
; ; at this point $R0 will equal "C:\Program Files\Directory"
Function GetParent
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Function GetRoot Function GetRoot
Exch $0 Exch $0
Push $1 Push $1
@ -300,9 +346,9 @@ Section Uninstall
Delete "$INSTDIR\gnu_regex.dll" Delete "$INSTDIR\gnu_regex.dll"
Delete "$INSTDIR\pthreadVC2.dll" Delete "$INSTDIR\pthreadVC2.dll"
Delete "$INSTDIR\sqlite.dll" Delete "$INSTDIR\sqlite.dll"
Delete "$INSTDIR\sqlie3.dll" Delete "$INSTDIR\sqlite3.dll"
Delete "$INSTDIR\mt-daapd.conf" Delete "$INSTDIR\mt-daapd.conf"
Delete "$INSTDIR\zlib.dll" Delete "$INSTDIR\zlib1.dll"
Delete "$INSTDIR\mt-daapd-example.conf" Delete "$INSTDIR\mt-daapd-example.conf"
Delete "$INSTDIR\admin-root\applet.html" Delete "$INSTDIR\admin-root\applet.html"
Delete "$INSTDIR\admin-root\aspl-license.html" Delete "$INSTDIR\admin-root\aspl-license.html"