diff options
author | Joey Hess <joey@kitenet.net> | 2012-11-05 17:43:17 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-11-05 17:43:17 -0400 |
commit | a4667e3e8cb7fae50b0c2cb8bc1a46df0b289b6c (patch) | |
tree | 9f75d066b025e99f7015818ccbe143d70b5bbae7 /Assistant/XMPP/Git.hs | |
parent | dedc9790ef60b0965c0c34acd080ef8d4906e07a (diff) |
finished XMPP pairing!
This includes keeping track of which buddies we're pairing with, to know
which PairAck are legitimate.
Diffstat (limited to 'Assistant/XMPP/Git.hs')
-rw-r--r-- | Assistant/XMPP/Git.hs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs new file mode 100644 index 000000000..154cbc86d --- /dev/null +++ b/Assistant/XMPP/Git.hs @@ -0,0 +1,49 @@ +{- git over XMPP + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Assistant.XMPP.Git where + +import Assistant.Common +import Assistant.XMPP +import Assistant.XMPP.Buddies +import Assistant.DaemonStatus +import Assistant.Alert +import Assistant.MakeRemote +import Assistant.Sync +import Annex.UUID +import Config +import qualified Types.Remote as Remote + +import Network.Protocol.XMPP +import qualified Data.Text as T + +finishXMPPPairing :: JID -> UUID -> Assistant () +finishXMPPPairing jid u = void $ alertWhile alert $ + makeXMPPGitRemote buddy (baseJID jid) u + where + buddy = T.unpack $ buddyName jid + alert = pairRequestAcknowledgedAlert buddy Nothing + +{- A git remote for an XMPP user? This is represented as a git remote + - that has no location set. The user's XMPP address is stored in the + - xmppaddress setting. + - + - The UUID of their remote is also stored as usual. + -} +makeXMPPGitRemote :: String -> JID -> UUID -> Assistant Bool +makeXMPPGitRemote buddyname jid u = do + remote <- liftAnnex $ addRemote $ makeGitRemote buddyname "" -- no location + liftAnnex $ do + let r = Remote.repo remote + storeUUID (remoteConfig r "uuid") u + setConfig (remoteConfig r "xmppaddress") xmppaddress + syncNewRemote remote + return True + where + xmppaddress = T.unpack $ formatJID $ baseJID jid + + |