summaryrefslogtreecommitdiff
path: root/Command/WebApp.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-28 18:25:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-28 18:25:27 -0400
commitf9aef09f97a864a9bc2663af80736df1a3f0a816 (patch)
treeeb946f52a22763feb0caf4705ac623fefd8b5d5b /Command/WebApp.hs
parentb6eb8760322b3615a05ebc440598379c137c397d (diff)
Android: Added an "Open WebApp" item to the terminal's menu. Should work for Android devices that cannot auto-open the webapp on start.
Diffstat (limited to 'Command/WebApp.hs')
-rw-r--r--Command/WebApp.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs
index d15319078..0a8c62be8 100644
--- a/Command/WebApp.hs
+++ b/Command/WebApp.hs
@@ -157,10 +157,12 @@ firstRun listenhost = do
sendurlback v _origout _origerr url _htmlshim = putMVar v url
openBrowser :: Maybe FilePath -> FilePath -> String -> Maybe Handle -> Maybe Handle -> IO ()
-#ifdef __ANDROID__
-openBrowser mcmd htmlshim realurl outh errh = do
-#else
+#ifndef __ANDROID__
openBrowser mcmd htmlshim _realurl outh errh = do
+#else
+openBrowser mcmd htmlshim realurl outh errh = do
+ {- The Android app has a menu item that opens this file. -}
+ writeFile "/sdcard/git-annex.home/.git-annex-url" realurl
#endif
hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url
hFlush stdout
@@ -171,8 +173,11 @@ openBrowser mcmd htmlshim _realurl outh errh = do
, std_err = maybe Inherit UseHandle errh
}
exitcode <- waitForProcess pid
- unless (exitcode == ExitSuccess) $
+ unless (exitcode == ExitSuccess) $ do
hPutStrLn (fromMaybe stderr errh) "failed to start web browser"
+#ifdef __ANDROID__
+ hPutStrLn (fromMaybe stderr errh) "To open the WebApp, go to the menu and select \"Open WebApp\""
+#endif
where
p = case mcmd of
Just cmd -> proc cmd [htmlshim]