Пример #1
0
        private void ProcessMultipleBackgrounds(RepositoryThemeInfo SelectedTheme)
        {
            string LocalFolder = Constants.TemporaryFolder;

            if (Directory.GetDirectories(LocalFolder, "_theme_").Length > 0)
            {
                LocalFolder += "_theme_" + Path.DirectorySeparatorChar;
            }

            lbBackgrounds.Items.Clear();
            Backgrounds.Clear();


            List <string> backgrounds = new List <string>();

            string[] folders = Directory.GetDirectories(LocalFolder);
            int      i       = 0;

            while ((i < folders.Length) && (Path.GetFileName(folders[i]).ToLower() != panelResults["ThemeFormat"].ToString().ToLower()))
            {
                i++;
            }

            if (i < folders.Length)
            {
                foreach (string file in Directory.GetFiles(folders[i] + Path.DirectorySeparatorChar))
                {
                    if ((Path.GetFileName(file).ToLower().StartsWith("bg")) && Path.GetFileName(file).ToLower().EndsWith(".jpg"))
                    {
                        backgrounds.Add(file);
                    }
                }
            }

            backgrounds.Sort();


            if (backgrounds.Count > 1)
            {
                foreach (string item in backgrounds)
                {
                    Backgrounds.Add(item);
                    lbBackgrounds.Items.Add(Resources.Text_Background + " " + Backgrounds.Count.ToString());
                }

                lbBackgrounds.SelectedIndex = 0;
            }

            gbxThemeBackgroundSelect.Visible = lbBackgrounds.Items.Count > 0;
            gbxThemeBackgroundSelect.Enabled = lbBackgrounds.Items.Count > 0;
        }
        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();
                }
            }
        }
Пример #3
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);
                }
            }
        }