diff --git a/apps/simplex-chat/Main.hs b/apps/simplex-chat/Main.hs index d40022718..85840d05e 100644 --- a/apps/simplex-chat/Main.hs +++ b/apps/simplex-chat/Main.hs @@ -8,7 +8,7 @@ import Simplex.Chat.Controller (versionNumber) import Simplex.Chat.Core import Simplex.Chat.Options import Simplex.Chat.Terminal -import Simplex.Chat.View (serializeChatResponse, viewSocksProxy) +import Simplex.Chat.View (serializeChatResponse) import System.Directory (getAppUserDataDirectory) import System.Terminal (withTerminal) @@ -35,6 +35,9 @@ welcome ChatOpts {dbFilePrefix, socksProxy} = putStrLn [ "SimpleX Chat v" ++ versionNumber, "db: " <> dbFilePrefix <> "_chat.db, " <> dbFilePrefix <> "_agent.db", - viewSocksProxy socksProxy, + maybe + "direct network connection - use `/network` command or `-x` CLI option to connect via SOCKS5 at :9050" + (("using SOCKS5 proxy " <>) . show) + socksProxy, "type \"/help\" or \"/h\" for usage info" ] diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index a9d598601..e2a2b8e8f 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -2467,6 +2467,7 @@ chatCommandP = ("/help groups" <|> "/help group" <|> "/hg") $> ChatHelp HSGroups, ("/help address" <|> "/ha") $> ChatHelp HSMyAddress, ("/help messages" <|> "/hm") $> ChatHelp HSMessages, + ("/help settings" <|> "/hs") $> ChatHelp HSSettings, ("/help" <|> "/h") $> ChatHelp HSMain, ("/group #" <|> "/group " <|> "/g #" <|> "/g ") *> (NewGroup <$> groupProfile), ("/add #" <|> "/add " <|> "/a #" <|> "/a ") *> (AddMember <$> displayName <* A.space <*> displayName <*> memberRole), diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index d084423b7..5bd646061 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -89,7 +89,7 @@ data ChatController = ChatController filesFolder :: TVar (Maybe FilePath) -- path to files folder for mobile apps } -data HelpSection = HSMain | HSFiles | HSGroups | HSMyAddress | HSMarkdown | HSMessages +data HelpSection = HSMain | HSFiles | HSGroups | HSMyAddress | HSMarkdown | HSMessages | HSSettings deriving (Show, Generic) instance ToJSON HelpSection where diff --git a/src/Simplex/Chat/Help.hs b/src/Simplex/Chat/Help.hs index 61f98fedd..736508da7 100644 --- a/src/Simplex/Chat/Help.hs +++ b/src/Simplex/Chat/Help.hs @@ -9,6 +9,7 @@ module Simplex.Chat.Help myAddressHelpInfo, messagesHelpInfo, markdownInfo, + settingsInfo, ) where @@ -83,11 +84,10 @@ chatHelpInfo = green "Create your address: " <> highlight "/address", "", green "Other commands:", - indent <> highlight "/help " <> " - help on: " <> listHighlight ["messages", "files", "groups", "address"], + indent <> highlight "/help " <> " - help on: " <> listHighlight ["messages", "files", "groups", "address", "settings"], indent <> highlight "/profile " <> " - show / update user profile", indent <> highlight "/delete " <> " - delete contact and all messages with them", indent <> highlight "/contacts " <> " - list contacts", - indent <> highlight "/smp_servers " <> " - show / set custom SMP servers", indent <> highlight "/markdown " <> " - supported markdown syntax", indent <> highlight "/version " <> " - SimpleX Chat version", indent <> highlight "/quit " <> " - quit chat", @@ -185,3 +185,14 @@ markdownInfo = indent <> highlight "!1 text! " <> " - " <> markdown (colored Red) "red text" <> " (1-6: red, green, blue, yellow, cyan, magenta)", indent <> highlight "#secret# " <> " - " <> markdown Secret "secret text" <> " (can be copy-pasted)" ] + +settingsInfo :: [StyledString] +settingsInfo = + map + styleMarkdown + [ green "Chat settings:", + indent <> highlight "/network " <> " - show / set network access options", + indent <> highlight "/smp_servers " <> " - show / set custom SMP servers", + indent <> highlight "/info " <> " - information about contact connection", + indent <> highlight "/info # " <> " - information about member connection" + ] diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 02dcbc1ee..82cac6c63 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -42,8 +42,8 @@ import qualified Simplex.Messaging.Crypto as C import Simplex.Messaging.Encoding import Simplex.Messaging.Encoding.String import Simplex.Messaging.Parsers (dropPrefix, taggedObjectJSON) +import Simplex.Messaging.Protocol (ProtocolServer (..)) import qualified Simplex.Messaging.Protocol as SMP -import Simplex.Messaging.Transport.Client (SocksProxy) import Simplex.Messaging.Util (bshow) import System.Console.ANSI.Types @@ -81,6 +81,7 @@ responseToView testView = \case HSMyAddress -> myAddressHelpInfo HSMessages -> messagesHelpInfo HSMarkdown -> markdownInfo + HSSettings -> settingsInfo CRWelcome user -> chatWelcome user CRContactsList cs -> viewContactsList cs CRUserContactLink cReqUri autoAccept autoReply -> connReqContact_ "Your chat address:" cReqUri <> autoAcceptStatus_ autoAccept autoReply @@ -492,13 +493,10 @@ viewSMPServers smpServers testView = viewNetworkConfig :: NetworkConfig -> [StyledString] viewNetworkConfig NetworkConfig {socksProxy, tcpTimeout} = - [plain $ viewSocksProxy socksProxy, "TCP timeout: " <> sShow tcpTimeout] - -viewSocksProxy :: Maybe SocksProxy -> String -viewSocksProxy = - maybe - "Direct network connection. Use `/network socks=on` command or `-x` CLI option to connect via SOCKS5 at :9050" - (("using SOCKS5 proxy " <>) . show) + [ plain $ maybe "direct network connection" (("using SOCKS5 proxy " <>) . show) socksProxy, + "TCP timeout: " <> sShow tcpTimeout, + "use `/network socks=[ timeout=]` to change settings" + ] viewContactInfo :: Contact -> ConnectionStats -> [StyledString] viewContactInfo Contact {contactId} stats = @@ -513,12 +511,15 @@ viewGroupMemberInfo GroupInfo {groupId} GroupMember {groupMemberId} stats = viewConnectionStats :: ConnectionStats -> [StyledString] viewConnectionStats ConnectionStats {rcvServers, sndServers} = - ["receiving messages via: " <> viewServers rcvServers | not $ null rcvServers] - <> ["sending messages via: " <> viewServers sndServers | not $ null sndServers] + ["receiving messages via: " <> viewServerHosts rcvServers | not $ null rcvServers] + <> ["sending messages via: " <> viewServerHosts sndServers | not $ null sndServers] viewServers :: [SMPServer] -> StyledString viewServers = plain . intercalate ", " . map (B.unpack . strEncode) +viewServerHosts :: [SMPServer] -> StyledString +viewServerHosts = plain . intercalate ", " . map host + viewUserProfileUpdated :: Profile -> Profile -> [StyledString] viewUserProfileUpdated Profile {displayName = n, fullName, image} Profile {displayName = n', fullName = fullName', image = image'} | n == n' && fullName == fullName' && image == image' = []