Update bindings and fix a bug in last commit, password support still has issues.
authorJuho Vähä-Herttua <juhovh@iki.fi>
Tue, 20 Mar 2012 19:41:03 +0000 (21:41 +0200)
committerJuho Vähä-Herttua <juhovh@iki.fi>
Wed, 16 May 2012 21:33:32 +0000 (00:33 +0300)
AirTV-Qt/AirTV.pro
AirTV-Qt/raopservice.cpp
src/bindings/python/Shairplay.py
src/lib/raop.c

index bdfe3a88266627129f4eead18cad3d6bd29a3170..207743cef9f3e126d97f5774ffcc01abe1a2084f 100644 (file)
@@ -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
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
index 8332f5cf0b607ce076370907556ce34d49e50466..1c3519dbeb567a0876f796e88b65b825cc77d1f5 100644 (file)
@@ -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();
index 0add4be5f20a8987bea78147b47a6fb0363a9e76..15afc540c49917351c35924bb1bed94cfaec9cda 100644 (file)
@@ -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)
index 0eaace1bbc2c2fde1d2ef2fbeae6c6a78b3fdd27..9aafe65b18ef654e01303b7060e96629862cbae3 100644 (file)
@@ -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);
 }