private void cleanupNMTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string Warning = "";
            string Command = Settings.Default.CommandsScriptURL.Substring(Settings.Default.CommandsScriptURL.LastIndexOf('/') + 1);

            Command = Command.Substring(0, Command.Length - 3) + "cgi";
            string WarningTitle = "";

            if (sender == shutdownNMTToolStripMenuItem)
            {
                Warning      = Resources.MessageBox_HaltWarning;
                WarningTitle = Resources.MessageBox_HaltWarningCaption;
                Command     += "?halt";
            }
            else
            if (sender == cleanupNMTDeepToolStripMenuItem)
            {
                Warning      = Resources.MessageBox_DeepCleanWarning;
                WarningTitle = Resources.MessageBox_DeepCleanCaption;
                Command     += "?deepclean";
            }
            else
            if (sender == cleanupNMTToolStripMenuItem)
            {
                Warning      = Resources.MessageBox_CleanWarning;
                WarningTitle = Resources.MessageBox_CleanCaption;
                Command     += "?clean";
            }
            else
            {
                Warning     += Resources.MessageBox_RestartNMTConfirm;
                WarningTitle = Resources.MessageBox_RestartNMTCaption;
                Command     += "?reboot";
            }

            if (MessageBox.Show(Warning, WarningTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                try
                {
                    btnPrev.Enabled = btnNext.Enabled = btnExit.Enabled = menuStrip1.Enabled = false;
                    Application.DoEvents();
                    string LocalFolder = HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CommandsScriptURL, Constants.TemporaryFolder, true, null);

                    RepositoryApplicationInfo app    = new RepositoryApplicationInfo(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], Command, string.Empty, string.Empty);
                    UploadInstaller           ulinst = new UploadInstaller(app, ProgressChanges, OnInstallComplete);
                    ulinst.Install();
                }
                catch (Exception ex)
                {
                    menuStrip1.Enabled = true;
                    UpdateButtonState();
                    Logger.GetInstance().AddLogLine(LogLevel.Error, "Cleanup or restart of NMT failed", ex);
                    MessageBox.Show(Resources.MessageBox_CleanupActionFailed, Resources.MessageBox_CleanupActionCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void installFirmwareToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Resources.MessageBox_InstallFirmwareWarning, Resources.MessageBox_InstallFirmwareCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                OpenFileDialog odf = new OpenFileDialog();
                odf.Title  = Resources.FileDialog_SelectFirmwareFileCaption;
                odf.Filter = Resources.FileDialog_SelectFirmwareFileFilter;
                if (odf.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string LocalFolder = Constants.TemporaryFolder;
                        if (Directory.Exists(LocalFolder))
                        {
                            Directory.Delete(LocalFolder, true);
                        }
                        Directory.CreateDirectory(LocalFolder);

                        File.Copy(odf.FileName, LocalFolder + "firmware.zip");
                        SimpleUnZipper.UnZipTo(LocalFolder + "firmware.zip", LocalFolder);

                        File.Delete(LocalFolder + "firmware.zip");

                        if ((Directory.GetFiles(LocalFolder).Length == 0) && (Directory.GetDirectories(LocalFolder).Length == 1))
                        {
                            LocalFolder = Directory.GetDirectories(LocalFolder)[0] + Path.DirectorySeparatorChar;
                        }
                        HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CommandsScriptURL, LocalFolder, false, ProgressChanges);

                        btnPrev.Enabled = btnNext.Enabled = btnExit.Enabled = menuStrip1.Enabled = false;
                        Application.DoEvents();
                        RepositoryApplicationInfo app    = new RepositoryApplicationInfo(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], "commands.cgi?firmwareinstall", string.Empty, string.Empty);
                        UploadInstaller           ulinst = new UploadInstaller(app, ProgressChanges, OnInstallComplete);
                        ulinst.Install();
                    }
                    catch (Exception ex)
                    {
                        menuStrip1.Enabled = true;
                        UpdateButtonState();
                        Logger.GetInstance().AddLogLine(LogLevel.Error, "Installing firmware failed", ex);
                        MessageBox.Show(Resources.MessageBox_InstallFirmwareFailed, Resources.MessageBox_InstallFirmwareCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void FillMetaInfo()
        {
            HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType));

            if ((Directory.GetFiles(LocalFolder).Length == 0) && (Directory.GetDirectories(LocalFolder).Length == 1))
            {
                LocalFolder = Directory.GetDirectories(LocalFolder)[0] + Path.DirectorySeparatorChar;
            }

            if (InstallItem is RepositoryApplicationInfo)
            {
                RepositoryApplicationInfo app = (RepositoryApplicationInfo)InstallItem;
                UploadLocation      = "/";
                CleanupAfterInstall = (app.Name != string.Empty);

                //executing commands (firmare, clean etc) will not have an appname
                //and will not require a appinit or installprepare
                if (app.Name != string.Empty)
                {
                    ExecuteScriptSequence.Add(Settings.Default.AppInitScriptURL.Substring(Settings.Default.AppInitScriptURL.LastIndexOf("/") + 1));
                    if (!app.InstallScript.StartsWith("Apps/"))
                    {
                        ExecuteScriptSequence.Add(string.Format(Settings.Default.InstallPrepareScriptURL.Substring(Settings.Default.InstallPrepareScriptURL.LastIndexOf("/") + 1) + "?autostart_add={0}&webservice_name={1}&webservice_url={2}", "", HttpCommands.UrlEncode(app.Name), HttpCommands.UrlEncode(app.GayaInterfaceURL)));
                    }
                    else
                    {
                        ExecuteScriptSequence.Add(string.Format(Settings.Default.InstallPrepareScriptURL.Substring(Settings.Default.InstallPrepareScriptURL.LastIndexOf("/") + 1) + "?autostart_add={0}&webservice_name={1}&webservice_url={2}", "", string.Empty, string.Empty));
                    }
                }
                ExecuteScriptSequence.Add(app.InstallScript);

                DeleteFoldersBeforeInstall.Clear();
                DeleteFilesBeforeInstall.Clear();
            }

            if (InstallItem is RepositoryThemeInfo)
            {
                RepositoryThemeInfo theme = (RepositoryThemeInfo)InstallItem;
                UploadLocation      = "/Photo/_theme_/";
                CleanupAfterInstall = false;

                ExecuteScriptSequence.Clear();

                DeleteFoldersBeforeInstall.Add(UploadLocation);
                DeleteFilesBeforeInstall.Add("/Photo/_theme_/.config");
            }

            if (InstallItem is RepositoryCustomMenuInfo)
            {
                if (det.RepositoryType == "AB")
                {
                    RepositoryCustomMenuInfo customMenu = (RepositoryCustomMenuInfo)InstallItem;

                    if (Directory.GetDirectories(LocalFolder, "Photo").Length > 0)
                    {
                        UploadLocation = "/";
                    }
                    else
                    {
                        UploadLocation = "/Photo/_index_/";
                    }

                    CleanupAfterInstall = false;

                    ExecuteScriptSequence.Clear();

                    DeleteFoldersBeforeInstall.Add("/Photo/_index_/");
                    DeleteFilesBeforeInstall.Add("/index.htm");
                }

                if (det.RepositoryType == "A4")
                {
                    RepositoryCustomMenuInfo customMenu = (RepositoryCustomMenuInfo)InstallItem;

                    UploadLocation      = "/.home/";
                    CleanupAfterInstall = false;

                    ExecuteScriptSequence.Clear();

                    DeleteFoldersBeforeInstall.Add("/.home/firmwareupdate/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/images/widgets/sevenDaysForecast/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/images/widgets/weatherbug/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/images/menu/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/images/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/xml/.profile/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/xml/data/");
                    DeleteFoldersBeforeInstall.Add("/.home/source/");
                    DeleteFoldersBeforeInstall.Add("/.home/components/popMsg/xml/key/");
                    DeleteFoldersBeforeInstall.Add("/.home/components/popMsg/");
                    DeleteFoldersBeforeInstall.Add("/.home/");
                }

                if (InstallItem is RepositoryWaitImagesInfo)
                {
                    RepositoryWaitImagesInfo waitImages = (RepositoryWaitImagesInfo)InstallItem;
                    UploadLocation      = "/Photo/_waitimages_/";
                    CleanupAfterInstall = false;

                    ExecuteScriptSequence.Add(Settings.Default.InstallPrepareScriptURL.Substring(Settings.Default.InstallPrepareScriptURL.LastIndexOf("/") + 1));

                    DeleteFoldersBeforeInstall.Add("/Photo/_waitimages_/");
                    DeleteFilesBeforeInstall.Clear();
                }

                if (InstallItem is RepositoryWebserviceInfo)
                {
                    RepositoryWebserviceInfo webservice = (RepositoryWebserviceInfo)InstallItem;
                    UploadLocation      = "/";
                    CleanupAfterInstall = true;

                    ExecuteScriptSequence.Add(string.Format(Settings.Default.InstallPrepareScriptURL.Substring(Settings.Default.InstallPrepareScriptURL.LastIndexOf("/") + 1) + "?autostart_add={0}&webservice_name={1}&webservice_url={2}", "", HttpCommands.UrlEncode(webservice.Name), HttpCommands.UrlEncode(webservice.WebserviceUrl)));

                    DeleteFoldersBeforeInstall.Clear();
                    DeleteFilesBeforeInstall.Clear();
                }
            }
        }
Example #4
0
        private void LoadRepositoryFile(string Filename, List <RepositoryApplicationInfo> Applications, List <RepositoryCustomMenuInfo> CustomMenus, List <RepositoryThemeInfo> Themes, List <RepositoryWebserviceInfo> Webservices, List <RepositoryWaitImagesInfo> WaitimageSets)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(Filename);

            XmlNodeList selection = null;

            //applications
            if (doc.SelectSingleNode("Repository/Applications/Application") != null)
            {
                selection = doc.SelectNodes("Repository/Applications/Application");
                foreach (XmlNode node in selection)
                {
                    string   Name;
                    string   Author;
                    string   Maintainer;
                    string   Version;
                    string   Description;
                    string   UsageInstructions;
                    string   Homepage;
                    string   DownloadURL;
                    string[] ScreenshotUrls;
                    string   Changelog;
                    string   Forum;
                    ParseFileInformation(node, out Name, out Author, out Maintainer, out Version, out Description, out Changelog, out UsageInstructions, out Homepage, out Forum, out DownloadURL, out ScreenshotUrls);

                    string InstallScript    = node.SelectSingleNode("InstallScript").InnerText.Trim();
                    string GayaInterfaceURL = FixStrings(node.SelectSingleNode("GayaInterfaceURL").InnerText.Trim());
                    string WebInterfaceURL  = FixStrings(node.SelectSingleNode("WebInterfaceURL").InnerText.Trim());

                    RepositoryApplicationInfo rmf = new RepositoryApplicationInfo(Name, Author, Maintainer, Version, Homepage, Forum, Description, Changelog, UsageInstructions, DownloadURL, ScreenshotUrls, InstallScript, GayaInterfaceURL, WebInterfaceURL);
                    Applications.Add(rmf);
                }
            }


            //indexes
            if (doc.SelectSingleNode("Repository/Indexes/Index") != null)
            {
                selection = doc.SelectNodes("Repository/Indexes/Index");
                foreach (XmlNode node in selection)
                {
                    string   Name;
                    string   Author;
                    string   Maintainer;
                    string   Version;
                    string   Description;
                    string   UsageInstructions;
                    string   Homepage;
                    string   DownloadURL;
                    string[] ScreenshotUrls;
                    string   Changelog;
                    string   Forum;
                    ParseFileInformation(node, out Name, out Author, out Maintainer, out Version, out Description, out Changelog, out UsageInstructions, out Homepage, out Forum, out DownloadURL, out ScreenshotUrls);

                    RepositoryCustomMenuInfo rmf = new RepositoryCustomMenuInfo(Name, Author, Maintainer, Version, Homepage, Forum, Description, Changelog, UsageInstructions, DownloadURL, ScreenshotUrls);
                    CustomMenus.Add(rmf);
                }
            }


            //themes
            if (doc.SelectSingleNode("Repository/Themes/Theme") != null)
            {
                selection = doc.SelectNodes("Repository/Themes/Theme");
                foreach (XmlNode node in selection)
                {
                    string   Name;
                    string   Author;
                    string   Maintainer;
                    string   Version;
                    string   Description;
                    string   UsageInstructions;
                    string   Homepage;
                    string   DownloadURL;
                    string[] ScreenshotUrls;
                    string   Changelog;
                    string   Forum;
                    ParseFileInformation(node, out Name, out Author, out Maintainer, out Version, out Description, out Changelog, out UsageInstructions, out Homepage, out Forum, out DownloadURL, out ScreenshotUrls);

                    bool ForHD = node.SelectSingleNode("Formats/HD").InnerText.Trim().ToLower() == "true";
                    bool ForSD = node.SelectSingleNode("Formats/SD").InnerText.Trim().ToLower() == "true";


                    RepositoryThemeInfo rmf = new RepositoryThemeInfo(Name, Author, Maintainer, Version, Homepage, Forum, Description, Changelog, UsageInstructions, DownloadURL, ScreenshotUrls, ForHD, ForSD);
                    Themes.Add(rmf);
                }
            }

            //waitimageset
            if (doc.SelectSingleNode("Repository/WaitImageSets/WaitImageSet") != null)
            {
                selection = doc.SelectNodes("Repository/WaitImageSets/WaitImageSet");
                foreach (XmlNode node in selection)
                {
                    string   Name;
                    string   Author;
                    string   Maintainer;
                    string   Version;
                    string   Description;
                    string   UsageInstructions;
                    string   Homepage;
                    string   DownloadURL;
                    string[] ScreenshotUrls;
                    string   Changelog;
                    string   Forum;
                    ParseFileInformation(node, out Name, out Author, out Maintainer, out Version, out Description, out Changelog, out UsageInstructions, out Homepage, out Forum, out DownloadURL, out ScreenshotUrls);

                    RepositoryWaitImagesInfo rmf = new RepositoryWaitImagesInfo(Name, Author, Maintainer, Version, Homepage, Forum, Description, Changelog, UsageInstructions, DownloadURL, ScreenshotUrls);
                    WaitimageSets.Add(rmf);
                }
            }

            //webservices
            if (doc.SelectSingleNode("Repository/Webservices/Webservice") != null)
            {
                selection = doc.SelectNodes("Repository/Webservices/Webservice");
                foreach (XmlNode node in selection)
                {
                    string   Name;
                    string   Author;
                    string   Maintainer;
                    string   Version;
                    string   Description;
                    string   Changelog;
                    string   Forum;
                    string   UsageInstructions;
                    string   Homepage;
                    string   DownloadURL;
                    string[] ScreenshotUrls;
                    ParseFileInformation(node, out Name, out Author, out Maintainer, out Version, out Description, out Changelog, out UsageInstructions, out Homepage, out Forum, out DownloadURL, out ScreenshotUrls);

                    string WebserviceUrl = node.SelectSingleNode("WebserviceUrl").InnerText.Trim();

                    RepositoryWebserviceInfo wes = new RepositoryWebserviceInfo(Name, Author, Maintainer, Version, Homepage, Forum, Description, Changelog, UsageInstructions, DownloadURL, ScreenshotUrls, WebserviceUrl);
                    Webservices.Add(wes);
                }
            }
        }
Example #5
0
        private void pnlDone_VisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType));
                gbxWebbrowserUI.Visible = gbxUsageInstructions.Visible = gbxGayaInterface.Visible = false;


                if (((RepositoryFileInfoBase)panelResults["SelectedItem"]).UsageInstructions.Length > 0)
                {
                    tbUsageInstructions.Text     = ((RepositoryFileInfoBase)panelResults["SelectedItem"]).UsageInstructions;
                    gbxUsageInstructions.Visible = true;
                }


                if (panelResults["SelectedItem"] is RepositoryApplicationInfo)
                {
                    RepositoryApplicationInfo app = panelResults["SelectedItem"] as RepositoryApplicationInfo;

                    if (!string.IsNullOrEmpty(app.WebInterfaceURL))
                    {
                        gbxWebbrowserUI.Visible = true;

                        linkWebInterfaceURL.Text = app.WebInterfaceURL;
                        linkWebInterfaceURL.Links.Clear();
                        linkWebInterfaceURL.Links.Add(0, linkWebInterfaceURL.Text.Length, app.WebInterfaceURL);
                    }


                    if (!string.IsNullOrEmpty(app.GayaInterfaceURL))
                    {
                        gbxGayaInterface.Visible = true;

                        lblNewWebserviceName.Text = app.Name;
                    }
                }


                if (panelResults["SelectedItem"] is RepositoryApplicationInfo)
                {
                    lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_Application.Replace("\\n", "\n");
                }

                if (panelResults["SelectedItem"] is RepositoryThemeInfo)
                {
                    lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_Theme.Replace("\\n", "\n");
                }

                if (panelResults["SelectedItem"] is RepositoryCustomMenuInfo)
                {
                    if (det.RepositoryType == "AB")
                    {
                        lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_CustomMenu.Replace("\\n", "\n");
                    }

                    if (det.RepositoryType == "A4")
                    {
                        string Warning = "";
                        string Command = Settings.Default.CommandsScriptURL.Substring(Settings.Default.CommandsScriptURL.LastIndexOf('/') + 1);
                        Command = Command.Substring(0, Command.Length - 3) + "cgi";
                        string WarningTitle = "";
                        Warning     += Resources.MessageBox_RestartNMTConfirm;
                        WarningTitle = Resources.MessageBox_RestartNMTCaption;
                        Command     += "?reboot";
                        lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_CustomMenuA4.Replace("\\n", "\n");
                    }
                }

                if (panelResults["SelectedItem"] is RepositoryWaitImagesInfo)
                {
                    lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_WaitImageSet.Replace("\\n", "\n");
                }

                if (panelResults["SelectedItem"] is RepositoryWebserviceInfo)
                {
                    lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_Webservice.Replace("\\n", "\n");
                }
            }
        }