示例#1
0
        private void DoRegister()
        {
            string          network         = server.Connection.ServerProperties["Network"];
            NetworkSettings networkSettings = IrcSettingsManager.Instance.GetNetwork(server);

            if (networkSettings == null)
            {
                NetworkSettings tempNet;
                if (network == String.Empty)
                {
                    tempNet = IrcSettingsManager.Instance.AddNetwork(server.Url);
                    //TODO: Get domain name to use as network name, or something
                    network = "Network";
                }
                else
                {
                    tempNet = IrcSettingsManager.Instance.AddNetwork(network);
                }

                tempNet.AddServer(new ServerSettings(server.Url, "Random", server.Port.ToString(),
                                                     server.Connection.ConnectionData.Ssl)
                {
                    AutoConnect = true
                });
            }
            else
            {
                if (network == String.Empty)
                {
                    network = networkSettings.Name;
                }
                else
                {
                    networkSettings.Name = network;
                }

                ServerSettings nServer = networkSettings.GetServer(server.Url);
                if (nServer == null)
                {
                    networkSettings.AddServer(new ServerSettings(server.Url, "Random", server.Port.ToString(),
                                                                 server.Connection.ConnectionData.Ssl)
                    {
                        AutoConnect = true
                    });
                }
            }

            Name = ServerStrings.ServerFormTitleBar.With(
                server.UserNick,
                network,
                server.Url,
                server.Port);

            if (nickRetryFailed)
            {
                AddMessage(ServerStrings.RandomNickMessage);
            }

            nickRetryAttempt = 0;
            nickRetryFailed  = false;

            if (networkSettings == null || networkSettings.Channels == null)
            {
                return;
            }
            foreach (ChannelSettings channel in networkSettings.Channels)
            {
                if (channel.AutoJoin)
                {
                    server.JoinChannel(channel.Name);
                }
            }
        }