summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-24 18:55:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-24 18:55:19 -0400
commit98e460ec24073856f0a8ace7f4d1b28761e0be76 (patch)
tree5fd332e96442bc4b557a591ec5dc6e3d1f5ecb0c /Assistant
parent9ad09558eb6c9f7ed651168a030e26bc5698c1b8 (diff)
fix build with xmpp and w/o webapp
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/XMPPClient.hs6
-rw-r--r--Assistant/XMPP/Git.hs30
2 files changed, 12 insertions, 24 deletions
diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs
index 1242c1d74..8ccb241bb 100644
--- a/Assistant/Threads/XMPPClient.hs
+++ b/Assistant/Threads/XMPPClient.hs
@@ -20,6 +20,7 @@ import qualified Remote
import Utility.ThreadScheduler
import Assistant.WebApp (UrlRenderer, renderUrl)
import Assistant.WebApp.Types hiding (liftAssistant)
+import Assistant.WebApp.Configurators.XMPP (checkCloudRepos)
import Assistant.Alert
import Assistant.Pairing
import Assistant.XMPP.Git
@@ -106,8 +107,9 @@ xmppClient urlrenderer d creds =
maybe noop (inAssistant . pairMsgReceived urlrenderer stage u selfjid) (parseJID c)
handle _ (GotNetMessage m@(Pushing _ pushstage))
| isPushInitiation pushstage = inAssistant $
- unlessM (queueNetPushMessage m) $
- void $ forkIO <~> handlePushInitiation urlrenderer m
+ unlessM (queueNetPushMessage m) $ do
+ let checker = checkCloudRepos urlrenderer
+ void $ forkIO <~> handlePushInitiation checker m
| otherwise = void $ inAssistant $ queueNetPushMessage m
handle _ (Ignorable _) = noop
handle _ (Unknown _) = noop
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs
index 135c68fbc..f90af4080 100644
--- a/Assistant/XMPP/Git.hs
+++ b/Assistant/XMPP/Git.hs
@@ -31,10 +31,6 @@ import qualified Remote as Remote
import Remote.List
import Utility.FileMode
import Utility.Shell
-#ifdef WITH_WEBAPP
-import Assistant.WebApp (UrlRenderer)
-import Assistant.WebApp.Configurators.XMPP
-#endif
import Network.Protocol.XMPP
import qualified Data.Text as T
@@ -256,11 +252,11 @@ xmppRemotes cid = case baseJID <$> parseJID cid of
where
matching loc r = repoIsUrl r && repoLocation r == loc
-handlePushInitiation :: UrlRenderer -> NetMessage -> Assistant ()
+handlePushInitiation :: (Remote -> Assistant ()) -> NetMessage -> Assistant ()
handlePushInitiation _ (Pushing cid CanPush) =
unlessM (null <$> xmppRemotes cid) $
sendNetMessage $ Pushing cid PushRequest
-handlePushInitiation urlrenderer (Pushing cid PushRequest) =
+handlePushInitiation checkcloudrepos (Pushing cid PushRequest) =
go =<< liftAnnex (inRepo Git.Branch.current)
where
go Nothing = noop
@@ -276,29 +272,19 @@ handlePushInitiation urlrenderer (Pushing cid PushRequest) =
void $ alertWhile (syncAlert [r]) $
xmppPush cid
(taggedPush u selfjid branch r)
- (handleDeferred urlrenderer)
- checkCloudRepos urlrenderer r
-handlePushInitiation urlrenderer (Pushing cid StartingPush) = do
+ (handleDeferred checkcloudrepos)
+ checkcloudrepos r
+handlePushInitiation checkcloudrepos (Pushing cid StartingPush) = do
rs <- xmppRemotes cid
unless (null rs) $ do
void $ alertWhile (syncAlert rs) $
- xmppReceivePack cid (handleDeferred urlrenderer)
- mapM_ (checkCloudRepos urlrenderer) rs
+ xmppReceivePack cid (handleDeferred checkcloudrepos)
+ mapM_ checkcloudrepos rs
handlePushInitiation _ _ = noop
-handleDeferred :: UrlRenderer -> NetMessage -> Assistant ()
+handleDeferred :: (Remote -> Assistant ()) -> NetMessage -> Assistant ()
handleDeferred = handlePushInitiation
-checkCloudRepos :: UrlRenderer -> Remote -> Assistant ()
--- TODO only display if needed
-checkCloudRepos urlrenderer r =
-#ifdef WITH_WEBAPP
- unlessM (syncingToCloudRemote <$> getDaemonStatus) $
- cloudRepoNeeded urlrenderer (Remote.uuid r)
-#else
- noop
-#endif
-
writeChunk :: Handle -> B.ByteString -> IO ()
writeChunk h b = do
B.hPut h b