    {-# LANGUAGE OverloadedStrings #-}
    module StatusNotifier.Watcher.Constants where

    import           DBus.Client
    import           DBus.Generation
    import           DBus.Internal.Types
    import qualified DBus.Introspection as I
    import           Data.Coerce
    import           Data.String
    import           StatusNotifier.Util
    import           System.IO.Unsafe
    import           System.Log.Logger
    import           Text.Printf

    statusNotifierWatcherString :: String
    statusNotifierWatcherString :: String
    statusNotifierWatcherString = String
    "StatusNotifierWatcher"

    getWatcherInterfaceName :: String -> InterfaceName
    getWatcherInterfaceName :: String -> InterfaceName
    getWatcherInterfaceName String
    interfaceNamespace =
      String -> InterfaceName
    forall a. IsString a => String -> a
    fromString (String -> InterfaceName) -> String -> InterfaceName
    forall a b. (a -> b) -> a -> b
    $ String -> String -> String -> String
    forall r. PrintfType r => String -> r
    printf String
    "%s.%s" String
    interfaceNamespace String
    statusNotifierWatcherString

    data ItemEntry = ItemEntry
      { ItemEntry -> BusName
    serviceName :: BusName
      , ItemEntry -> ObjectPath
    servicePath :: ObjectPath
      } deriving (Int -> ItemEntry -> String -> String
    [ItemEntry] -> String -> String
    ItemEntry -> String
    (Int -> ItemEntry -> String -> String)
    -> (ItemEntry -> String)
    -> ([ItemEntry] -> String -> String)
    -> Show ItemEntry
    forall a.
    (Int -> a -> String -> String)
    -> (a -> String) -> ([a] -> String -> String) -> Show a
    $cshowsPrec :: Int -> ItemEntry -> String -> String
    showsPrec :: Int -> ItemEntry -> String -> String
    $cshow :: ItemEntry -> String
    show :: ItemEntry -> String
    $cshowList :: [ItemEntry] -> String -> String
    showList :: [ItemEntry] -> String -> String
    Show, ItemEntry -> ItemEntry -> Bool
    (ItemEntry -> ItemEntry -> Bool)
    -> (ItemEntry -> ItemEntry -> Bool) -> Eq ItemEntry
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ItemEntry -> ItemEntry -> Bool
    == :: ItemEntry -> ItemEntry -> Bool
    $c/= :: ItemEntry -> ItemEntry -> Bool
    /= :: ItemEntry -> ItemEntry -> Bool
    Eq)

    data WatcherParams = WatcherParams
      { WatcherParams -> String
    watcherNamespace :: String
      , WatcherParams -> String
    watcherPath :: String
      , WatcherParams -> IO ()
    watcherStop :: IO ()
      , WatcherParams -> Maybe Client
    watcherDBusClient :: Maybe Client
      }

    defaultWatcherParams :: WatcherParams
    defaultWatcherParams :: WatcherParams
    defaultWatcherParams =
      WatcherParams
      { watcherNamespace :: String
    watcherNamespace = String
    "org.kde"
      , watcherStop :: IO ()
    watcherStop = () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
      , watcherPath :: String
    watcherPath = String
    "/StatusNotifierWatcher"
      , watcherDBusClient :: Maybe Client
    watcherDBusClient = Maybe Client
    forall a. Maybe a
    Nothing
      }

    defaultWatcherInterfaceName :: InterfaceName
    defaultWatcherInterfaceName =
      String -> InterfaceName
    getWatcherInterfaceName (String -> InterfaceName) -> String -> InterfaceName
    forall a b. (a -> b) -> a -> b
    $ WatcherParams -> String
    watcherNamespace WatcherParams
    defaultWatcherParams

    serviceArg :: SignalArg
    serviceArg = I.SignalArg { signalArgName :: String
    I.signalArgName = String
    "service"
                             , signalArgType :: Type
    I.signalArgType = Type
    TypeString
                             }

    watcherSignals :: [Signal]
    watcherSignals = [ I.Signal { signalName :: MemberName
    I.signalName = MemberName
    "StatusNotifierItemRegistered"
                                , signalArgs :: [SignalArg]
    I.signalArgs = [SignalArg
    serviceArg]
                                }
                     , I.Signal { signalName :: MemberName
    I.signalName = MemberName
    "StatusNotifierItemUnregistered"
                                , signalArgs :: [SignalArg]
    I.signalArgs = [SignalArg
    serviceArg]
                                }
                     , I.Signal { signalName :: MemberName
    I.signalName = MemberName
    "StatusNotifierHostRegistered"
                                , signalArgs :: [SignalArg]
    I.signalArgs = []
                                }
                     ]

    watcherClientGenerationParams :: GenerationParams
    watcherClientGenerationParams =
      GenerationParams
    defaultGenerationParams
      { genBusName = Just $ fromString $ coerce $ getWatcherInterfaceName
                     (watcherNamespace defaultWatcherParams)
      , genObjectPath = Just $ fromString $ watcherPath defaultWatcherParams
      , genTakeSignalErrorHandler = True
      }