addFilter :: Connection
          -> (Message -> IO Bool) -- ^A callback that returns True if
                                  --  the message has been handled.
          -> IO ()
addFilter conn callback = do
  withForeignPtr conn $ \conn -> do
    hmf <- wrapHandleMessageFunction handleMessageFunction
    closure <- mkFreeClosure hmf
    pclosure <- newStablePtr closure
    catchOom $ connection_add_filter conn hmf pclosure (fcFree closure)
    where
    handleMessageFunction :: HandleMessageFunction
    handleMessageFunction connp messagep datap = do
      message <- messagePToMessage messagep True
      res <- callback message
      if res then return 0
{-# LINE 205 "DBus/Connection.hsc" #-}
             else return 1

addFilter :: Connection
          -> (Message -> IO Bool) -- ^A callback that returns True if
                                  --  the message has been handled.
          -> IO ()
addFilter conn callback = do
  withForeignPtr conn $ \conn -> do
    hmf <- wrapHandleMessageFunction handleMessageFunction
    closure <- mkFreeClosure hmf
    pclosure <- newStablePtr closure
    catchOom $ connection_add_filter conn hmf pclosure (fcFree closure)
    where
    handleMessageFunction :: HandleMessageFunction
    handleMessageFunction connp messagep datap = do
      message <- messagePToMessage messagep True
      res <- callback message
      if res then return 0
{-# LINE 205 "DBus/Connection.hsc" #-}
             else return 1

addFilter conn callback = do
  withForeignPtr conn $ \conn -> do
    hmf <- wrapHandleMessageFunction handleMessageFunction
    closure <- mkFreeClosure hmf
    pclosure <- newStablePtr closure
    catchOom $ connection_add_filter conn hmf pclosure (fcFree closure)
    where
    handleMessageFunction :: HandleMessageFunction
    handleMessageFunction connp messagep datap = do
      message <- messagePToMessage messagep True
      res <- callback message
      if res then return 0
{-# LINE 205 "DBus/Connection.hsc" #-}
             else return 1
