1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-05 06:27:37 +00:00

x11/hs-xmobar: Fix the weather plugin

Since the source weather plugin uses switched fully to SSL
the plugin (using HTTP) fails.
The fix by upstream is to omit HTTP_CONDUIT flag on the plugin.
It is backported from upstream here, until their next release.

Reviewed by:	arrowd (maintainer, Haskell@)
Approved by:	arrowd (maintainer, Haskell@)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19403
This commit is contained in:
Mahdi Mokhtari 2019-03-03 13:58:00 +00:00
parent 3d175f4b60
commit 31bf58fb89
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=494509
2 changed files with 105 additions and 1 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= xmobar
PORTVERSION= 0.29.4
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= x11 haskell
MAINTAINER= haskell@FreeBSD.org

View File

@ -0,0 +1,104 @@
Index: src/Xmobar/Plugins/Monitors/Weather.hs
==============================================================================
--- src/Xmobar/Plugins/Monitors/Weather.hs.orig 2018-11-21 23:52:35 UTC
+++ 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
@@ -190,7 +186,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 <- parseUrl $ stationUrl station
@@ -199,13 +194,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] =
@@ -221,7 +209,6 @@ runWeather str =
formatWeather i
weatherReady :: [String] -> Monitor Bool
-#ifdef HTTP_CONDUIT
weatherReady str = do
initRequest <- parseUrl $ stationUrl $ head str
let request = initRequest{method = methodHead}
@@ -235,21 +222,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
Index: xmobar.cabal
==============================================================================
--- xmobar.cabal.orig 2018-12-24 02:06:23 UTC
+++ 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