Esempio n. 1
0
        static void Main(string[] args)
        {
            Platform.Instance = new Eddie.Platforms.Linux();
            CommandLine.InitSystem(Environment.CommandLine);

            Engine engine = new Engine();

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            if (engine.Initialization(true))
            {
                engine.ConsoleStart();
            }
        }
Esempio n. 2
0
 public Engine()
     : base(false)
 {
     Instance = this;
 }
Esempio n. 3
0
        public void RefreshUi(Engine.RefreshUiMode mode)
        {
            if (this.IsHandleCreated == false)
                return;

            if (m_lockCoordUpdate)
                return;

            if (this.InvokeRequired)
            {
                RefreshUiDelegate inv = new RefreshUiDelegate(this.RefreshUi);

                //this.Invoke(inv, new object[] { mode });
                this.BeginInvoke(inv, new object[] { mode });
            }
            else
            {
                if (m_formReady == false) // To avoid useless calling that Windows.Forms do when initializing controls
                    return;

                // lock (Engine) // TOCLEAN 2.9
                {
                    if( (mode == Core.Engine.RefreshUiMode.MainMessage) || (mode == Core.Engine.RefreshUiMode.Full) )
                    {
                        // Status message
                        String text1 = Engine.WaitMessage;
                        lblWait1.Text = text1;

                        if (Engine.IsWaiting())
                        {
                            pnlWelcome.Visible = false;
                            pnlWaiting.Visible = true;
                            pnlConnected.Visible = false;
                            cmdCancel.Visible = Engine.IsWaitingCancelAllowed();
                            cmdCancel.Enabled = (Engine.IsWaitingCancelPending() == false);
                            mnuConnect.Enabled = cmdCancel.Enabled;

                            mnuStatus.Image = global::Eddie.Lib.Forms.Properties.Resources.status_yellow;

                        }
                        else if (Engine.IsConnected())
                        {
                            pnlWelcome.Visible = false;
                            pnlWaiting.Visible = false;
                            pnlConnected.Visible = true;

                            lblConnectedServerName.Text = Engine.CurrentServer.DisplayName;
                            lblConnectedLocation.Text = Engine.CurrentServer.GetLocationForList();
                            txtConnectedExitIp.Text = Engine.CurrentServer.IpExit;
                            string iconFlagCode = Engine.CurrentServer.CountryCode;
                            Image iconFlag = null;
                            if (imgCountries.Images.ContainsKey(iconFlagCode))
                            {
                                iconFlag = imgCountries.Images[iconFlagCode];
                                lblConnectedCountry.Image = iconFlag;
                            }
                            else
                                lblConnectedCountry.Image = null;

                            mnuStatus.Image = global::Eddie.Lib.Forms.Properties.Resources.status_green;
                        }
                        else
                        {
                            pnlWelcome.Visible = true;
                            pnlWaiting.Visible = false;
                            pnlConnected.Visible = false;

                            mnuStatus.Image = global::Eddie.Lib.Forms.Properties.Resources.status_red;
                        }

                        // Icon
                        {
                            Icon icon;

                            //if(pageView == PageView.Stats)
                            if (Engine.IsConnected())
                            {
                                icon = global::Eddie.Lib.Forms.Properties.Resources.icon1;
                            }
                            else
                            {
                                icon = global::Eddie.Lib.Forms.Properties.Resources.icon_gray1;
                            }

                            if (this.Icon != icon)
                            {
                                this.Icon = icon;
                                if (m_notifyIcon != null)
                                    m_notifyIcon.Icon = icon;
                            }
                        }

                        // Repaint
                        Invalidate();

                        EnabledUi();
                    }

                    if ((mode == Core.Engine.RefreshUiMode.Log) || (mode == Core.Engine.RefreshUiMode.Full))
                    {
                        lock (Engine.LogEntries)
                        {
                            while (Engine.LogEntries.Count > 0)
                            {
                                LogEntry l = Engine.LogEntries[0];
                                Engine.LogEntries.RemoveAt(0);

                                Log(l);
                            }
                        }

                        if (Engine.IsWaiting())
                        {
                            lblWait2.Text = Engine.Logs.GetLogDetailTitle();
                        }
                    }

                    if( (mode == Core.Engine.RefreshUiMode.Stats) || (mode == Core.Engine.RefreshUiMode.Full))
                    {
                        if (Engine.IsConnected())
                        {
                            txtConnectedSince.Text = Engine.Stats.GetValue("VpnConnectionStart");

                            txtConnectedDownload.Text = Core.Utils.FormatBytes(Engine.ConnectedLastDownloadStep, true, false);
                            txtConnectedUpload.Text = Core.Utils.FormatBytes(Engine.ConnectedLastUploadStep, true, false);

                            string notifyText = Engine.Instance.GetConnectedTrayText(true, true);
                            string notifyText2 = Constants.Name + " - " + notifyText;
                            Text = notifyText2;
                            mnuStatus.Text = "> " + notifyText;
                            if (m_notifyIcon != null)
                            {
                                if (notifyText2.Length > 62)
                                    notifyText2 = notifyText2.Substring(0, 62);
                                m_notifyIcon.Text = notifyText2;
                            }
                        }
                    }

                    if (mode == Core.Engine.RefreshUiMode.Full)
                    {
                        m_listViewServers.UpdateList();
                        m_listViewAreas.UpdateList();
                    }
                }

            }
        }