예제 #1
0
        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();

                // reload server list in join bar
                JoinWidget.InitNetworks(controller.GetNetworks());
            } catch (InvalidOperationException ex) {
                Frontend.ShowError(Parent, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                }
            }
        }
예제 #2
0
        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;
        }
예제 #3
0
파일: MainWindow.cs 프로젝트: licnep/smuxi
        protected virtual void OnServerAddButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            ServerDialog dialog = null;

            try {
                ServerListController controller = new ServerListController(Frontend.UserConfig);
                dialog = new ServerDialog(this, 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(this, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                }
            }
        }
    public override void OnReceivedBroadcast(string fromAddress, string data)
    {
        GameObject ServerList = GameObject.FindGameObjectWithTag("ServerList");

        list = ServerList.GetComponent <ServerListController>();
        list.AddServerInfo(fromAddress, data);
        base.OnReceivedBroadcast(fromAddress, data);
    }
예제 #5
0
        public void ApplyConfig(UserConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            var servers = new ServerListController(config);

            InitNetworks(servers.GetNetworks());
        }
예제 #6
0
        void Init()
        {
            _Controller = new ServerListController(Frontend.UserConfig);

            _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
                                           );
            _TreeStore.SetSortColumnId(0, Gtk.SortType.Ascending);
            _TreeStore.SetSortFunc(0, SortTreeStore);
            _TreeView.RowActivated      += OnTreeViewRowActivated;
            _TreeView.Selection.Changed += OnTreeViewSelectionChanged;
            _TreeView.Model              = _TreeStore;
        }
예제 #7
0
        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();
            };
        }
예제 #8
0
        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);
        }