Skip to content
Browse files

Update bindings and fix a bug in last commit, password support still …

…has issues.
  • Loading branch information...
1 parent 6beb6dd commit 02e47e457fe93c24a9f14b611f982eff7a4cf10e @juhovh committed Mar 20, 2012
Showing with 21 additions and 52 deletions.
  1. +1 −38 AirTV-Qt/AirTV.pro
  2. +2 −2 AirTV-Qt/raopservice.cpp
  3. +9 −6 src/bindings/python/Shairplay.py
  4. +9 −6 src/lib/raop.c
View
39 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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
4 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();
View
15 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 @@ def __del__(self):
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 @@ def __del__(self):
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)
View
15 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);
}

0 comments on commit 02e47e4

Please sign in to comment.
Something went wrong with that request. Please try again.