Beispiel #1
0
        public static void HtmlToCli(string data)
        {
            XmlItem xml = new XmlItem (data);

            string action = xml.GetAttribute ("action");

            // Look WebView.cs comment about the Mono bug
            // Core.Send (data);
            // Alternative workaround, send to JS for direct delivery via /api/command/
            // Maybe totally TOCLEAN if i always use a TCP method.
            Gtk.Application.Invoke (delegate {
                string jsStr = CommonUtils.JsonEncode(data);
                string js = "Eddie.command(\"" + jsStr + "\")";
                m_webBrowser.ExecuteScript (js);
            });
        }
Beispiel #2
0
        public override void OnCommand(XmlItem xml, bool ignoreIfNotExists)
        {
            string action = xml.GetAttribute("action").ToLowerInvariant();

            if(action == "ui.show.preferences")
            {
                Forms.Settings Dlg = new Forms.Settings();
                Dlg.ShowDialog();

                FormMain.EnabledUi();
            }
            else if (action == "ui.show.about")
            {
                Forms.About dlg = new Forms.About();
                dlg.ShowDialog();
            }
            else if (action == "ui.show.menu")
            {
                FormMain.ShowMenu();
            }
            else
                base.OnCommand(xml, ignoreIfNotExists);
        }
Beispiel #3
0
        public virtual void OnCommand(XmlItem xml, bool ignoreIfNotExists)
        {
            string action = xml.GetAttribute("action").ToLowerInvariant();
            if (action == "exit")
            {
                OnExit();
            }
            else if (action == "openvpn")
            {
                SendManagementCommand(xml.GetAttribute("command"));
            }
            else if (action == "ui.show.text")
            {
                OnShowText(xml.GetAttribute("title",""), xml.GetAttribute("body",""));
            }
            else if (action == "ui.show.url")
            {
                Platform.Instance.OpenUrl(xml.GetAttribute("url"));
            }
            else if (action == "ui.show.license")
            {
                XmlItem xml2 = new XmlItem("command");
                xml2.SetAttribute("action", "ui.show.text");
                xml2.SetAttribute("title", "License");
                xml2.SetAttribute("body", ResourcesFiles.GetString("license.txt"));
                Command(xml2);
            }
            else if (action == "ui.show.libraries")
            {
                XmlItem xml2 = new XmlItem("command");
                xml2.SetAttribute("action", "ui.show.text");
                xml2.SetAttribute("title", "Libraries and Tools");
                xml2.SetAttribute("body", ResourcesFiles.GetString("thirdparty.txt"));
                Command(xml2);
            }
            else if (action == "ui.show.website")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "");
            }
            else if (action == "ui.show.ports")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "ports/");
            }
            else if (action == "ui.show.speedtest")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "speedtest/");
            }
            else if (action == "ui.show.clientarea")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "client/");
            }
            else if (action == "ui.show.docs.general")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "software/");
            }
            else if (action == "ui.show.docs.protocols")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_protocols/");
            }
            else if (action == "ui.show.docs.udp_vs_tcp")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/udp_vs_tcp/");
            }
            else if (action == "ui.show.docs.tor")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "tor/");
            }
            else if (action == "ui.show.docs.advanced")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_advanced/");
            }
            else if (action == "ui.show.docs.directives")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_directives/");
            }
            else if (action == "ui.show.docs.lock")
            {
                Platform.Instance.OpenUrl(Constants.WebSite + "/" + "faq/software_lock/");
            }
            else if (action == "ui.show.sources")
            {
                string url = "https://github.com/AirVPN/airvpn-client";
                Platform.Instance.OpenUrl(url);
            }
            else if (action == "ui.show.gpl")
            {
                Platform.Instance.OpenUrl("http://www.gnu.org/licenses/gpl.html");
            }
            else if (action == "ui.show.openvpn.management")
            {
                Platform.Instance.OpenUrl("http://openvpn.net/index.php/open-source/documentation/miscellaneous/79-management-interface.html");
            }
            else if (action == "ui.stats.vpngeneratedovpn")
            {
                if (IsConnected() == false)
                    return;

                OnShowText(Messages.StatsVpnGeneratedOVPN, ConnectedOVPN);
            }
            else if (action == "ui.stats.systemreport")
            {
                OnShowText(Messages.StatsSystemReport, Platform.Instance.GenerateSystemReport());
            }
            else if (action == "ui.stats.pinger")
            {
                Core.Threads.Pinger.Instance.InvalidateAll();
                OnRefreshUi(Core.Engine.RefreshUiMode.Full);
            }
            else if (action == "ui.stats.manifestlastupdate")
            {
                Core.Threads.Manifest.Instance.ForceUpdate = true;
            }
            else if (action == "ui.stats.pathapp")
            {
                Platform.Instance.OpenDirectoryInFileManager(Stats.Get("PathApp").Value);
            }
            else if (action == "ui.stats.pathprofile")
            {
                Platform.Instance.OpenDirectoryInFileManager(Stats.Get("PathProfile").Value);
            }
            else if (action == "providers.add.airvpn")
            {
                Engine.Instance.ProvidersManager.AddProvider("AirVPN", null);
            }
            else if (action == "providers.add.openvpn")
            {
                Engine.Instance.ProvidersManager.AddProvider("OpenVPN", null);
            }
            else if (action == "testlog")
            {
                Engine.Instance.Logs.Log(LogType.Warning, "Test Log " + Utils.GetRandomToken());
            }
            else if (action == "ui.hello")
            {
                Engine.Instance.Command("ui.show.ready");
            }
            else if (action == "ui.start")
            {
                UiSendOsInfo();
                UiSendStatusInfo();
                UiSendQuickInfo();
            }
            else
            {
                if(ignoreIfNotExists == false)
                    throw new Exception(MessagesFormatter.Format(Messages.CommandUnknown, xml.ToString()));
            }
        }