From 1f640234f5d89d5fc8fb956d27418d019f918018 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Fri, 13 Apr 2007 21:37:42 +0000 Subject: [PATCH] start of UPnP functions --- configure.in | 5 +++++ src/Makefile.am | 9 +++++++-- src/main.c | 8 ++++++++ src/os-unix.h | 2 +- src/util.h | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index c792ff0f..5fe5c788 100644 --- a/configure.in +++ b/configure.in @@ -45,6 +45,7 @@ rend_avahi=false db_sqlite=false db_sqlite3=false use_ffmpeg=false; +use_upnp=false; STATIC_LIBS=no CPPFLAGS="${CPPFLAGS} -g -Wall" @@ -117,6 +118,8 @@ AC_ARG_ENABLE(gdbm,[ --enable-gdbm Enable gdbm support], AC_ARG_ENABLE(ffmpeg,[ --enable-ffmpeg Enable ffmpeg transcode support], use_ffmpeg=true;) +AC_ARG_ENABLE(upnp,[ --enable-upnp Enable upnp support], + CPPFLAGS="${CPPFLAGS} -DUPNP"; use_upnp=true;) AC_ARG_ENABLE(mem-debug,[ --enable-mem-debug Enable memory debugging], CPPFLAGS="${CPPFLAGS} -DDEBUG_MEM") @@ -131,6 +134,8 @@ AM_CONDITIONAL(COND_SQLITE,test x$db_sqlite = xtrue) AM_CONDITIONAL(COND_SQLITE3,test x$db_sqlite3 = xtrue) AM_CONDITIONAL(COND_GDBM,test x$use_gdbm = xtrue) AM_CONDITIONAL(COND_FFMPEG,test x$use_ffmpeg = xtrue) +AM_CONDITIONAL(COND_UPNP,test x$use_upnp = xtrue) + #AM_CONDITIONAL(COND_NEED_STRCASESTR,false) #AM_CONDITIONAL(COND_NEED_STRSEP,false) AC_CHECK_FUNCS(strcasestr strsep) diff --git a/src/Makefile.am b/src/Makefile.am index d75e8e94..b1e75e83 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,6 +54,10 @@ if COND_GDBM GDBM=db-gdbm.c db-gdbm.h endif +if COND_UPNP +UPNP=upnp.c upnp.h +endif + wavstreamer_SOURCES = wavstreamer.c mt_daapd_SOURCES = main.c daapd.h rend.h uici.c uici.h webserver.c \ @@ -67,7 +71,8 @@ mt_daapd_SOURCES = main.c daapd.h rend.h uici.c uici.h webserver.c \ os-unix.h os-unix.c os.h plugin.c plugin.h db-sql-updates.c \ memdebug.c memdebug.h \ $(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(ARENDSRC) $(OGGVORBISSRC) \ - $(FLACSRC) $(MUSEPACKSRC) $(SQLITEDB) $(SQLITE3DB) $(SQLDB) $(GDBM) + $(FLACSRC) $(MUSEPACKSRC) $(SQLITEDB) $(SQLITE3DB) $(SQLDB) $(GDBM) \ + $(UPNP) EXTRA_DIST = rend-howl.c rend-posix.c rend-osx.c scan-mpc.c \ scan-ogg.c scan-flac.c db-sql.c db-sql.h \ @@ -75,4 +80,4 @@ EXTRA_DIST = rend-howl.c rend-posix.c rend-osx.c scan-mpc.c \ db-sql-sqlite3.h db-sql-sqlite3.c \ w32-eventlog.c w32-eventlog.h w32-service.c w32-service.h \ os-win32.h os-win32.c win32.h db-gdbm.c db-gdbm.h \ - ff-plugins.h ff-dbstruct.h + ff-plugins.h ff-dbstruct.h upnp.c upnp.h diff --git a/src/main.c b/src/main.c index c9bc2938..178b72c8 100644 --- a/src/main.c +++ b/src/main.c @@ -88,6 +88,7 @@ #include "os.h" #include "plugin.h" #include "util.h" +#include "upnp.h" #ifdef HAVE_GETOPT_H # include "getopt.h" @@ -421,6 +422,11 @@ int main(int argc, char *argv[]) { DPRINTF(E_LOG,L_MAIN,"Firefly Version %s: Starting with debuglevel %d\n", VERSION,err_getlevel()); + +#ifdef UPNP + upnp_init(); +#endif + /* load plugins before we drop privs? Maybe... let the * plugins do stuff they might need to */ plugin_init(); @@ -583,6 +589,8 @@ int main(int argc, char *argv[]) { config.reload = 1; /* force a reload on start */ while(!config.stop) { + upnp_tick(); /* run the upnp loop */ + if((conf_get_int("general","rescan_interval",0) && (rescan_counter > conf_get_int("general","rescan_interval",0)))) { if((conf_get_int("general","always_scan",0)) || diff --git a/src/os-unix.h b/src/os-unix.h index 14c10d00..51f7096b 100644 --- a/src/os-unix.h +++ b/src/os-unix.h @@ -9,10 +9,10 @@ #define PATHSEP '/' #define PATHSEP_STR "/" +#define OS_SOCKETTYPE unsigned int /* unix-specific functions */ extern int os_drop_privs(char *user); void os_set_pidfile(char *file); - #endif diff --git a/src/util.h b/src/util.h index f5c74f41..2197b2bd 100644 --- a/src/util.h +++ b/src/util.h @@ -20,6 +20,7 @@ typedef enum { l_conf, l_plugin, l_memdebug, + l_upnp, l_last } ff_lock_t;