Commits

Anonymous committed 4d96285

ServiceUtils is now private

Comments (0)

Files changed (4)

 import Network.DNSSD.Services
 import Network.DNSSD.InterfaceIndex 
 import Network.DNSSD.Flags
-import Network.DNSSD.ServicesUtils
 import Network.DNSSD.TXT
 import Control.Concurrent
 import Foreign.Ptr
                 (BrowseReply (ReplyWithInterface f i) name regType domain :_ ) -> do
                     lift $ resolve name regType domain print [] i >>= runServiceFor 5                   
 
-buildListFor :: CreateServiceRef t => Int -> ((a -> IO ()) -> IO (ServiceResult t)) -> IO (ServiceResult [a])
+buildListFor :: StopService t => Int -> ((a -> IO ()) -> IO (ServiceResult t)) -> IO (ServiceResult [a])
 buildListFor n f = do
     listRef <- newIORef []
     srv <- f (\t -> modifyIORef listRef (t :))

Network/DNSSD/Services.chs

      , getAddrInfo
      , enumerateDomains
      , enumerateDomainsS
+     , ServiceResult
+     , ServiceRef
      , BrowseReply          (..)
      , ReplyWithInterface   (..)
      , RegisterReply        (..)
      , DNSServiceProtocol   (..)
      , Proto
      , DNSServiceFlag       (..)
+     , StopService          (..)
 )-- {{{
  where
 import Foreign.Ptr

Network/DNSSD/ServicesUtils.chs

 unmarshalIface :: CUInt -> InterfaceIndex
 unmarshalIface = unmarshalInterface
 
+class StopService t where
+    stopService :: t -> IO ()
+
 class CreateServiceRef t where
     createServiceRef :: ThreadId -> DNSServiceRef -> t
-    stopService :: t -> IO ()
+
+instance StopService ServiceRef where
+    stopService (ServiceRef tid) = killThread tid
 
 instance CreateServiceRef ServiceRef where
     createServiceRef tid _ = ServiceRef tid
-    stopService (ServiceRef tid) = killThread tid
+
+instance StopService (RecServiceRefAdd) where
+    stopService (RecServiceRefAdd tid _) = killThread tid
 
 instance CreateServiceRef (RecServiceRefAdd) where
     createServiceRef = RecServiceRefAdd
-    stopService (RecServiceRefAdd tid _) = killThread tid
+
+instance StopService RecServiceRefRegister where
+    stopService (RecServiceRefRegister tid _) = killThread tid
 
 instance CreateServiceRef (RecServiceRefRegister) where
     createServiceRef = RecServiceRefRegister
-    stopService (RecServiceRefRegister tid _) = killThread tid
 
 createService :: CreateServiceRef t => 
     Flags ->
                     , Network.DNSSD.Flags
                     , Network.DNSSD.InterfaceIndex
                     , Network.DNSSD.Records
-                    , Network.DNSSD.ServicesUtils
+  other-modules     : Network.DNSSD.ServicesUtils
   build-depends     : base ==4.5.* 
                     , bytestring == 0.9.*
                     , network    == 2.3.*