summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Cochrane <adrian@openwork.nz>2021-01-07 19:19:30 +1300
committerAdrian Cochrane <adrian@openwork.nz>2021-01-07 19:19:30 +1300
commitcdc252ef0c0155c55282ca43b7b855d4120336e2 (patch)
tree9c59a24894e318ae19cea4c0e19e10c0e36a2fa9
parent6d7fb3907be08d85c949a63a0da58302ba5e26d2 (diff)
downloadhurl-cdc252ef0c0155c55282ca43b7b855d4120336e2.tar.gz
hurl-cdc252ef0c0155c55282ca43b7b855d4120336e2.tar.bz2
hurl-cdc252ef0c0155c55282ca43b7b855d4120336e2.zip
Various fixes.
-rw-r--r--hurl.cabal20
-rw-r--r--src/Network/MIME/Info.hs2
-rw-r--r--src/Network/URI/Fetch.hs7
-rw-r--r--src/Network/URI/XDG.hs15
4 files changed, 12 insertions, 32 deletions
diff --git a/hurl.cabal b/hurl.cabal
index 08789ff..644f914 100644
--- a/hurl.cabal
+++ b/hurl.cabal
@@ -73,11 +73,6 @@ Flag freedesktop
Default: True
Manual: True
-Flag appstream
- Description: Failing to dispatch URIs and MIMEtypes as per `freedesktop`, consults the local AppStream database to suggest apps to install. Only has an effect if the `freedesktop` is also set.
- Default: True
- Manual: True
-
Flag rewriters
Description: Support regexp-based URI rewriting/blocking plugins
Default: True
@@ -89,10 +84,10 @@ source-repository head
library
-- Modules exported by the library.
- exposed-modules: Network.URI.Charset, Network.URI.Fetch
+ exposed-modules: Network.URI.Charset, Network.URI.Fetch, Network.MIME.Info
-- Modules included in this library but not exported.
- other-modules: Network.URI.Locale, Network.URI.Messages, Network.URI.Types, Network.MIME.Info
+ other-modules: Network.URI.Locale, Network.URI.Messages, Network.URI.Types
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
@@ -100,7 +95,7 @@ library
-- Other library packages from which modules are imported.
build-depends: base >=4.9 && <5, text >= 1.2 && <1.3,
network-uri >=2.6 && <2.7, bytestring >= 0.10 && < 0.11,
- async >= 2.1 && < 2.3, filepath, directory,
+ async >= 2.1 && < 2.3, filepath, directory >= 1.3.2,
time >= 1.6
-- Directories containing source files.
@@ -126,13 +121,10 @@ library
build-depends: base64-bytestring >=1.0 && <2.0
if flag(freedesktop)
CPP-options: -DWITH_XDG
- build-depends: process >= 1.2 && <2.0
+ build-depends: process >= 1.2 && <2.0, xml-conduit >=1.8, zlib >= 0.6 && < 0.7, containers
other-modules: Network.URI.XDG.Ini, Network.URI.XDG.MimeApps,
- Network.URI.XDG.DesktopEntry, Network.URI.XDG.MimeInfo, Network.URI.XDG
- if flag(freedesktop) && flag(appstream)
- CPP-options: -DWITH_APPSTREAM
- build-depends: xml-conduit >=1.8, zlib >= 0.6 && < 0.7, containers
- other-modules: Network.URI.XDG.AppStream, Network.URI.XDG.AppStreamOutput
+ Network.URI.XDG.DesktopEntry, Network.URI.XDG.MimeInfo, Network.URI.XDG,
+ Network.URI.XDG.AppStream, Network.URI.XDG.AppStreamOutput
if flag(rewriters)
CPP-options: -DWITH_PLUGIN_REWRITES
build-depends: regex, regex-tdfa >= 1.2 && < 1.4
diff --git a/src/Network/MIME/Info.hs b/src/Network/MIME/Info.hs
index 5ff9514..f8ca9e4 100644
--- a/src/Network/MIME/Info.hs
+++ b/src/Network/MIME/Info.hs
@@ -1,5 +1,5 @@
{-# LANGUAGE CPP #-}
-module Network.MIME.Info(mimeInfo, MIME(..)) where
+module Network.MIME.Info(mimeInfo, MIME, Application(..)) where
#ifdef WITH_XDG
import Network.URI.XDG.MimeInfo (readMimeInfo)
diff --git a/src/Network/URI/Fetch.hs b/src/Network/URI/Fetch.hs
index b4aab8b..2910d19 100644
--- a/src/Network/URI/Fetch.hs
+++ b/src/Network/URI/Fetch.hs
@@ -98,7 +98,9 @@ data Session = Session {
-- | How many redirects to follow for Gemini or HTTP(S) requests
redirectCount :: Int,
-- | Whether to cache network responses, avoiding sending requests
- cachingEnabled :: Bool
+ cachingEnabled :: Bool,
+ -- | App-specific config subdirectory to check
+ appName :: String
}
data LogRecord = LogRecord {
@@ -158,7 +160,8 @@ newSession' appname = do
aboutPages = [],
requestLog = Nothing,
redirectCount = 5,
- cachingEnabled = True
+ cachingEnabled = True,
+ appName = appname
}
llookup key fallback map = fallback `fromMaybe` listToMaybe [v | (k, v) <- map, k == key]
diff --git a/src/Network/URI/XDG.hs b/src/Network/URI/XDG.hs
index 0de6652..3e3366e 100644
--- a/src/Network/URI/XDG.hs
+++ b/src/Network/URI/XDG.hs
@@ -10,7 +10,6 @@ import Network.URI.XDG.MimeApps
import Data.List (stripPrefix)
import Data.Maybe (catMaybes)
-#if WITH_APPSTREAM
import qualified Text.XML as XML
import qualified Data.Map as M
import Data.Text (Text)
@@ -19,14 +18,11 @@ import Network.URI.XDG.AppStream
import Network.URI.XDG.AppStreamOutput
import Control.Monad (forM)
import Network.URI
-#endif
data XDGConfig = XDGConfig {
-#if WITH_APPSTREAM
components :: M.Map Text Component,
componentsByMIME :: M.Map Text [Component],
iconCache :: IconCache,
-#endif
handlers :: HandlersConfig,
locales :: [String]
}
@@ -34,13 +30,9 @@ data XDGConfig = XDGConfig {
loadXDGConfig :: [String] -> IO XDGConfig
loadXDGConfig locales = do
handlers <- loadHandlers
-#if WITH_APPSTREAM
components <- loadDatabase locales
icons <- scanIconCache
return $ XDGConfig components (buildMIMEIndex components) icons handlers locales
-#else
- return $ XDGConfig handlers locales
-#endif
dispatchURIByMIME :: XDGConfig -> URI -> String -> IO Errors
dispatchURIByMIME config uri mime = do
@@ -50,7 +42,6 @@ dispatchURIByMIME config uri mime = do
Nothing -> reportUnsupported config mime uri
reportUnsupported :: XDGConfig -> String -> URI -> IO Errors
-#if WITH_APPSTREAM
reportUnsupported XDGConfig { components = comps } "x-scheme-handler/appstream" URI {
uriAuthority = Just (URIAuth { uriRegName = ident })
} | Just el <- xmlForID comps $ Txt.pack ident = return $ RawXML $ serializeXML el
@@ -61,12 +52,6 @@ reportUnsupported XDGConfig { iconCache = icondirs, componentsByMIME = index } m
icons' <- testLocalIcons $ icons app
return $ app {icons = icons'}
return $ RequiresInstall mime $ outputApps apps'
-#else
-reportUnsupported _ mime _
- | Just scheme <- "x-scheme-handler/" `stripPrefix` mime =
- return $ UnsupportedScheme (scheme ++ ":")
- | otherwise = return $ UnsupportedMIME mime
-#endif
mapFirstM :: [a] -> (a -> IO (Maybe b)) -> IO (Maybe b)
mapFirstM (x:xs) cb = do