From: Juho Vähä-Herttua Date: Tue, 20 Mar 2012 19:41:03 +0000 (+0200) Subject: Update bindings and fix a bug in last commit, password support still has issues. X-Git-Tag: upstream/0.9.0~4^2~92 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a68fedbb434cf90caea9b83d7690e5465d1272df;p=deb_shairplay.git Update bindings and fix a bug in last commit, password support still has issues. --- diff --git a/AirTV-Qt/AirTV.pro b/AirTV-Qt/AirTV.pro index bdfe3a8..207743c 100644 --- a/AirTV-Qt/AirTV.pro +++ b/AirTV-Qt/AirTV.pro @@ -48,6 +48,7 @@ SOURCES += main.cpp\ ../src/lib/crypto/bigint.c \ ../src/lib/crypto/aes.c \ ../src/lib/logger.c \ + ../src/lib/digest.c \ audiooutput.cpp \ raopservice.cpp \ mainapplication.cpp \ @@ -64,41 +65,3 @@ FORMS += mainwindow.ui RESOURCES += \ AirTV.qrc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AirTV-Qt/raopservice.cpp b/AirTV-Qt/raopservice.cpp index 8332f5c..1c3519d 100644 --- a/AirTV-Qt/raopservice.cpp +++ b/AirTV-Qt/raopservice.cpp @@ -131,12 +131,12 @@ bool RaopService::start(const QString & name, quint16 port) } m_thread.start(); - if (raop_start(m_raop, &port, hwaddr, sizeof(hwaddr)) < 0) { + if (raop_start(m_raop, &port, hwaddr, sizeof(hwaddr), NULL) < 0) { m_thread.quit(); m_thread.wait(); return false; } - if (dnssd_register_raop(m_dnssd, name.toUtf8(), port, hwaddr, sizeof(hwaddr)) < 0) { + if (dnssd_register_raop(m_dnssd, name.toUtf8(), port, hwaddr, sizeof(hwaddr), 0) < 0) { raop_stop(m_raop); m_thread.quit(); m_thread.wait(); diff --git a/src/bindings/python/Shairplay.py b/src/bindings/python/Shairplay.py index 0add4be..15afc54 100644 --- a/src/bindings/python/Shairplay.py +++ b/src/bindings/python/Shairplay.py @@ -47,7 +47,7 @@ def InitShairplay(libshairplay): libshairplay.dnssd_init.restype = c_void_p libshairplay.dnssd_init.argtypes = [POINTER(c_int)] libshairplay.dnssd_register_raop.restype = c_int - libshairplay.dnssd_register_raop.argtypes = [c_void_p, c_char_p, c_ushort, POINTER(c_char), c_int] + libshairplay.dnssd_register_raop.argtypes = [c_void_p, c_char_p, c_ushort, POINTER(c_char), c_int, c_int] libshairplay.dnssd_register_airplay.restype = c_int libshairplay.dnssd_register_airplay.argtypes = [c_void_p, c_char_p, c_ushort, POINTER(c_char), c_int] libshairplay.dnssd_unregister_raop.restype = None @@ -61,7 +61,7 @@ def InitShairplay(libshairplay): libshairplay.raop_init.restype = c_void_p libshairplay.raop_init.argtypes = [POINTER(RaopNativeCallbacks), c_char_p] libshairplay.raop_start.restype = c_int - libshairplay.raop_start.argtypes = [c_void_p, POINTER(c_ushort), POINTER(c_char), c_int] + libshairplay.raop_start.argtypes = [c_void_p, POINTER(c_ushort), POINTER(c_char), c_int, c_char_p] libshairplay.raop_stop.restype = None libshairplay.raop_stop.argtypes = [c_void_p] libshairplay.raop_destroy.restype = None @@ -181,11 +181,11 @@ class RaopService: self.libshairplay.raop_destroy(self.instance) self.instance = None - def start(self, port, hwaddrstr): + def start(self, port, hwaddrstr, password=None): port = c_ushort(port) hwaddr = create_string_buffer(hwaddrstr, len(hwaddrstr)) - ret = self.libshairplay.raop_start(self.instance, pointer(port), hwaddr, c_int(len(hwaddr))) + ret = self.libshairplay.raop_start(self.instance, pointer(port), hwaddr, c_int(len(hwaddr)), password) if ret < 0: raise RuntimeError("Starting RAOP instance failed") return port.value @@ -209,9 +209,12 @@ class DnssdService: self.libshairplay.dnssd_destroy(self.instance) self.instance = None - def register_raop(self, name, port, hwaddrstr): + def register_raop(self, name, port, hwaddrstr, password=False): hwaddr = create_string_buffer(hwaddrstr, len(hwaddrstr)) - self.libshairplay.dnssd_register_raop(self.instance, name, c_ushort(port), hwaddr, len(hwaddr)) + use_pw = c_int(0) + if password: + use_pw = c_int(1) + self.libshairplay.dnssd_register_raop(self.instance, name, c_ushort(port), hwaddr, len(hwaddr), use_pw) def unregister_raop(self): self.libshairplay.dnssd_unregister_raop(self.instance) diff --git a/src/lib/raop.c b/src/lib/raop.c index 0eaace1..9aafe65 100644 --- a/src/lib/raop.c +++ b/src/lib/raop.c @@ -439,18 +439,21 @@ raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen return -1; } - /* Validate password */ - if (strlen(password) > MAX_PASSWORD_LEN) { - return -1; + memset(raop->password, 0, sizeof(raop->password)); + if (password) { + /* Validate password */ + if (strlen(password) > MAX_PASSWORD_LEN) { + return -1; + } + + /* Copy password to the raop structure */ + strncpy(raop->password, password, MAX_PASSWORD_LEN); } /* Copy hwaddr to the raop structure */ memcpy(raop->hwaddr, hwaddr, hwaddrlen); raop->hwaddrlen = hwaddrlen; - /* Copy password to the raop structure */ - strncpy(raop->password, password, MAX_PASSWORD_LEN); - return httpd_start(raop->httpd, port); }