]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Fri, 19 Jun 2009 15:19:01 +0000 (15:19 +0000)
committersr55 <sr55.hb@outlook.com>
Fri, 19 Jun 2009 15:19:01 +0000 (15:19 +0000)
- Cleans up the appcast reader code a bit more, removing all globals.
- Small fix to preset loader to make sure audio bit-rate is set to auto for AC3 tracks.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2576 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Functions/AppcastReader.cs
win/C#/Functions/Main.cs
win/C#/Functions/PresetLoader.cs
win/C#/frmUpdater.cs

index e86259ff76376191f1f8b968a79f24ce91e6f022..94425859760626743ebd6be5e5775dc7807c6e9c 100644 (file)
@@ -12,50 +12,36 @@ namespace Handbrake.Functions
 {\r
     public class AppcastReader\r
     {\r
-        XmlDocument rssDoc;\r
-        XmlNode nodeRss;\r
-        XmlNode nodeChannel;\r
-        XmlNode nodeItem;\r
-        private Uri hb_description;\r
-        private string hb_version;\r
-        private string hb_build;\r
-        private string hb_file;\r
-\r
         /// <summary>\r
-        /// Get the build information from the required appcasts.\r
-        /// This must be run before calling any of the public return functions.\r
+        /// Get the build information from the required appcasts. Run before accessing the public vars.\r
         /// </summary>\r
         public void getInfo()\r
         {\r
             // Get the correct Appcast and set input.\r
-            if (Properties.Settings.Default.hb_build.ToString().EndsWith("1"))\r
-                readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable));\r
-            else \r
-                readRss(new XmlTextReader(Properties.Settings.Default.appcast));\r
-\r
+            XmlNode nodeItem = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable)) : readRss(new XmlTextReader(Properties.Settings.Default.appcast));\r
             string input = nodeItem.InnerXml;\r
 \r
             // Regular Expressions\r
             Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");\r
             Match verShort = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");\r
 \r
-            if (nodeItem != null)\r
-            {\r
-                hb_build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
-                hb_version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
-                hb_file = nodeItem["windows"].InnerText;\r
-                hb_description = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
-            }\r
-\r
+            build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
+            version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
+            downloadFile = nodeItem["windows"].InnerText;\r
+            descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);\r
         }\r
 \r
         /// <summary>\r
         /// Read the RSS file.\r
         /// </summary>\r
         /// <param name="rssReader"></param>\r
-        private void readRss(XmlReader rssReader)\r
+        private static XmlNode readRss(XmlReader rssReader)\r
         {\r
-            rssDoc = new XmlDocument();\r
+            XmlNode nodeItem = null;\r
+            XmlNode nodeChannel = null;\r
+            XmlNode nodeRss = null;\r
+\r
+            XmlDocument rssDoc = new XmlDocument();\r
             rssDoc.Load(rssReader);\r
 \r
             for (int i = 0; i < rssDoc.ChildNodes.Count; i++)\r
@@ -64,53 +50,41 @@ namespace Handbrake.Functions
                     nodeRss = rssDoc.ChildNodes[i];\r
             }\r
 \r
-            for (int i = 0; i < nodeRss.ChildNodes.Count; i++)\r
-            {\r
-                if (nodeRss.ChildNodes[i].Name == "channel")\r
-                    nodeChannel = nodeRss.ChildNodes[i];\r
-            }\r
+            if (nodeRss != null)\r
+                for (int i = 0; i < nodeRss.ChildNodes.Count; i++)\r
+                {\r
+                    if (nodeRss.ChildNodes[i].Name == "channel")\r
+                        nodeChannel = nodeRss.ChildNodes[i];\r
+                }\r
 \r
-            for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)\r
-            {\r
-                if (nodeChannel.ChildNodes[i].Name == "item")\r
-                    nodeItem = nodeChannel.ChildNodes[i];\r
-            }\r
+            if (nodeChannel != null)\r
+                for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)\r
+                {\r
+                    if (nodeChannel.ChildNodes[i].Name == "item")\r
+                        nodeItem = nodeChannel.ChildNodes[i];\r
+                }\r
+\r
+            return nodeItem;\r
         }\r
 \r
         /// <summary>\r
         /// Get Information about an update to HandBrake\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public System.Uri descriptionUrl()\r
-        {\r
-            return hb_description;\r
-        }\r
+        public Uri descriptionUrl { get; set; }\r
 \r
         /// <summary>\r
         /// Get HandBrake's version from the appcast.xml file.\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string version()\r
-        {\r
-            return hb_version;\r
-        }\r
+        public string version { get; set; }\r
 \r
         /// <summary>\r
         /// Get HandBrake's Build from the appcast.xml file.\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string build()\r
-        {\r
-            return hb_build;\r
-        }\r
+        public string build { get; set; }\r
 \r
         /// <summary>\r
         /// Get's the URL for update file.\r
         /// </summary>\r
-        /// <returns></returns>\r
-        public string downloadFile()\r
-        {\r
-            return hb_file;\r
-        }\r
+        public string downloadFile { get; set; }\r
     }\r
 }
\ No newline at end of file
index f6c85b1cf21bb23fd26c01f44eba6493d46b87fe..95a17cfb3295c7f121576aba9da9a40e1caeee2b 100644 (file)
@@ -199,7 +199,7 @@ namespace Handbrake.Functions
             {\r
                 AppcastReader rssRead = new AppcastReader();\r
                 rssRead.getInfo(); // Initializes the class.\r
-                string build = rssRead.build();\r
+                string build = rssRead.build;\r
 \r
                 int latest = int.Parse(build);\r
                 int current = Properties.Settings.Default.hb_build;\r
index 251735aec6d97a75145fd538e9294742acea0c6c..4952e5d3d8c661c5ffe049a79c3efb96207f9a5c 100644 (file)
@@ -243,7 +243,10 @@ namespace Handbrake.Functions
                     newTrack.SubItems.Add(track.Encoder);\r
                     newTrack.SubItems.Add(track.MixDown);\r
                     newTrack.SubItems.Add(track.SampleRate);\r
-                    newTrack.SubItems.Add(track.Bitrate);\r
+                    if (track.Encoder.Contains("AC3"))\r
+                        newTrack.SubItems.Add("Auto");\r
+                    else\r
+                        newTrack.SubItems.Add(track.Bitrate);\r
                     newTrack.SubItems.Add(track.DRC);\r
                     mainWindow.audioPanel.addTrackForPreset(newTrack);\r
                 }\r
index 463ab5676d101817c7c2d758bbac4a9a2e5d28af..97a5c9a647d5662d3bfdfddf1e51c20d7c64ab9d 100644 (file)
@@ -24,19 +24,19 @@ namespace Handbrake
 \r
         private void getRss()\r
         {\r
-            wBrowser.Url = appcast.descriptionUrl();\r
+            wBrowser.Url = appcast.descriptionUrl;\r
         }\r
 \r
         private void setVersions()\r
         {\r
             string old = "(You have: " + Properties.Settings.Default.hb_version.Trim() + " / " + Properties.Settings.Default.hb_build.ToString().Trim() + ")";\r
-            string newBuild = appcast.version().Trim() + " (" + appcast.build() + ")";\r
+            string newBuild = appcast.version.Trim() + " (" + appcast.build + ")";\r
             lbl_update_text.Text = "HandBrake " + newBuild + " is now available. " + old;\r
         }\r
 \r
         private void btn_installUpdate_Click(object sender, EventArgs e)\r
         {\r
-            frmDownload download = new frmDownload(appcast.downloadFile());\r
+            frmDownload download = new frmDownload(appcast.downloadFile);\r
             download.Show();\r
             this.Close();\r
         }\r
@@ -48,7 +48,7 @@ namespace Handbrake
 \r
         private void btn_skip_Click(object sender, EventArgs e)\r
         {\r
-            Properties.Settings.Default.skipversion = int.Parse(appcast.build());\r
+            Properties.Settings.Default.skipversion = int.Parse(appcast.build);\r
             Properties.Settings.Default.Save();\r
 \r
             this.Close();\r