public QuickConnectDialog(Gtk.Window parent) { Trace.Call(parent); if (parent == null) { throw new ArgumentNullException("parent"); } Build(); TransientFor = parent; f_Controller = new ServerListController(Frontend.UserConfig); f_TreeView.AppendColumn(_("Protocol"), new Gtk.CellRendererText(), "text", 1); f_TreeView.AppendColumn(_("Hostname"), new Gtk.CellRendererText(), "text", 2); f_TreeStore = new Gtk.TreeStore( typeof(ServerModel), typeof(string), // protocol typeof(string) // hostname ); f_TreeView.RowActivated += OnTreeViewRowActivated; f_TreeView.Selection.Changed += OnTreeViewSelectionChanged; f_TreeView.Model = f_TreeStore; }
public ServerListView(Gtk.Window parent, Glade.XML gladeXml) { Trace.Call(parent, gladeXml); if (parent == null) { throw new ArgumentNullException("parent"); } _Parent = parent; _Controller = new ServerListController(Frontend.UserConfig); gladeXml.BindFields(this); _AddButton.Clicked += new EventHandler(OnAddButtonClicked); _EditButton.Clicked += new EventHandler(OnEditButtonClicked); _RemoveButton.Clicked += new EventHandler(OnRemoveButtonClicked); _TreeView.AppendColumn(_("Protocol"), new Gtk.CellRendererText(), "text", 1); _TreeView.AppendColumn(_("Hostname"), new Gtk.CellRendererText(), "text", 2); _TreeStore = new Gtk.TreeStore(typeof(ServerModel), typeof(string), // protocol typeof(string) // hostname ); _TreeView.RowActivated += OnTreeViewRowActivated; _TreeView.Selection.Changed += OnTreeViewSelectionChanged; _TreeView.Model = _TreeStore; }
public void ApplyConfig(UserConfig config) { if (config == null) { throw new ArgumentNullException("config"); } var servers = new ServerListController(config); InitNetworks(servers.GetNetworks()); }
public QuickConnectDialog(Gtk.Window parent) : base(null, parent, Gtk.DialogFlags.DestroyWithParent) { Trace.Call(parent); if (parent == null) { throw new ArgumentNullException("parent"); } Build(); TransientFor = parent; f_Controller = new ServerListController(Frontend.UserConfig); f_TreeView.AppendColumn(_("Protocol"), new Gtk.CellRendererText(), "text", 1); f_TreeView.AppendColumn(_("Hostname"), new Gtk.CellRendererText(), "text", 2); f_TreeStore = new Gtk.TreeStore( typeof(ServerModel), typeof(string), // protocol typeof(string) // hostname ); f_TreeView.RowActivated += OnTreeViewRowActivated; f_TreeView.Selection.Changed += OnTreeViewSelectionChanged; f_TreeView.Model = f_TreeStore; f_Widget.InitProtocols(Frontend.Session.GetSupportedProtocols()); // these fields doesn't make sense here f_Widget.OnStartupConnectCheckButton.Visible = false; f_Widget.NetworkComboBoxEntry.Sensitive = false; f_Widget.ProtocolComboBox.Changed += delegate { CheckConnectButton(); }; f_Widget.HostnameEntry.Changed += delegate { CheckConnectButton(); }; }
public static bool TryOpenChatLink(Uri link) { Trace.Call(link); if (Session == null) { return false; } // supported: // smuxi://freenode/#smuxi // smuxi://freenode/#%23csharp (##csharp) // irc://#smuxi // irc://irc.oftc.net/ // irc://irc.oftc.net/#smuxi // irc://irc.oftc.net:6667/#smuxi // not supported (yet): // smuxi:///meebey IProtocolManager manager = null; var linkPort = link.Port; if (linkPort == -1) { switch (link.Scheme) { case "irc": linkPort = 6667; break; case "ircs": linkPort = 6697; break; } } // decode #%23csharp to ##csharp var linkChat = HttpUtility.UrlDecode(link.Fragment); if (String.IsNullOrEmpty(linkChat) && link.AbsolutePath.Length > 0) { linkChat = link.AbsolutePath.Substring(1); } var linkProtocol = link.Scheme; var linkHost = link.Host; string linkNetwork = null; if (!linkHost.Contains(".")) { // this seems to be a network name linkNetwork = linkHost; } // find existing protocol chat foreach (var chatView in MainWindow.ChatViewManager.Chats) { if (!(chatView is ProtocolChatView)) { continue; } var protocolChat = (ProtocolChatView) chatView; var host = protocolChat.Host; var port = protocolChat.Port; var network = protocolChat.NetworkID; // Check first by network name with fallback to host+port. // The network name has to be checked against the NetworkID and // also ChatModel.ID as the user might have entered a different // network name in settings than the server does if (!String.IsNullOrEmpty(network) && (String.Compare(network, linkNetwork, true) == 0 || String.Compare(chatView.ID, linkNetwork, true) == 0)) { manager = protocolChat.ProtocolManager; break; } if (String.Compare(host, linkHost, true) == 0 && port == linkPort) { manager = protocolChat.ProtocolManager; break; } } if (manager == null) { // only irc may autoconnect to a server switch (linkProtocol) { case "irc": case "ircs": case "smuxi": break; default: return false; } ServerModel server = null; if (!String.IsNullOrEmpty(linkNetwork)) { // try to find a server with this network name and connect to it var serverSettings = new ServerListController(UserConfig); server = serverSettings.GetServerByNetwork(linkNetwork); if (server == null) { // in case someone tried an unknown network return false; } // ignore OnConnectCommands server.OnConnectCommands = null; } else if (!String.IsNullOrEmpty(linkHost)) { server = new ServerModel() { Protocol = linkProtocol, Hostname = linkHost, Port = linkPort }; } if (server != null) { manager = Session.Connect(server, FrontendManager); } } if (String.IsNullOrEmpty(linkChat)) { return true; } // switch to existing chat foreach (var chatView in MainWindow.ChatViewManager.Chats) { if (manager != null && chatView.ProtocolManager != manager) { continue; } if (String.Compare(chatView.ID, linkChat, true) == 0) { MainWindow.ChatViewManager.CurrentChatView = chatView; return true; } } // join chat if (manager != null) { var chat = new GroupChatModel(linkChat, linkChat, null); ThreadPool.QueueUserWorkItem(delegate { try { manager.OpenChat(FrontendManager, chat); } catch (Exception ex) { Frontend.ShowException(ex); } }); } return true; }
protected void OnAddServerActionActivated(object sender, EventArgs e) { Trace.Call(sender, e); ServerDialog dialog = null; try { var controller = new ServerListController(Frontend.UserConfig); dialog = new ServerDialog(Parent, null, Frontend.Session.GetSupportedProtocols(), controller.GetNetworks()); int res = dialog.Run(); ServerModel server = dialog.GetServer(); if (res != (int) Gtk.ResponseType.Ok) { return; } controller.AddServer(server); controller.Save(); } catch (InvalidOperationException ex) { Frontend.ShowError(Parent, _("Unable to add server: "), ex); } catch (Exception ex) { Frontend.ShowException(Parent, ex); } finally { if (dialog != null) { dialog.Destroy(); } } }
public void Connect(FrontendManager fm, string server, int port, string[] nicks, string user, string pass) { Trace.Call(fm, server, port, nicks, user, pass); _FrontendManager = fm; _Host = server; _Port = port; _Nicknames = nicks; _Username = user; _Password = pass; // add fallbacks if only one nick was specified, else we get random // number nicks when nick collisions happen if (_Nicknames.Length == 1) { _Nicknames = new string[] { _Nicknames[0], _Nicknames[0] + "_", _Nicknames[0] + "__" }; } // TODO: use config for single network chat or once per network manager var servers = new ServerListController(Session.UserConfig); var serverModel = servers.GetServer(Protocol, server); _ServerModel = serverModel; ApplyConfig(Session.UserConfig, serverModel); string network; if (serverModel != null && !String.IsNullOrEmpty(serverModel.Network)) { network = serverModel.Network; } else { network = server; } _Network = network; _NetworkChat = new ProtocolChatModel(network, "IRC " + network, this); // BUG: race condition when we use Session.AddChat() as it pushes this already // to the connected frontend and the frontend will sync and get the page 2 times! //Session.Chats.Add(_NetworkChat); // NOTABUG: the frontend manager needs to take care for that Session.AddChat(_NetworkChat); Session.SyncChat(_NetworkChat); _RunThread = new Thread(new ThreadStart(_Run)); _RunThread.IsBackground = true; _RunThread.Name = "IrcProtocolManager ("+server+":"+port+") listener"; _RunThread.Start(); _LagWatcherThread = new Thread(new ThreadStart(_LagWatcher)); _LagWatcherThread.Name = "IrcProtocolManager ("+server+":"+port+") lag watcher"; _LagWatcherThread.Start(); }
public override void Connect(FrontendManager fm, string host, int port, string username, string password) { Trace.Call(fm, host, port, username, "XXX"); f_Username = username; var proxyType = (string) Session.UserConfig["Connection/ProxyType"]; if (proxyType.ToLower() == "http") { var uriBuilder = new UriBuilder(); uriBuilder.Scheme = "http"; uriBuilder.Host = (string) Session.UserConfig["Connection/ProxyHostname"]; uriBuilder.Port = (int) Session.UserConfig["Connection/ProxyPort"]; uriBuilder.UserName = (string) Session.UserConfig["Connection/ProxyUsername"]; uriBuilder.Password = (string) Session.UserConfig["Connection/ProxyPassword"]; var proxyUri = uriBuilder.ToString(); f_WebProxy = new WebProxy(proxyUri); } f_OptionalProperties = new OptionalProperties(); if (f_WebProxy != null) { f_OptionalProperties.Proxy = f_WebProxy; } f_ProtocolChat = new ProtocolChatModel(NetworkID, "Twitter " + username, this); Session.AddChat(f_ProtocolChat); Session.SyncChat(f_ProtocolChat); string msg; msg = String.Format(_("Connecting to Twitter...")); fm.SetStatus(msg); Session.AddTextToChat(f_ProtocolChat, "-!- " + msg); try { var key = GetApiKey(); f_OAuthTokens = new OAuthTokens(); f_OAuthTokens.ConsumerKey = key[0]; f_OAuthTokens.ConsumerSecret = key[1]; MessageBuilder builder; var servers = new ServerListController(Session.UserConfig); var server = servers.GetServer(Protocol, username); if (server != null) { if (password == null) { // no password passed, use server password password = server.Password; } } password = password ?? String.Empty; var access = password.Split('|'); if (password.Length == 0 || access.Length == 1) { // new account or basic auth user that needs to be migrated var reqToken = OAuthUtility.GetRequestToken(key[0], key[1], "oob", f_WebProxy); f_RequestToken = reqToken.Token; var authUri = OAuthUtility.BuildAuthorizationUri(f_RequestToken); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText(_("Twitter authorization required.")); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); /* _("Twitter authorization required, please open the " + "following URL and enter the returned PIN using the " + "/pin command: {0}"), String.Empty ); */ builder = CreateMessageBuilder(); builder.AppendEventPrefix(); // TRANSLATOR: do NOT change the position of {0}! builder.AppendText( _("Please open the following URL and click " + "\"Allow\" to allow Smuxi to connect to your " + "Twitter account: {0}"), String.Empty ); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText(" "); builder.AppendUrl(authUri.AbsoluteUri); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText( _("Once you have allowed Smuxi to access your " + "Twitter account, Twitter will provide a PIN.") ); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText(_("Please type: /pin PIN_FROM_TWITTER")); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); } else { f_OAuthTokens.AccessToken = access[0]; f_OAuthTokens.AccessTokenSecret = access[1]; } } catch (Exception ex) { #if LOG4NET f_Logger.Error("Connect(): Exception", ex); #endif fm.SetStatus(_("Connection failed!")); Session.AddTextToChat(f_ProtocolChat, "-!- " + _("Connection failed! Reason: ") + ex.Message ); return; } // twitter is sometimes pretty slow, so fetch this in the background ThreadPool.QueueUserWorkItem(delegate { try { // FIXME: replace with AutoResetEvent while (!HasTokens) { Thread.Sleep(1000); } var message = _("Fetching user details from Twitter, please wait..."); Session.AddTextToChat(f_ProtocolChat, "-!- " + message); UpdateUser(); message = _("Finished fetching user details."); Session.AddTextToChat(f_ProtocolChat, "-!- " + message); f_IsConnected = true; fm.UpdateNetworkStatus(); msg =_("Successfully connected to Twitter."); fm.SetStatus(msg); Session.AddTextToChat(f_ProtocolChat, "-!- " + msg); f_Listening = true; f_FriendsTimelineChat.PersonCount = f_RepliesChat.PersonCount = f_DirectMessagesChat.PersonCount = (int) f_TwitterUser.NumberOfFriends; } catch (Exception ex) { var message = _("Failed to fetch user details from Twitter. Reason: "); #if LOG4NET f_Logger.Error("Connect(): " + message, ex); #endif Session.AddTextToChat(f_ProtocolChat, "-!- " + message + ex.Message); fm.SetStatus(_("Connection failed!")); Session.AddTextToChat(f_ProtocolChat, "-!- " + _("Connection failed! Reason: ") + ex.Message ); } }); ThreadPool.QueueUserWorkItem(delegate { try { // FIXME: replace with AutoResetEvent // f_TwitterUser needed for proper self detection in the // CreatePerson() method while (!HasTokens || f_TwitterUser == null) { Thread.Sleep(1000); } var message = _("Fetching friends from Twitter, please wait..."); Session.AddTextToChat(f_ProtocolChat, "-!- " + message); UpdateFriends(); message = _("Finished fetching friends."); Session.AddTextToChat(f_ProtocolChat, "-!- " + message); } catch (Exception ex) { var message = _("Failed to fetch friends from Twitter. Reason: "); #if LOG4NET f_Logger.Error("Connect(): " + message, ex); #endif Session.AddTextToChat(f_ProtocolChat, "-!- " + message + ex.Message); } }); OpenFriendsTimelineChat(); OpenRepliesChat(); OpenDirectMessagesChat(); }
public void CommandPin(CommandModel cd) { if (String.IsNullOrEmpty(cd.Parameter)) { NotEnoughParameters(cd); return; } var pin = cd.Parameter.Trim(); MessageBuilder builder; if (String.IsNullOrEmpty(f_RequestToken)) { builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText(_("No pending authorization request!")); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); return; } var reqToken = f_RequestToken; f_RequestToken = null; var key = GetApiKey(); OAuthTokenResponse response; try { response = OAuthUtility.GetAccessToken(key[0], key[1], reqToken, pin, f_WebProxy); } catch (Exception ex) { #if LOG4NET f_Logger.Error("CommandPin(): GetAccessToken() threw Exception!", ex); #endif builder = CreateMessageBuilder(); builder.AppendEventPrefix(); // TRANSLATOR: {0} contains the reason of the failure builder.AppendText( _("Failed to authorize with Twitter: {0}"), ex.Message ); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText( _("Twitter did not accept your PIN. " + "Did you enter it correctly?") ); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText( _("Please retry by closing this tab and reconnecting to " + "the Twitter \"{0}\" account."), f_Username ); // allow the user to re-enter the pin // LAME: An incorrect PIN invalidates the request token! //f_RequestToken = reqToken; return; } #if LOG4NET f_Logger.Debug("CommandPin(): retrieved " + " AccessToken: " + response.Token + " AccessTokenSecret: " + response.TokenSecret + " ScreenName: " + response.ScreenName + " UserId: " + response.UserId); #endif var servers = new ServerListController(Session.UserConfig); var server = servers.GetServer(Protocol, response.ScreenName); if (server == null) { server = new ServerModel() { Protocol = Protocol, Network = String.Empty, Hostname = response.ScreenName, Username = response.ScreenName, Password = String.Format("{0}|{1}", response.Token, response.TokenSecret), OnStartupConnect = true }; servers.AddServer(server); var obsoleteServer = servers.GetServer(Protocol, String.Empty); if (obsoleteServer != null && obsoleteServer.Username.ToLower() == response.ScreenName.ToLower()) { // found an old server entry for this user using basic auth servers.RemoveServer(Protocol, String.Empty); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText( _("Migrated Twitter account from basic auth to OAuth.") ); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); } } else { // update token server.Password = String.Format("{0}|{1}", response.Token, response.TokenSecret); servers.SetServer(server); } servers.Save(); builder = CreateMessageBuilder(); builder.AppendEventPrefix(); builder.AppendText(_("Successfully authorized Twitter account " + "\"{0}\" for Smuxi"), response.ScreenName); Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage()); f_OAuthTokens.AccessToken = response.Token; f_OAuthTokens.AccessTokenSecret = response.TokenSecret; f_Username = response.ScreenName; }
public static void Init() { if (_IsInitialized) { return; } _IsInitialized = true; var asm = Assembly.GetEntryAssembly(); if (asm == null) { asm = Assembly.GetAssembly(typeof(Engine)); } var asm_name = asm.GetName(false); var distVersion = Defines.DistVersion; if (!String.IsNullOrEmpty(distVersion)) { distVersion = String.Format(" ({0})", distVersion); } _VersionString = String.Format( "{0} {1}{2} - running on {3} {4}", Path.GetFileNameWithoutExtension(asm_name.Name), AssemblyVersion, distVersion, Platform.OperatingSystem, Platform.Architecture ); _Config = new Config(); _Config.Load(); // migration config settins from 1.0 or earlier to 1.1 if (_Config.PreviousVersion == null || _Config.PreviousVersion < new Version(1, 1)) { // migrate all existing IRC connections for Slack to the // SlackProtocolManager var users = (string[])_Config["Engine/Users/Users"]; if (users != null) { foreach (var user in users) { var userConfig = new UserConfig(_Config, user); var serverController = new ServerListController(userConfig); var servers = serverController.GetServerList(); foreach (var server in servers) { if (server.Protocol != "IRC") { continue; } if (!server.Hostname.EndsWith(".irc.slack.com")) { continue; } #if LOG4NET f_Logger.InfoFormat( "Migrating Slack server '{0}' of user '{1}' " + "from IRC to Slack protocol manager", server, user ); #endif // this is Slack IRC bridge connection var migratedServer = new ServerModel(server); migratedServer.ServerID = null; migratedServer.Protocol = "Slack"; serverController.AddServer(migratedServer); // remove old Slack server with IRC as protocol serverController.RemoveServer(server.Protocol, server.ServerID); } } } _Config["Engine/ConfigVersion"] = _Config.CurrentVersion.ToString(); } _Config.Save(); string location = Path.GetDirectoryName(asm.Location); if (String.IsNullOrEmpty(location) && Environment.OSVersion.Platform == PlatformID.Unix) { // we are mkbundled var locationBuilder = new StringBuilder(8192); if (Mono.Unix.Native.Syscall.readlink("/proc/self/exe", locationBuilder) >= 0) { location = Path.GetDirectoryName(locationBuilder.ToString()); } } _ProtocolManagerFactory = new ProtocolManagerFactory(); _ProtocolManagerFactory.LoadAllProtocolManagers(location); }
public void RegisterFrontendUI(IFrontendUI ui) { Trace.Call(ui); if (ui == null) { throw new ArgumentNullException("ui"); } string uri = GetUri(ui); #if LOG4NET f_Logger.Debug("Registering UI with URI: " + uri); #endif // add the FrontendManager to the hashtable with an unique .NET remoting identifier FrontendManager fm = new FrontendManager(this, ui); _FrontendManagers[uri] = fm; // if this is the first frontend, we process OnStartupCommands if (!_OnStartupCommandsProcessed) { _OnStartupCommandsProcessed = true; MessageModel msg; msg = new MessageModel(); msg.MessageParts.Add( new TextMessagePartModel(new TextColor(0xFF0000), null, false, true, false, _("Welcome to Smuxi"))); AddMessageToChat(_SessionChat, msg); msg = new MessageModel(); msg.MessageParts.Add( new TextMessagePartModel(null, null, false, true, false, _("Type /help to get a list of available commands."))); AddMessageToChat(_SessionChat, msg); msg = new MessageModel(); msg.MessageParts.Add( new TextMessagePartModel(null, null, false, true, false, _("After you have made a connection the list of available commands changes, just use /help again."))); AddMessageToChat(_SessionChat, msg); foreach (string command in (string[])_UserConfig["OnStartupCommands"]) { if (command.Length == 0) { continue; } CommandModel cd = new CommandModel(fm, _SessionChat, (string)_UserConfig["Interface/Entry/CommandCharacter"], command); bool handled; handled = Command(cd); if (!handled) { if (fm.CurrentProtocolManager != null) { fm.CurrentProtocolManager.Command(cd); } } } // process server specific connects/commands ServerListController serverCon = new ServerListController(_UserConfig); IList<ServerModel> servers = serverCon.GetServerList(); foreach (ServerModel server in servers) { if (!server.OnStartupConnect) { continue; } IProtocolManager protocolManager = _CreateProtocolManager(fm, server.Protocol); if (protocolManager == null) { continue; } _ProtocolManagers.Add(protocolManager); string password = null; // only pass non-empty passwords to Connect() if (!String.IsNullOrEmpty(server.Password)) { password = server.Password; } protocolManager.Connect(fm, server.Hostname, server.Port, server.Username, password); // if the connect command was correct, we should be able to get // the chat model if (protocolManager.Chat == null) { fm.AddTextToChat(_SessionChat, String.Format(_("Automatic connect to {0} failed!"), server.Hostname + ":" + server.Port)); continue; } if (server.OnConnectCommands != null && server.OnConnectCommands.Count > 0) { // copy the server variable into the loop scope, else it will always be the same object in the anonymous method! ServerModel ser = server; protocolManager.Connected += delegate { foreach (string command in ser.OnConnectCommands) { if (command.Length == 0) { continue; } CommandModel cd = new CommandModel(fm, protocolManager.Chat, (string)_UserConfig["Interface/Entry/CommandCharacter"], command); protocolManager.Command(cd); } }; } } } }
public void Connect(FrontendManager fm, string host, int port, string username, string password, string resource) { Trace.Call(fm, host, port, username, "XXX"); _FrontendManager = fm; Host = host; Port = port; // TODO: use config for single network chat or once per network manager _NetworkChat = new ProtocolChatModel(NetworkID, "Jabber " + host, this); Session.AddChat(_NetworkChat); Session.SyncChat(_NetworkChat); // HACK: try to lookup settings via config var servers = new ServerListController(Session.UserConfig); var serverModel = servers.GetServer(Protocol, host); if (serverModel != null) { ApplyConfig(Session.UserConfig, serverModel); } if (username.Contains("@")) { var user = username.Split('@')[0]; var server = username.Split('@')[1]; _JabberClient.NetworkHost = host; _JabberClient.Server = server; _JabberClient.User = user; } else { _JabberClient.Server = host; _JabberClient.User = username; } _JabberClient.Port = port; _JabberClient.Password = password; _JabberClient.Resource = resource; _JabberClient.Connect(); }
public void RegisterFrontendUI(IFrontendUI ui) { Trace.Call(ui); if (ui == null) { throw new ArgumentNullException("ui"); } string uri = GetUri(ui); #if LOG4NET f_Logger.Debug("Registering UI with URI: " + uri); #endif // add the FrontendManager to the hashtable with an unique .NET remoting identifier FrontendManager fm = new FrontendManager(this, ui); lock (_FrontendManagers) { _FrontendManagers[uri] = fm; } // if this is the first frontend, we process OnStartupCommands if (!_OnStartupCommandsProcessed) { _OnStartupCommandsProcessed = true; string str; MessageModel msg; msg = new MessageModel(); msg.MessageParts.Add( new TextMessagePartModel(new TextColor(0xFF0000), null, false, true, false, _("Welcome to Smuxi"))); AddMessageToChat(_SessionChat, msg); msg = new MessageModel(); msg.MessageParts.Add( new TextMessagePartModel(null, null, false, true, false, _("Type /help to get a list of available commands."))); AddMessageToChat(_SessionChat, msg); str = _("After you have made a connection the list of " + "available commands changes. Use the /help command " + "again to see the extended command list."); msg = new MessageModel(); msg.MessageParts.Add( new TextMessagePartModel(null, null, false, true, false, str)); AddMessageToChat(_SessionChat, msg); foreach (string command in (string[])_UserConfig["OnStartupCommands"]) { if (command.Length == 0) { continue; } CommandModel cd = new CommandModel(fm, _SessionChat, (string)_UserConfig["Interface/Entry/CommandCharacter"], command); bool handled; handled = Command(cd); if (!handled) { if (fm.CurrentProtocolManager != null) { fm.CurrentProtocolManager.Command(cd); } } } // process server specific connects/commands ServerListController serverCon = new ServerListController(_UserConfig); IList<ServerModel> servers = serverCon.GetServerList(); foreach (ServerModel server in servers) { if (!server.OnStartupConnect) { continue; } bool isError = false; try { IProtocolManager protocolManager = Connect(server, fm); // if the connect command was correct, we should be // able to get the chat model if (protocolManager.Chat == null) { isError = true; } } catch (Exception ex) { #if LOG4NET f_Logger.Error("RegisterFrontendUI(): Exception during "+ "automatic connect: ", ex); #endif isError = true; } if (isError) { fm.AddTextToChat( _SessionChat, String.Format( _("Automatic connect to {0} failed!"), server.Hostname + ":" + server.Port ) ); continue; } } } }