summaryrefslogtreecommitdiff
path: root/Assistant/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-30 14:11:14 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-30 14:11:14 -0400
commitdbf9ac41086ffb39296bd1d977cc1db844ff0b32 (patch)
tree357f7397929bc0545b0097e503b4fc2c352a533f /Assistant/Types
parent8ccbaabb0a6b85753f9899f6c066e203281f01e4 (diff)
split out daemonstatus types
Diffstat (limited to 'Assistant/Types')
-rw-r--r--Assistant/Types/DaemonStatus.hs66
1 files changed, 66 insertions, 0 deletions
diff --git a/Assistant/Types/DaemonStatus.hs b/Assistant/Types/DaemonStatus.hs
new file mode 100644
index 000000000..ca4122d55
--- /dev/null
+++ b/Assistant/Types/DaemonStatus.hs
@@ -0,0 +1,66 @@
+{- git-annex assistant daemon status
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+{-# LANGUAGE RankNTypes, ImpredicativeTypes #-}
+
+module Assistant.Types.DaemonStatus where
+
+import Common.Annex
+import Assistant.Alert
+import Assistant.Pairing
+import Utility.NotificationBroadcaster
+import Logs.Transfer
+
+import Control.Concurrent.STM
+import Data.Time.Clock.POSIX
+import qualified Data.Map as M
+
+data DaemonStatus = DaemonStatus
+ -- False when the daemon is performing its startup scan
+ { scanComplete :: Bool
+ -- Time when a previous process of the daemon was running ok
+ , lastRunning :: Maybe POSIXTime
+ -- True when the sanity checker is running
+ , sanityCheckRunning :: Bool
+ -- Last time the sanity checker ran
+ , lastSanityCheck :: Maybe POSIXTime
+ -- Currently running file content transfers
+ , currentTransfers :: TransferMap
+ -- Messages to display to the user.
+ , alertMap :: AlertMap
+ , lastAlertId :: AlertId
+ -- Ordered list of remotes to sync with.
+ , syncRemotes :: [Remote]
+ -- Pairing request that is in progress.
+ , pairingInProgress :: Maybe PairingInProgress
+ -- Broadcasts notifications about all changes to the DaemonStatus
+ , changeNotifier :: NotificationBroadcaster
+ -- Broadcasts notifications when queued or current transfers change.
+ , transferNotifier :: NotificationBroadcaster
+ -- Broadcasts notifications when there's a change to the alerts
+ , alertNotifier :: NotificationBroadcaster
+ }
+
+type TransferMap = M.Map Transfer TransferInfo
+
+{- This TMVar is never left empty, so accessing it will never block. -}
+type DaemonStatusHandle = TMVar DaemonStatus
+
+newDaemonStatus :: IO DaemonStatus
+newDaemonStatus = DaemonStatus
+ <$> pure False
+ <*> pure Nothing
+ <*> pure False
+ <*> pure Nothing
+ <*> pure M.empty
+ <*> pure M.empty
+ <*> pure firstAlertId
+ <*> pure []
+ <*> pure Nothing
+ <*> newNotificationBroadcaster
+ <*> newNotificationBroadcaster
+ <*> newNotificationBroadcaster