Exemplo n.º 1
0
        public override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);
            var server = new JabbRServer {
                Name = "JabbR.net", Address = "https://jabbr.net", JanrainAppName = "jabbr"
            };

            using (var dialog = new ServerDialog(server, true, true))
            {
                dialog.DisplayMode = DialogDisplayMode.Attached;
                var ret = dialog.ShowDialog(Application.Instance.MainForm);
                if (ret == DialogResult.Ok)
                {
                    Debug.WriteLine("Added Server, Name: {0}", server.Name);
                    var config = JabbRApplication.Instance.Configuration;
                    config.AddServer(server);
                    JabbRApplication.Instance.SaveConfiguration();
                    if (AutoConnect)
                    {
                        Application.Instance.AsyncInvoke(delegate
                        {
                            server.Connect();
                        });
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void EnableServer(object obj)
        {
            var dialog = new ServerDialog();

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            try
            {
                var excludedPlugins = Settings.Current.Plugins
                                      .Where(s => !s.Enabled)
                                      .Select(s => s.Name)
                                      .ToArray();

                var initializer = new ServerInitializer
                {
                    AdminPassword   = Settings.Current.AdminPassword,
                    PluginsPath     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"),
                    ExcludedPlugins = excludedPlugins
                };

                ServerModel.Init(initializer);
                ServerModel.Server.Start(Settings.Current.Port, Settings.Current.ServicePort, Settings.Current.StateOfIPv6Protocol);

                InitializeClient(true);
            }
            catch (ArgumentException)
            {
                SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(ParamsErrorKey));

                if (ClientModel.IsInited)
                {
                    ClientModel.Reset();
                }

                if (ServerModel.IsInited)
                {
                    ServerModel.Reset();
                }
            }
        }
Exemplo n.º 3
0
        public override void OnExecuted(EventArgs e)
        {
            base.OnExecuted(e);
            var server = channels.SelectedServer;

            if (server != null)
            {
                using (var dialog = new ServerDialog(server, false, true))
                {
                    dialog.DisplayMode = DialogDisplayMode.Attached;
                    var ret = dialog.ShowDialog(Application.Instance.MainForm);
                    if (ret == DialogResult.Ok)
                    {
                        JabbRApplication.Instance.SaveConfiguration();
                        Debug.WriteLine(string.Format("Edited Server, Name: {0}", server.Name));
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void EnableServer(object obj)
        {
            var dialog = new ServerDialog();

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    var adminPassword   = Settings.Current.AdminPassword;
                    var p2pPort         = Settings.Current.ServerStartP2PPort;
                    var excludedPlugins = Settings.Current.Plugins
                                          .Where(s => !s.Enabled)
                                          .Select(s => s.Name)
                                          .ToArray();

                    var initializer = new ServerInitializer
                    {
                        AdminPassword   = adminPassword,
                        PluginsPath     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectoryName),
                        ExcludedPlugins = excludedPlugins,
                        Certificate     = new X509Certificate2(dialog.CertificatePath, dialog.CertificatePassword),
                    };

                    ServerModel.Init(initializer);

                    var serverStartUri = Connection.CreateTcpchatUri(dialog.ServerAddress);
                    ServerModel.Server.Start(serverStartUri, p2pPort);

                    dialog.SaveSettings();
                }
                catch (Exception e)
                {
                    var errorMessage = Localizer.Instance.Localize(ParamsErrorKey);
                    SelectedRoom.AddSystemMessage($"{errorMessage}\r\n{e.Message}");

                    if (ServerModel.IsInited)
                    {
                        ServerModel.Reset();
                    }
                }
            }
        }
Exemplo n.º 5
0
 public override bool Authenticate(Control parent)
 {
     if (UseSocialLogin)
     {
         var dlg    = new JabbRAuthDialog(Address, JanrainAppName);
         var result = dlg.ShowDialog(parent);
         if (result == DialogResult.Ok)
         {
             UserId = dlg.UserID;
             return(true);
         }
     }
     else
     {
         var dialog = new ServerDialog(this, false, false);
         dialog.DisplayMode = DialogDisplayMode.Attached;
         var ret = dialog.ShowDialog(Application.Instance.MainForm);
         return(ret == DialogResult.Ok);
     }
     return(false);
 }