Beispiel #1
0
        private void WindowMonitoring_Load(object sender, EventArgs e)
        {
            lblVersionID.Text = Global.Settings.CurrentVersion;

            Log.DebugFormat("[WindowMonitoring] Version: {0}", lblVersionID.Text);

            CreateTooltipsForStatics();

            DelegateStartProcess startProcessFunction = StartPilotAuthorizeFlow;

            new Thread(() => new CrestApiListener().ListenLocalhost(startProcessFunction))
            {
                IsBackground = true
            }.Start();

            SetStyle(ControlStyles.ResizeRedraw, true);

            _containerAuthorization.RefreshAuthorizationStatus();

            if (IsNeedUpdateApplication() == false)
            {
                ContainerTabs.Activate("Authorization");
                OpenAuthorizationPanel();
            }
            else
            {
                ContainerTabs.Activate("Version");
            }

            Size = ContainerTabs.Active().Size;

            //TODO: Recomment before create version!!!
            Global.Metrics.PublishOnApplicationStart(Global.Settings.CurrentVersion);
        }
Beispiel #2
0
        public frmMain()
        {
            InitializeComponent();

            DelegateStartProcess startProcessFunction = StartPilotAuthorizeFlow;

            new Thread(() => new CrestApiListener().ListenLocalhost(startProcessFunction))
            {
                IsBackground = true
            }.Start();
        }
Beispiel #3
0
        private void WindowMonitoring_Load(object sender, EventArgs e)
        {
            lblVersionID.Text = Global.Version;

            ucContainreSolarSystem = new whlSolarSystem();

            ucContainerlSolarSystemOffline = new whlSolarSystemOffline();

            ucContainerBookmarks = new whlBookmarks();

            ucContainreAuthorization = new whlAuthorization();

            Controls.Add(ucContainerPilotInfo);
            Controls.Add(ucContainerBookmarks);
            Controls.Add(ucContainreSolarSystem);
            Controls.Add(ucContainerlSolarSystemOffline);
            Controls.Add(ucContainreAuthorization);

            Global.Browser = new whlBrowser(OpenWebBrowserPanel);

            Controls.Add(Global.Browser);

            Log.DebugFormat("[WindowMonitoring] Version: {0}", lblVersionID.Text);

            Size = ContainerTabs.Active().Size;
            ResizeWindow();
            CreateTooltipsForStatics();

            var identity  = System.Security.Principal.WindowsIdentity.GetCurrent();
            var principal = new System.Security.Principal.WindowsPrincipal(identity);

            if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
            {
                MessageBox.Show("For use return tokens from EVE CREST we need run WHL as administrator");
            }

            DelegateStartProcess startProcessFunction = StartPilotAuthorizeFlow;

            new Thread(() => new CrestApiListener().ListenLocalhost(startProcessFunction))
            {
                IsBackground = true
            }.Start();

            SetStyle(ControlStyles.ResizeRedraw, true);

            HideAllContainers();

            OpenAuthorizationPanel();

            CheckVersion();
        }
Beispiel #4
0
        public void ListenLocalhost(DelegateStartProcess StartPilotAuthorizeFlow)
        {
            try
            {
                var          web    = new HttpListener();
                const string url    = "http://localhost";
                string       port   = Global.Settings.CCPSSO_AUTH_PORT;
                var          prefix = string.Format("{0}:{1}/", url, port);

                web.Prefixes.Add(prefix);

                Log.DebugFormat("Listening new ..");

                web.Start();

                while (true)
                {
                    var context = web.GetContext();

                    Task.Run(() =>
                    {
                        var code = "";

                        Log.DebugFormat("Get new request.");

                        foreach (var key in context.Request.QueryString.Keys.Cast <object>().Where(key => key.ToString() == "code"))
                        {
                            code = context.Request.QueryString[key.ToString()];
                        }

                        using (var writer = new StreamWriter(context.Response.OutputStream))
                        {
                            writer.WriteLine("Wormhole Locator authorize complete. Close this tab and return to application.");
                        }
                        context.Response.OutputStream.Close();

                        if (string.IsNullOrEmpty(code) == false)
                        {
                            StartPilotAuthorizeFlow(code);
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                //Global.Settings.IsAuthorizationEnabled = false;
                Log.ErrorFormat("[CrestApiListener.ListenLocalhost] IsAuthorizationEnabled set FALSE Critical error = {0}", ex);
            }
        }
Beispiel #5
0
        public void ListenLocalhost(DelegateStartProcess StartPilotAuthorizeFlow)
        {
            var web = new HttpListener();

            const string url    = "http://localhost";
            const string port   = "8080";
            var          prefix = string.Format("{0}:{1}/", url, port);

            web.Prefixes.Add(prefix);

            Log.DebugFormat("Listening new ..");

            web.Start();

            while (true)
            {
                var context = web.GetContext();

                Task.Run(() =>
                {
                    var code = "";

                    Log.DebugFormat("Get new request.");

                    foreach (var key in context.Request.QueryString.Keys.Cast <object>().Where(key => key.ToString() == "code"))
                    {
                        code = context.Request.QueryString[key.ToString()];
                    }

                    using (var writer = new StreamWriter(context.Response.OutputStream))
                    {
                        writer.WriteLine("Wormhole Locator authorize complete. Close this tab and return to application.");
                    }
                    context.Response.OutputStream.Close();

                    if (string.IsNullOrEmpty(code) == false)
                    {
                        StartPilotAuthorizeFlow(code);
                    }
                });
            }
        }
        public WindowMonitoring()
        {
            try
            {
                InitializeComponent();

                ContainersInitialization();

                ContainerTabs = new Tabs {
                    Parent = this
                };

                ContainerTabs.OnChangeTab += Event_OnChangeActiveTab;

                ContainerTabs.AddTab("Authorization", TabSize.Small, cmdAuthirizationPanel1, _containerAuthorization);
                //ContainerTabs.AddTab("Location", TabSize.Small, cmdLocation1, _containerSolarSystem);
                ContainerTabs.AddTab("SolarSystem", TabSize.Small, cmdShowContainerSolarSystem1, _containerSolarSystemOffline);
                ContainerTabs.AddTab("Pilots", TabSize.Small, cmdShowContainerPilots1, _containerPilotInfo);
                ContainerTabs.AddTab("Bookmarks", TabSize.Small, cmdShowContainerBookmarks1, _containerBookmarks);
                //ContainerTabs.AddTab("Signatures", TabSize.Small, null, _containerTravelHistory);
                ContainerTabs.AddTab("WebBrowser", TabSize.Large, cmdOpenWebBrowser1, _containerBrowser);
                ContainerTabs.AddTab("Map", TabSize.Map, cmdMap, _containerMap);
                ContainerTabs.AddTab("Version", TabSize.Large, cmdVersion1, _containerVersion);
                //ContainerTabs.AddTab("LostAndFoundOffice", TabSize.Small, null, _containerLostAndFoundOffice);
                //ContainerTabs.AddTab("Router", TabSize.Small, null, _containerRouter);

                //cmdMap _containerMap

                ContainerTabs.Activate("Authorization");

                Size = ContainerTabs.Active().Size;

                lblSolarSystemName = new LabelWithOptionalCopyTextOnDoubleClick
                {
                    BackColor = Color.Transparent,
                    Font      = new Font("Verdana", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))),
                    ForeColor = Color.LightGray,
                    Location  = new Point(6, 5),
                    Name      = "lblSolarSystemName",
                    Size      = new Size(252, 18),
                    TabIndex  = 5
                };

                lblSolarSystemName.MouseDown += Event_TitleBarMouseDown;

                lblSolarSystemName.DoubleClick += Event_TitleBarDoubleClick;

                TitleBar.Controls.Add(lblSolarSystemName);

                Global.Pilots.OnActivatePilot            += GlobalEvent_ActivatePilot;
                Global.InternalBrowser.OnBrowserNavigate += Event_BrowserNavigate;

                DelegateStartProcess startProcessFunction = StartPilotAuthorizeFlow;
                new Thread(() => new CrestApiListener().ListenLocalhost(startProcessFunction))
                {
                    IsBackground = true
                }.Start();
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("[WindowMonitoring.WindowMonitoring] Critical error {0}", ex);
            }
        }