summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2019-02-07 04:49:32 +0000
committerjao <jao@gnu.org>2019-02-07 04:49:32 +0000
commit132c4c459763c81ddf60aeedf5b87b619bb5f1ce (patch)
treee9d958c5da9a34c960435a2045bc9ded9d0fbe0d
parent75d0d5e1897d5d69a3b296011be1981b92fbb5ac (diff)
downloadxmobar-132c4c459763c81ddf60aeedf5b87b619bb5f1ce.tar.gz
xmobar-132c4c459763c81ddf60aeedf5b87b619bb5f1ce.tar.bz2
Always require http-conduit for weather (fixes #378)
-rw-r--r--changelog.md4
-rw-r--r--readme.md6
-rw-r--r--src/Xmobar/Plugins/Monitors/Weather.hs31
-rw-r--r--xmobar.cabal12
4 files changed, 6 insertions, 47 deletions
diff --git a/changelog.md b/changelog.md
index 6659053..b387f6e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,4 @@
-## Version 0.29.5 (January, 2019)
+## Version 0.29.5 (February, 2019)
_Bug fixes_
@@ -6,6 +6,8 @@ _Bug fixes_
configuration file (issue #375).
- `Alsa` plugin: restart `alsactl` if it quits, e.g. because of a
sleep/awake cycle (issue #376).
+ - `Weather` using the new HTTPS URL, which requires http-conduit as
+ a dependency (issue #378).
## Version 0.29.4 (December, 2018)
diff --git a/readme.md b/readme.md
index 3eadb22..9a0fc51 100644
--- a/readme.md
+++ b/readme.md
@@ -130,15 +130,11 @@ Otherwise, you'll need to install them yourself.
.xpm files in `<icon>`. Requires the [libXpm] C library.
- `with_uvmeter` Enables UVMeter plugin. The plugin shows UV data for
- Australia. Requires `with_conduit` to connect to HTTPS URLs.
+ Australia.
- `with_weather` Support to display weather information. Enables
Weather plugin.
-- `with_conduit` Use http-conduit for getting weather data enabling
- support for http proxies. Requires [http-conduit] and [http-types].
- Note that this flag has only an effect if `with_weather` is also set.
-
- `all_extensions` Enables all the extensions above.
# Running xmobar
diff --git a/src/Xmobar/Plugins/Monitors/Weather.hs b/src/Xmobar/Plugins/Monitors/Weather.hs
index ce6fc29..30439f5 100644
--- a/src/Xmobar/Plugins/Monitors/Weather.hs
+++ b/src/Xmobar/Plugins/Monitors/Weather.hs
@@ -19,14 +19,10 @@ import Xmobar.Plugins.Monitors.Common
import qualified Control.Exception as CE
-#ifdef HTTP_CONDUIT
import Network.HTTP.Conduit
import Network.HTTP.Types.Status
import Network.HTTP.Types.Method
import qualified Data.ByteString.Lazy.Char8 as B
-#else
-import Network.HTTP
-#endif
import Text.ParserCombinators.Parsec
@@ -189,7 +185,6 @@ stationUrl :: String -> String
stationUrl station = defUrl ++ station ++ ".TXT"
getData :: String -> IO String
-#ifdef HTTP_CONDUIT
getData station = CE.catch (do
manager <- newManager tlsManagerSettings
request <- parseUrlThrow $ stationUrl station
@@ -198,13 +193,6 @@ getData station = CE.catch (do
) errHandler
where errHandler :: CE.SomeException -> IO String
errHandler _ = return "<Could not retrieve data>"
-#else
-getData station = do
- let request = getRequest (stationUrl station)
- CE.catch (simpleHTTP request >>= getResponseBody) errHandler
- where errHandler :: CE.IOException -> IO String
- errHandler _ = return "<Could not retrieve data>"
-#endif
formatWeather :: [WeatherInfo] -> Monitor String
formatWeather [WI st ss y m d h (WindInfo wc wa wm wk wkh wms) v sk tC tF dC dF r p] =
@@ -220,7 +208,6 @@ runWeather str =
formatWeather i
weatherReady :: [String] -> Monitor Bool
-#ifdef HTTP_CONDUIT
weatherReady str = do
initRequest <- parseUrlThrow $ stationUrl $ head str
let request = initRequest{method = methodHead}
@@ -234,21 +221,3 @@ weatherReady str = do
| statusIsServerError status = False
| statusIsClientError status = False
| otherwise = True
-#else
-weatherReady str = do
- let station = head str
- request = headRequest (stationUrl station)
- io $ CE.catch (simpleHTTP request >>= checkResult) errHandler
- where errHandler :: CE.IOException -> IO Bool
- errHandler _ = return False
- checkResult result =
- case result of
- Left _ -> return False
- Right response ->
- case rspCode response of
- -- Permission or network errors are failures; anything
- -- else is recoverable.
- (4, _, _) -> return False
- (5, _, _) -> return False
- (_, _, _) -> return True
-#endif
diff --git a/xmobar.cabal b/xmobar.cabal
index d7cf9ea..b0c6cf6 100644
--- a/xmobar.cabal
+++ b/xmobar.cabal
@@ -87,10 +87,6 @@ flag with_weather
description: Enable weather plugin.
default: True
-flag with_conduit
- description: Use http-conduits for weather data, used only if with_weather.
- default: False
-
library
hs-source-dirs: src
@@ -251,15 +247,11 @@ library
cpp-options: -DXPM
if flag(with_weather) || flag(all_extensions)
- build-depends: HTTP >= 4000.2.4
exposed-modules: Xmobar.Plugins.Monitors.Weather
cpp-options: -DWEATHER
- if flag(with_conduit)
- -- use http-conduit instead of simple-http
- build-depends: http-conduit, http-types
- cpp-options: -DHTTP_CONDUIT
+ build-depends: http-conduit, http-types
- if flag(with_uvmeter) && flag(with_conduit)
+ if flag(with_uvmeter)
exposed-modules: Xmobar.Plugins.Monitors.UVMeter
build-depends: http-conduit, http-types
cpp-options: -DUVMETER