internal WinIrcServer CreateIrcServer() { WinIrcServer ircServer = new WinIrcServer(); if (hostname.Text == "") { return(ShowFormError("No hostname entered!")); } if (Uri.CheckHostName(hostname.Text) == UriHostNameType.Unknown) { return(ShowFormError("Hostname is incorrect!")); } int portInt; if (port.Text == "") { return(ShowFormError("No port entered!")); } if (!int.TryParse(port.Text, out portInt)) { return(ShowFormError("Port is not a number!")); } if (username.Text == "") { return(ShowFormError("No username entered!")); } if (username.Text.Contains(" ")) { return(ShowFormError("Usernames cannot contain spaces!")); } ircServer.Hostname = hostname.Text; ircServer.Port = portInt; ircServer.Ssl = ssl.IsOn; ircServer.Username = username.Text; ircServer.Password = password.Password; ircServer.NickservPassword = nickservPassword.Password; ircServer.Name = server.Text; ircServer.webSocket = webSocket.IsOn; ircServer.Channels = channels.Text; ircServer.invalid = false; formError.Height = 0; if (ircServer.Name == "") { ircServer.Name = ircServer.Hostname; } return(ircServer); }
private void JoinSupport(object sender, RoutedEventArgs e) { WinIrcServer server = new WinIrcServer { Name = "WinIRC Support (Libera)", Hostname = "irc.libera.chat", Port = 6697, Ssl = true, Channels = "#WinIRC" }; MainPage.instance.IrcPrompt(server); }
private void JoinSupport(object sender, RoutedEventArgs e) { WinIrcServer server = new WinIrcServer { Name = "WinIRC Support (Freenode)", Hostname = "chat.freenode.net", Port = 6697, Ssl = true, Channels = "#winirc" }; MainPage.instance.IrcPrompt(server); }
protected async Task Activated(IActivatedEventArgs e) { // Initialise the app if it's not already open Debug.WriteLine("App activated!"); var loaded = await InitApp(e); // Handle toast activation if (e.Kind == ActivationKind.ToastNotification && loaded && NavigationService.Content is MainPage) { MainPage mainPage = NavigationService.Content as MainPage; var args = e as ToastNotificationActivatedEventArgs; var toastActivationArgs = args; // Parse the query string QueryString qryStr = QueryString.Parse(toastActivationArgs.Argument); if (!qryStr.Contains("action")) { return; } var ircHandler = IrcUiHandler.Instance; if (ircHandler == null) { return; } // See what action is being requested if (qryStr["action"] == "reply") { string channel = qryStr["channel"]; string server = qryStr["server"]; string username = qryStr["username"]; var message = args.UserInput["tbReply"].ToString(); if (!ircHandler.connectedServersList.Contains(server)) { return; } if (mainPage != null) { string replyMessage = channel.StartsWith("#") ? (username + ": " + message) : message; mainPage.MentionReply(server, channel, replyMessage); } if (!mainPage.currentChannel.Equals(channel)) { mainPage.SwitchChannel(server, channel, false); } } else if (qryStr["action"] == "viewConversation") { // The conversation ID retrieved from the toast args string channel = qryStr["channel"]; string server = qryStr["server"]; if (mainPage == null) { return; } if (!ircHandler.connectedServersList.Contains(server)) { return; } // If we're already viewing that channel, do nothing if (!mainPage.currentChannel.Equals(channel)) { mainPage.SwitchChannel(server, channel, false); } } } if (e.Kind == ActivationKind.Protocol) { ProtocolActivatedEventArgs eventArgs = e as ProtocolActivatedEventArgs; // TODO: Handle URI activation // The received URI is eventArgs.Uri.AbsoluteUri var uri = eventArgs.Uri; var port = 0; if (uri.Port == 0) { port = 6667; } else { port = uri.Port; } WinIrcServer server = new WinIrcServer { Name = uri.Host, Hostname = uri.Host, Port = port, Ssl = uri.Scheme == "ircs" }; if (uri.Segments.Length >= 2) { server.Channels += "#" + uri.Segments[1]; } MainPage.instance.IrcPrompt(server); } // Ensure the current window is active Window.Current.Activate(); }