split up xmpp and local pairing UIs

This commit is contained in:
Joey Hess 2012-11-11 17:41:56 -04:00
parent 116023e05d
commit b91f07fe83
7 changed files with 53 additions and 59 deletions

View file

@ -55,34 +55,29 @@ import Control.Concurrent
import qualified Data.Set as S import qualified Data.Set as S
#endif #endif
{- Starts either kind of pairing. -} getStartXMPPPairR :: Handler RepHtml
getStartPairR :: Handler RepHtml
#ifdef WITH_XMPP #ifdef WITH_XMPP
getStartPairR = do getStartXMPPPairR = ifM (isJust <$> runAnnex Nothing getXMPPCreds)
xmppconfigured <- isJust <$> runAnnex Nothing getXMPPCreds ( do
#ifdef WITH_PAIRING {- Ask buddies to send presence info, to get
let localsupported = True - the buddy list populated. -}
liftAssistant $ sendNetMessage QueryPresence
pairPage $
$(widgetFile "configurators/pairing/xmpp/prompt")
, redirect XMPPForPairingR -- go get XMPP configured, then come back
)
#else #else
let localsupported = False getStartXMPPPairR = noXMPPPairing
#endif
{- Ask buddies to send presence info, to get the buddy list noXMPPPairing :: Handler RepHtml
- populated. -} noXMPPPairing = noPairing "XMPP"
liftAssistant $ sendNetMessage QueryPresence
pairPage $
$(widgetFile "configurators/pairing/start")
#else
#ifdef WITH_PAIRING
getStartPairR = redirect StartLocalPairR
#else
getStartPairR = noPairing "local or jabber"
#endif
#endif #endif
{- Starts pairing with an XMPP buddy, or with other clients sharing an {- Does pairing with an XMPP buddy, or with other clients sharing an
- XMPP account. -} - XMPP account. -}
getStartXMPPPairR :: BuddyKey -> Handler RepHtml getRunningXMPPPairR :: BuddyKey -> Handler RepHtml
#ifdef WITH_XMPP #ifdef WITH_XMPP
getStartXMPPPairR bid = do getRunningXMPPPairR bid = do
buddy <- liftAssistant $ getBuddy bid <<~ buddyList buddy <- liftAssistant $ getBuddy bid <<~ buddyList
go $ S.toList . buddyAssistants <$> buddy go $ S.toList . buddyAssistants <$> buddy
where where
@ -97,12 +92,9 @@ getStartXMPPPairR bid = do
xmppPairEnd True $ if samejid then Nothing else Just exemplar xmppPairEnd True $ if samejid then Nothing else Just exemplar
-- A buddy could have logged out, or the XMPP client restarted, -- A buddy could have logged out, or the XMPP client restarted,
-- and there be no clients to message; handle unforseen by going back. -- and there be no clients to message; handle unforseen by going back.
go _ = redirect StartPairR go _ = redirect StartXMPPPairR
#else #else
getStartXMPPPairR _ = noXMPPPairing getRunningXMPPPairR _ = noXMPPPairing
noXMPPPairing :: Handler RepHtml
noXMPPPairing = noPairing "XMPP"
#endif #endif
{- Starts local pairing. -} {- Starts local pairing. -}

View file

@ -57,7 +57,7 @@ getXMPPR = xmppPage $
getXMPPForPairingR :: Handler RepHtml getXMPPForPairingR :: Handler RepHtml
#ifdef WITH_XMPP #ifdef WITH_XMPP
getXMPPForPairingR = getXMPPR' StartPairR getXMPPForPairingR = getXMPPR' StartXMPPPairR
#else #else
getXMPPForPairingR = xmppPage $ getXMPPForPairingR = xmppPage $
$(widgetFile "configurators/xmpp/disabled") $(widgetFile "configurators/xmpp/disabled")

View file

@ -26,11 +26,11 @@
/config/repository/add/cloud/rsync.net AddRsyncNetR GET /config/repository/add/cloud/rsync.net AddRsyncNetR GET
/config/repository/add/cloud/S3 AddS3R GET /config/repository/add/cloud/S3 AddS3R GET
/config/repository/pair/start StartPairR GET
/config/repository/pair/local/start StartLocalPairR GET /config/repository/pair/local/start StartLocalPairR GET
/config/repository/pair/local/running/#SecretReminder RunningLocalPairR GET /config/repository/pair/local/running/#SecretReminder RunningLocalPairR GET
/config/repository/pair/local/finish/#PairMsg FinishLocalPairR GET /config/repository/pair/local/finish/#PairMsg FinishLocalPairR GET
/config/repository/pair/xmpp/start/#BuddyKey StartXMPPPairR GET /config/repository/pair/xmpp/start StartXMPPPairR GET
/config/repository/pair/xmpp/running/#BuddyKey RunningXMPPPairR GET
/config/repository/pair/xmpp/finish/#PairKey FinishXMPPPairR GET /config/repository/pair/xmpp/finish/#PairKey FinishXMPPPairR GET
/config/repository/enable/rsync/#UUID EnableRsyncR GET /config/repository/enable/rsync/#UUID EnableRsyncR GET

View file

@ -1,24 +0,0 @@
<div .span9 .hero-unit>
<h2>
Pairing with another computer
<p>
Pairing with a another computer combines both git-annex repositories #
into a single shared repository, with changes kept in sync.
$if localsupported
<p>
Is the computer you want to pair with located nearby, on the same #
local network? (Or sharing a VPN?)
<br>
If so, the best choice is local pairing. #
<a .btn .btn-primary .btn-small href="@{StartLocalPairR}">
Start local pairing
<p>
Or, you can pair with any of your friends using jabber, or with another #
computer that shares your jabber account.
<p>
$if xmppconfigured
^{buddyListDisplay}
$else
First, you need to #
<a .btn .btn-primary href="@{XMPPForPairingR}">
configure a jabber account

View file

@ -0,0 +1,11 @@
<div .span9 .hero-unit>
<h2>
Pairing with another computer
<p>
Pairing with a another computer combines both git-annex repositories #
into a single shared repository, with changes kept in sync.
<p>
You can pair with any of your friends using jabber, or with another #
computer that shares your own jabber account.
<p>
^{buddyListDisplay}

View file

@ -10,11 +10,26 @@
between computers. between computers.
<h3> <h3>
<a href="@{StartPairR}"> <a href="@{StartLocalPairR}">
<i .icon-plus-sign></i> Pair with another computer <i .icon-plus-sign></i> Local computer
<p> <p>
Connect with another computer used by you, or by a friend, Pair with a computer to automatically keep files in sync
that is also running git-annex. over your local network.
<p>
For easy sharing with friends and devices in the same location.
<h3>
<a href="@{StartXMPPPairR}">
<i .icon-plus-sign></i> Share with a friend
<p>
Pair with a friend's computer, to combine your repositories and #
share files.
<p>
For easy sharing with friends and devices, over the internet.
<h3> <h3>
<i .icon-plus-sign></i> Phone <i .icon-plus-sign></i> Phone

View file

@ -25,7 +25,7 @@
paired paired
$else $else
$if canpair $if canpair
<a .btn .btn-primary .btn-small href="@{StartXMPPPairR buddyid}"> <a .btn .btn-primary .btn-small href="@{RunningXMPPPairR buddyid}">
Start pairing Start pairing
$else $else
not using git-annex not using git-annex