diff --git a/CUETools.CTDB.EACPlugin.Installer/CUETools.CTDB.EACPlugin.Installer.vdproj b/CUETools.CTDB.EACPlugin.Installer/CUETools.CTDB.EACPlugin.Installer.vdproj index f20537f..de61f7c 100644 --- a/CUETools.CTDB.EACPlugin.Installer/CUETools.CTDB.EACPlugin.Installer.vdproj +++ b/CUETools.CTDB.EACPlugin.Installer/CUETools.CTDB.EACPlugin.Installer.vdproj @@ -15,32 +15,38 @@ { "Entry" { - "MsmKey" = "8:_404CDECAD44DEDE89F5968D20B9790D4" - "OwnerKey" = "8:_5C38BA7F54E368532D5699479E787C04" + "MsmKey" = "8:_23A6BB18C5C16459B31F4387E1637805" + "OwnerKey" = "8:_7A5E0041DC75098C30D459114A6DEE81" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_404CDECAD44DEDE89F5968D20B9790D4" - "OwnerKey" = "8:_D773630141C71B97B8E286CAB5D6745D" + "MsmKey" = "8:_23A6BB18C5C16459B31F4387E1637805" + "OwnerKey" = "8:_EDC6E0710402166D3365BDE71ABA595A" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_404CDECAD44DEDE89F5968D20B9790D4" + "MsmKey" = "8:_23A6BB18C5C16459B31F4387E1637805" "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_5C38BA7F54E368532D5699479E787C04" + "MsmKey" = "8:_504F307A54097796FB92030AEBB7329B" "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_5C38BA7F54E368532D5699479E787C04" - "OwnerKey" = "8:_D773630141C71B97B8E286CAB5D6745D" + "MsmKey" = "8:_7A5E0041DC75098C30D459114A6DEE81" + "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_7A5E0041DC75098C30D459114A6DEE81" + "OwnerKey" = "8:_EDC6E0710402166D3365BDE71ABA595A" "MsmSig" = "8:_UNDEFINED" } "Entry" @@ -51,32 +57,20 @@ } "Entry" { - "MsmKey" = "8:_88C1C00C7C570D8CCF5DFB2742F06623" - "OwnerKey" = "8:_5C38BA7F54E368532D5699479E787C04" + "MsmKey" = "8:_A387AADC261164D68ABC68DA3BD54FF7" + "OwnerKey" = "8:_7A5E0041DC75098C30D459114A6DEE81" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_88C1C00C7C570D8CCF5DFB2742F06623" + "MsmKey" = "8:_A387AADC261164D68ABC68DA3BD54FF7" "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" "MsmSig" = "8:_UNDEFINED" } "Entry" { - "MsmKey" = "8:_C8D6D24D8A62DE5D9BD6EBE19184F81B" - "OwnerKey" = "8:_5C38BA7F54E368532D5699479E787C04" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_C8D6D24D8A62DE5D9BD6EBE19184F81B" - "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_D773630141C71B97B8E286CAB5D6745D" - "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" + "MsmKey" = "8:_A387AADC261164D68ABC68DA3BD54FF7" + "OwnerKey" = "8:_EDC6E0710402166D3365BDE71ABA595A" "MsmSig" = "8:_UNDEFINED" } "Entry" @@ -87,7 +81,19 @@ } "Entry" { - "MsmKey" = "8:_FCE5A5A259EDA6827D332455737A9470" + "MsmKey" = "8:_EA17591A9F261678B36DFC7E72DFC398" + "OwnerKey" = "8:_7A5E0041DC75098C30D459114A6DEE81" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_EA17591A9F261678B36DFC7E72DFC398" + "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_EDC6E0710402166D3365BDE71ABA595A" "OwnerKey" = "8:_82CE165AE35A4FB48DF2F4F7C072C14C" "MsmSig" = "8:_UNDEFINED" } @@ -100,37 +106,37 @@ "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_FCE5A5A259EDA6827D332455737A9470" + "OwnerKey" = "8:_EDC6E0710402166D3365BDE71ABA595A" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_D773630141C71B97B8E286CAB5D6745D" + "OwnerKey" = "8:_7A5E0041DC75098C30D459114A6DEE81" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_5C38BA7F54E368532D5699479E787C04" + "OwnerKey" = "8:_A387AADC261164D68ABC68DA3BD54FF7" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_C8D6D24D8A62DE5D9BD6EBE19184F81B" + "OwnerKey" = "8:_EA17591A9F261678B36DFC7E72DFC398" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_88C1C00C7C570D8CCF5DFB2742F06623" + "OwnerKey" = "8:_23A6BB18C5C16459B31F4387E1637805" "MsmSig" = "8:_UNDEFINED" } "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_404CDECAD44DEDE89F5968D20B9790D4" + "OwnerKey" = "8:_504F307A54097796FB92030AEBB7329B" "MsmSig" = "8:_UNDEFINED" } } @@ -145,7 +151,7 @@ "PackageFilesAs" = "3:2" "PackageFileSize" = "3:-2147483648" "CabType" = "3:1" - "Compression" = "3:2" + "Compression" = "3:3" "SignOutput" = "11:FALSE" "CertificateFile" = "8:" "PrivateKeyFile" = "8:" @@ -153,11 +159,24 @@ "InstallerBootstrapper" = "3:2" "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" { - "Enabled" = "11:TRUE" + "Enabled" = "11:FALSE" "PromptEnabled" = "11:TRUE" "PrerequisitesLocation" = "2:1" "Url" = "8:" "ComponentsUrl" = "8:" + "Items" + { + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.0,Profile=Client" + { + "Name" = "8:Microsoft .NET Framework 4 Client Profile (x86 and x64)" + "ProductCode" = "8:.NETFramework,Version=v4.0,Profile=Client" + } + "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Windows.Installer.3.1" + { + "Name" = "8:Windows Installer 3.1" + "ProductCode" = "8:Microsoft.Windows.Installer.3.1" + } + } } } "Release" @@ -177,7 +196,7 @@ "InstallerBootstrapper" = "3:2" "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" { - "Enabled" = "11:TRUE" + "Enabled" = "11:FALSE" "PromptEnabled" = "11:TRUE" "PrerequisitesLocation" = "2:1" "Url" = "8:" @@ -217,7 +236,7 @@ { "Name" = "8:.NET Framework" "Message" = "8:[VSDNETMSG]" - "Version" = "8:3.5.30729" + "FrameworkVersion" = "8:.NETFramework,Version=v2.0" "AllowLaterVersions" = "11:FALSE" "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=76617" } @@ -225,14 +244,14 @@ } "File" { - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_404CDECAD44DEDE89F5968D20B9790D4" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_23A6BB18C5C16459B31F4387E1637805" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:CUETools.CDImage, Version=2.1.4.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_404CDECAD44DEDE89F5968D20B9790D4" + "_23A6BB18C5C16459B31F4387E1637805" { "Name" = "8:CUETools.CDImage.dll" "Attributes" = "3:512" @@ -256,14 +275,45 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_5C38BA7F54E368532D5699479E787C04" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_504F307A54097796FB92030AEBB7329B" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Interop.HelperFunctionsLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_504F307A54097796FB92030AEBB7329B" + { + "Name" = "8:Interop.HelperFunctionsLib.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Interop.HelperFunctionsLib.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_B6AE380AE9784D55925E5A2F6CEC6447" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_7A5E0041DC75098C30D459114A6DEE81" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:CUETools.AccurateRip, Version=2.1.4.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_5C38BA7F54E368532D5699479E787C04" + "_7A5E0041DC75098C30D459114A6DEE81" { "Name" = "8:CUETools.AccurateRip.dll" "Attributes" = "3:512" @@ -287,45 +337,14 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_88C1C00C7C570D8CCF5DFB2742F06623" - { - "AssemblyRegister" = "3:1" - "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:CUETools.Codecs, Version=2.1.4.0, Culture=neutral, processorArchitecture=MSIL" - "ScatterAssemblies" - { - "_88C1C00C7C570D8CCF5DFB2742F06623" - { - "Name" = "8:CUETools.Codecs.dll" - "Attributes" = "3:512" - } - } - "SourcePath" = "8:CUETools.Codecs.dll" - "TargetName" = "8:" - "Tag" = "8:" - "Folder" = "8:_B6AE380AE9784D55925E5A2F6CEC6447" - "Condition" = "8:" - "Transitive" = "11:FALSE" - "Vital" = "11:TRUE" - "ReadOnly" = "11:FALSE" - "Hidden" = "11:FALSE" - "System" = "11:FALSE" - "Permanent" = "11:FALSE" - "SharedLegacy" = "11:FALSE" - "PackageAs" = "3:1" - "Register" = "3:1" - "Exclude" = "11:FALSE" - "IsDependency" = "11:TRUE" - "IsolateTo" = "8:" - } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_C8D6D24D8A62DE5D9BD6EBE19184F81B" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A387AADC261164D68ABC68DA3BD54FF7" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:CUETools.Parity, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_C8D6D24D8A62DE5D9BD6EBE19184F81B" + "_A387AADC261164D68ABC68DA3BD54FF7" { "Name" = "8:CUETools.Parity.dll" "Attributes" = "3:512" @@ -349,37 +368,6 @@ "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_D773630141C71B97B8E286CAB5D6745D" - { - "AssemblyRegister" = "3:1" - "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:CUETools.CTDB, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" - "ScatterAssemblies" - { - "_D773630141C71B97B8E286CAB5D6745D" - { - "Name" = "8:CUETools.CTDB.dll" - "Attributes" = "3:512" - } - } - "SourcePath" = "8:CUETools.CTDB.dll" - "TargetName" = "8:" - "Tag" = "8:" - "Folder" = "8:_B6AE380AE9784D55925E5A2F6CEC6447" - "Condition" = "8:" - "Transitive" = "11:FALSE" - "Vital" = "11:TRUE" - "ReadOnly" = "11:FALSE" - "Hidden" = "11:FALSE" - "System" = "11:FALSE" - "Permanent" = "11:FALSE" - "SharedLegacy" = "11:FALSE" - "PackageAs" = "3:1" - "Register" = "3:1" - "Exclude" = "11:FALSE" - "IsDependency" = "11:TRUE" - "IsolateTo" = "8:" - } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E985E1E2E343425AAC193B3EB3A5B7F0" { "SourcePath" = "8:..\\CUETools\\Resources\\ctdbheader.bmp" @@ -400,20 +388,20 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_FCE5A5A259EDA6827D332455737A9470" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_EA17591A9F261678B36DFC7E72DFC398" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Interop.HelperFunctionsLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:CUETools.Codecs, Version=2.1.4.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_FCE5A5A259EDA6827D332455737A9470" + "_EA17591A9F261678B36DFC7E72DFC398" { - "Name" = "8:Interop.HelperFunctionsLib.dll" + "Name" = "8:CUETools.Codecs.dll" "Attributes" = "3:512" } } - "SourcePath" = "8:Interop.HelperFunctionsLib.dll" + "SourcePath" = "8:CUETools.Codecs.dll" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_B6AE380AE9784D55925E5A2F6CEC6447" @@ -427,7 +415,38 @@ "SharedLegacy" = "11:FALSE" "PackageAs" = "3:1" "Register" = "3:1" - "Exclude" = "11:TRUE" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_EDC6E0710402166D3365BDE71ABA595A" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:CUETools.CTDB, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "ScatterAssemblies" + { + "_EDC6E0710402166D3365BDE71ABA595A" + { + "Name" = "8:CUETools.CTDB.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:CUETools.CTDB.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_B6AE380AE9784D55925E5A2F6CEC6447" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" "IsDependency" = "11:TRUE" "IsolateTo" = "8:" } @@ -488,14 +507,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:EAC CTDB Plugin" - "ProductCode" = "8:{808BD9EB-533A-4405-8464-5AACC9B0C6DD}" - "PackageCode" = "8:{6EE86F90-4EFF-43A1-B7FC-F25E1686A65F}" + "ProductCode" = "8:{E9DACE0D-CD24-469D-9B14-FCFD90866E10}" + "PackageCode" = "8:{BDACE2AD-10B4-42EF-9F36-5A1FA7F964AD}" "UpgradeCode" = "8:{E416086B-D9D3-424C-AAEB-397EC05ECF69}" + "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" - "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:2.1.3" + "InstallAllUsers" = "11:TRUE" + "ProductVersion" = "8:2.1.4" "Manufacturer" = "8:Grigory Chudov" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:http://www.cuetools.net" diff --git a/CUETools.CTDB.EACPlugin/FormMetadata.Designer.cs b/CUETools.CTDB.EACPlugin/FormMetadata.Designer.cs index f795be6..a92d3a8 100644 --- a/CUETools.CTDB.EACPlugin/FormMetadata.Designer.cs +++ b/CUETools.CTDB.EACPlugin/FormMetadata.Designer.cs @@ -150,6 +150,7 @@ this.Padding = new System.Windows.Forms.Padding(10); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "CTDB Metadata Lookup"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormMetadata_FormClosing); this.Load += new System.EventHandler(this.FormMetadata_Load); this.panel1.ResumeLayout(false); this.ResumeLayout(false); diff --git a/CUETools.CTDB.EACPlugin/FormMetadata.cs b/CUETools.CTDB.EACPlugin/FormMetadata.cs index a729e13..bb3abbb 100644 --- a/CUETools.CTDB.EACPlugin/FormMetadata.cs +++ b/CUETools.CTDB.EACPlugin/FormMetadata.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using CUETools.CTDB.EACPlugin.Properties; using System.Net; using System.IO; +using AudioDataPlugIn; namespace CUETools.CTDB.EACPlugin { @@ -25,6 +26,7 @@ namespace CUETools.CTDB.EACPlugin this.cdinfo = cdinfo; this.cover = cover; this.InitializeComponent(); + this.Size = Options.MetadataWindowSize; } public CTDBResponseMeta Meta @@ -62,54 +64,37 @@ namespace CUETools.CTDB.EACPlugin #endif this.ctdb.ContactDB(server, this.agent, null, false, false, AudioDataPlugIn.Options.MetadataSearch); - foreach (var metadata in ctdb.Metadata) + if (this.cdinfo) { - backgroundWorker1.ReportProgress(0, metadata); + foreach (var metadata in ctdb.Metadata) + { + backgroundWorker1.ReportProgress(0, metadata); + } } var knownUrls = new List(); foreach (var metadata in ctdb.Metadata) { if (metadata.coverart == null || !this.cover) continue; + if (!this.cdinfo) + { + backgroundWorker1.ReportProgress(0, metadata); + } foreach (var coverart in metadata.coverart) { - if (knownUrls.Contains(coverart.uri) || !coverart.primary) + var uri = Options.CoversSearch == CTDBCoversSearch.Large ? + coverart.uri : coverart.uri150 ?? coverart.uri; + if (knownUrls.Contains(uri) || !coverart.primary) continue; - try - { - HttpWebRequest req = (HttpWebRequest)WebRequest.Create(coverart.uri); - req.Method = "GET"; - //req.Proxy = proxy; - //req.UserAgent = this.userAgent; - //req.Timeout = connectTimeout; - //req.ReadWriteTimeout = socketTimeout; - using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) - { - if (resp.StatusCode != HttpStatusCode.OK) - continue; - using (var responseStream = resp.GetResponseStream()) - using (var reader = new BinaryReader(responseStream)) - { - MemoryStream ms = new MemoryStream(); - var buf = new byte[4096]; - do - { - int len = responseStream.Read(buf, 0, buf.Length); - if (len <= 0) break; - ms.Write(buf, 0, len); - } while (true); - var img = new InternetImage(); - img.URL = coverart.uri; - img.Data = ms.ToArray(); - img.Image = new Bitmap(ms); - knownUrls.Add(coverart.uri); - backgroundWorker1.ReportProgress(0, img); - } - } - } - catch - { - } + var ms = new MemoryStream(); + if (!this.ctdb.FetchFile(uri, ms)) + continue; + var img = new InternetImage(); + img.URL = uri; + img.Data = ms.ToArray(); + img.Image = new Bitmap(ms); + knownUrls.Add(uri); + backgroundWorker1.ReportProgress(0, img); } } } @@ -214,21 +199,32 @@ namespace CUETools.CTDB.EACPlugin this.progressBar1.Visible = false; this.button1.Visible = true; this.button2.Visible = true; - if (listView1.Items.Count == 0) + if (listView1.Items.Count == 0 && flowLayoutPanel1.Controls.Count == 0) { this.DialogResult = DialogResult.Cancel; return; } - listView1.Items[0].Selected = true; - if (listView1.Items.Count == 1) + if (listView1.Items.Count > 0) + listView1.Items[0].Selected = true; + if (flowLayoutPanel1.Controls.Count > 0 && m_currently_selected == null) + { + m_currently_selected = flowLayoutPanel1.Controls[0] as ImagePreview; + m_currently_selected.Selected = true; + } + if ((!this.cdinfo || listView1.Items.Count == 1) && (!this.cover || flowLayoutPanel1.Controls.Count == 1)) + { this.DialogResult = DialogResult.OK; + } } private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { - var ht = listView1.HitTest(e.Location); - if (ht.Item != null) - this.DialogResult = DialogResult.OK; + if (this.cdinfo) + { + var ht = listView1.HitTest(e.Location); + if (ht.Item != null) + this.DialogResult = DialogResult.OK; + } } private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) @@ -272,5 +268,10 @@ namespace CUETools.CTDB.EACPlugin this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } } + + private void FormMetadata_FormClosing(object sender, FormClosingEventArgs e) + { + Options.MetadataWindowSize = this.Size; + } } } diff --git a/CUETools.CTDB.EACPlugin/FormSubmitParity.cs b/CUETools.CTDB.EACPlugin/FormSubmitParity.cs index dd6877f..3df9b0f 100644 --- a/CUETools.CTDB.EACPlugin/FormSubmitParity.cs +++ b/CUETools.CTDB.EACPlugin/FormSubmitParity.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.Text; using System.Windows.Forms; using CUETools.CTDB.EACPlugin.Properties; +using System.IO; namespace CUETools.CTDB.EACPlugin { @@ -14,6 +15,7 @@ namespace CUETools.CTDB.EACPlugin private CUEToolsDB ctdb; private int confidence, quality; private string artist, title, agent, drivename; + private CTDBResponse resp; public FormSubmitParity(CUEToolsDB ctdb, string agent, string drivename, int confidence, int quality, string artist, string title) { @@ -41,19 +43,41 @@ namespace CUETools.CTDB.EACPlugin private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { this.ctdb.UploadHelper.onProgress += UploadProgress; + if (resp == null) + { #if DEBUG - string server = "hq.cuetools.net"; + string server = "hq.cuetools.net"; #else - string server = null; + string server = null; #endif - this.ctdb.ContactDB(server, this.agent, this.drivename, true, true, CTDBMetadataSearch.None); - this.ctdb.DoVerify(); - this.ctdb.Submit(this.confidence, this.quality, this.artist, this.title, null); + this.ctdb.ContactDB(server, this.agent, this.drivename, true, true, CTDBMetadataSearch.None); + this.ctdb.DoVerify(); + resp = this.ctdb.Submit(this.confidence, this.quality, this.artist, this.title, null); + } else + { + var url = resp.updateurl; + resp = null; + var temp = Path.GetTempPath() + Path.GetFileName(url.Substring(url.LastIndexOf('/') + 1)); + bool ok = false; + using (var stream = new FileStream(temp, FileMode.Create)) + ok = this.ctdb.FetchFile(url, stream); + if (ok) + System.Diagnostics.Process.Start(temp); + } this.ctdb.UploadHelper.onProgress -= UploadProgress; } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { + if (resp != null && resp.updateurl != null) + { + DialogResult mb = MessageBox.Show(this, (resp.updatemsg ?? "") + " Do you wish to download and install it?", "An updated version of CTDB plugin is available", MessageBoxButtons.OKCancel); + if (mb == DialogResult.OK) + { + this.backgroundWorker1.RunWorkerAsync(); + return; + } + } this.DialogResult = DialogResult.OK; } diff --git a/CUETools.CTDB.EACPlugin/Metadata.cs b/CUETools.CTDB.EACPlugin/Metadata.cs index 253b800..d9f93c8 100644 --- a/CUETools.CTDB.EACPlugin/Metadata.cs +++ b/CUETools.CTDB.EACPlugin/Metadata.cs @@ -12,6 +12,7 @@ using CUETools.Codecs; using CUETools.CTDB; using CUETools.CTDB.EACPlugin.Properties; using System.Drawing.Imaging; +using AudioDataPlugIn; namespace MetadataPlugIn { @@ -24,6 +25,9 @@ namespace MetadataPlugIn { public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics) { + if (Options.CoversSearch == CTDBCoversSearch.None) + cover = false; + if (!cdinfo && !cover) return false; diff --git a/CUETools.CTDB.EACPlugin/Options.Designer.cs b/CUETools.CTDB.EACPlugin/Options.Designer.cs index d22a00a..f9574d8 100644 --- a/CUETools.CTDB.EACPlugin/Options.Designer.cs +++ b/CUETools.CTDB.EACPlugin/Options.Designer.cs @@ -29,161 +29,202 @@ namespace AudioDataPlugIn /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.radioButtonMBExtensive = new System.Windows.Forms.RadioButton(); - this.radioButtonMBFast = new System.Windows.Forms.RadioButton(); - this.radioButtonMBDefault = new System.Windows.Forms.RadioButton(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.buttonOk = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.groupBox1.SuspendLayout(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(127, 16); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(182, 17); - this.label1.TabIndex = 0; - this.label1.Text = "CUETools DB Plugin V2.1.4"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(127, 82); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(307, 42); - this.label2.TabIndex = 1; - this.label2.Text = "Copyright (c) 2011-12 Gregory S. Chudov"; - // - // linkLabel1 - // - this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(127, 44); - this.linkLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(209, 17); - this.linkLabel1.TabIndex = 3; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "http://db.cuetools.net/about.php"; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); - // - // pictureBox1 - // - this.pictureBox1.Image = global::CUETools.CTDB.EACPlugin.Properties.Resources.ctdb64; - this.pictureBox1.Location = new System.Drawing.Point(17, 16); - this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(85, 79); - this.pictureBox1.TabIndex = 4; - this.pictureBox1.TabStop = false; - // - // radioButtonMBExtensive - // - this.radioButtonMBExtensive.AutoSize = true; - this.radioButtonMBExtensive.Location = new System.Drawing.Point(8, 20); - this.radioButtonMBExtensive.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.radioButtonMBExtensive.Name = "radioButtonMBExtensive"; - this.radioButtonMBExtensive.Size = new System.Drawing.Size(89, 21); - this.radioButtonMBExtensive.TabIndex = 6; - this.radioButtonMBExtensive.TabStop = true; - this.radioButtonMBExtensive.Text = "Extensive"; - this.radioButtonMBExtensive.UseVisualStyleBackColor = true; - // - // radioButtonMBFast - // - this.radioButtonMBFast.AutoSize = true; - this.radioButtonMBFast.Location = new System.Drawing.Point(8, 62); - this.radioButtonMBFast.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.radioButtonMBFast.Name = "radioButtonMBFast"; - this.radioButtonMBFast.Size = new System.Drawing.Size(56, 21); - this.radioButtonMBFast.TabIndex = 7; - this.radioButtonMBFast.TabStop = true; - this.radioButtonMBFast.Text = "Fast"; - this.radioButtonMBFast.UseVisualStyleBackColor = true; - // - // radioButtonMBDefault - // - this.radioButtonMBDefault.AutoSize = true; - this.radioButtonMBDefault.Location = new System.Drawing.Point(8, 41); - this.radioButtonMBDefault.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.radioButtonMBDefault.Name = "radioButtonMBDefault"; - this.radioButtonMBDefault.Size = new System.Drawing.Size(74, 21); - this.radioButtonMBDefault.TabIndex = 8; - this.radioButtonMBDefault.TabStop = true; - this.radioButtonMBDefault.Text = "Default"; - this.radioButtonMBDefault.UseVisualStyleBackColor = true; - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.radioButtonMBDefault); - this.groupBox1.Controls.Add(this.radioButtonMBExtensive); - this.groupBox1.Controls.Add(this.radioButtonMBFast); - this.groupBox1.Location = new System.Drawing.Point(16, 156); - this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.groupBox1.Size = new System.Drawing.Size(191, 107); - this.groupBox1.TabIndex = 15; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Metadata search mode:"; - // - // buttonOk - // - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOk.Location = new System.Drawing.Point(404, 233); - this.buttonOk.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(100, 31); - this.buttonOk.TabIndex = 17; - this.buttonOk.Text = "OK"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.button2_Click); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(404, 194); - this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(100, 31); - this.buttonCancel.TabIndex = 19; - this.buttonCancel.Text = "Cancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // Options - // - this.AcceptButton = this.buttonOk; - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(520, 279); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.linkLabel1); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Options"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Options"; - this.Load += new System.EventHandler(this.Options_Load); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.radioButtonMBExtensive = new System.Windows.Forms.RadioButton(); + this.radioButtonMBFast = new System.Windows.Forms.RadioButton(); + this.radioButtonMBDefault = new System.Windows.Forms.RadioButton(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.radioButtonCoversNone = new System.Windows.Forms.RadioButton(); + this.radioButtonCoversSmall = new System.Windows.Forms.RadioButton(); + this.radioButtonCoversLarge = new System.Windows.Forms.RadioButton(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(95, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(139, 13); + this.label1.TabIndex = 0; + this.label1.Text = "CUETools DB Plugin V2.1.4"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(95, 67); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(230, 34); + this.label2.TabIndex = 1; + this.label2.Text = "Copyright (c) 2011-12 Gregory S. Chudov"; + // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.Location = new System.Drawing.Point(95, 36); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(164, 13); + this.linkLabel1.TabIndex = 3; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "http://db.cuetools.net/about.php"; + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // + // pictureBox1 + // + this.pictureBox1.Image = global::CUETools.CTDB.EACPlugin.Properties.Resources.ctdb64; + this.pictureBox1.Location = new System.Drawing.Point(13, 13); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(64, 64); + this.pictureBox1.TabIndex = 4; + this.pictureBox1.TabStop = false; + // + // radioButtonMBExtensive + // + this.radioButtonMBExtensive.AutoSize = true; + this.radioButtonMBExtensive.Location = new System.Drawing.Point(6, 16); + this.radioButtonMBExtensive.Name = "radioButtonMBExtensive"; + this.radioButtonMBExtensive.Size = new System.Drawing.Size(71, 17); + this.radioButtonMBExtensive.TabIndex = 6; + this.radioButtonMBExtensive.TabStop = true; + this.radioButtonMBExtensive.Text = "Extensive"; + this.radioButtonMBExtensive.UseVisualStyleBackColor = true; + // + // radioButtonMBFast + // + this.radioButtonMBFast.AutoSize = true; + this.radioButtonMBFast.Location = new System.Drawing.Point(6, 50); + this.radioButtonMBFast.Name = "radioButtonMBFast"; + this.radioButtonMBFast.Size = new System.Drawing.Size(45, 17); + this.radioButtonMBFast.TabIndex = 7; + this.radioButtonMBFast.TabStop = true; + this.radioButtonMBFast.Text = "Fast"; + this.radioButtonMBFast.UseVisualStyleBackColor = true; + // + // radioButtonMBDefault + // + this.radioButtonMBDefault.AutoSize = true; + this.radioButtonMBDefault.Location = new System.Drawing.Point(6, 33); + this.radioButtonMBDefault.Name = "radioButtonMBDefault"; + this.radioButtonMBDefault.Size = new System.Drawing.Size(59, 17); + this.radioButtonMBDefault.TabIndex = 8; + this.radioButtonMBDefault.TabStop = true; + this.radioButtonMBDefault.Text = "Default"; + this.radioButtonMBDefault.UseVisualStyleBackColor = true; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.radioButtonMBFast); + this.groupBox1.Controls.Add(this.radioButtonMBDefault); + this.groupBox1.Controls.Add(this.radioButtonMBExtensive); + this.groupBox1.Location = new System.Drawing.Point(12, 127); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(136, 87); + this.groupBox1.TabIndex = 15; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Metadata search mode:"; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(303, 189); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 25); + this.buttonOk.TabIndex = 17; + this.buttonOk.Text = "OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.button2_Click); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(303, 158); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 25); + this.buttonCancel.TabIndex = 19; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.radioButtonCoversNone); + this.groupBox2.Controls.Add(this.radioButtonCoversSmall); + this.groupBox2.Controls.Add(this.radioButtonCoversLarge); + this.groupBox2.Location = new System.Drawing.Point(154, 127); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(136, 87); + this.groupBox2.TabIndex = 16; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Covers search mode:"; + // + // radioButtonCoversNone + // + this.radioButtonCoversNone.AutoSize = true; + this.radioButtonCoversNone.Location = new System.Drawing.Point(6, 50); + this.radioButtonCoversNone.Name = "radioButtonCoversNone"; + this.radioButtonCoversNone.Size = new System.Drawing.Size(51, 17); + this.radioButtonCoversNone.TabIndex = 7; + this.radioButtonCoversNone.TabStop = true; + this.radioButtonCoversNone.Text = "None"; + this.radioButtonCoversNone.UseVisualStyleBackColor = true; + // + // radioButtonCoversSmall + // + this.radioButtonCoversSmall.AutoSize = true; + this.radioButtonCoversSmall.Location = new System.Drawing.Point(6, 33); + this.radioButtonCoversSmall.Name = "radioButtonCoversSmall"; + this.radioButtonCoversSmall.Size = new System.Drawing.Size(50, 17); + this.radioButtonCoversSmall.TabIndex = 8; + this.radioButtonCoversSmall.TabStop = true; + this.radioButtonCoversSmall.Text = "Small"; + this.radioButtonCoversSmall.UseVisualStyleBackColor = true; + // + // radioButtonCoversLarge + // + this.radioButtonCoversLarge.AutoSize = true; + this.radioButtonCoversLarge.Location = new System.Drawing.Point(6, 16); + this.radioButtonCoversLarge.Name = "radioButtonCoversLarge"; + this.radioButtonCoversLarge.Size = new System.Drawing.Size(52, 17); + this.radioButtonCoversLarge.TabIndex = 6; + this.radioButtonCoversLarge.TabStop = true; + this.radioButtonCoversLarge.Text = "Large"; + this.radioButtonCoversLarge.UseVisualStyleBackColor = true; + // + // Options + // + this.AcceptButton = this.buttonOk; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(390, 227); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.linkLabel1); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Options"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Options"; + this.Load += new System.EventHandler(this.Options_Load); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -199,5 +240,9 @@ namespace AudioDataPlugIn private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button buttonOk; private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.RadioButton radioButtonCoversNone; + private System.Windows.Forms.RadioButton radioButtonCoversSmall; + private System.Windows.Forms.RadioButton radioButtonCoversLarge; } } \ No newline at end of file diff --git a/CUETools.CTDB.EACPlugin/Options.cs b/CUETools.CTDB.EACPlugin/Options.cs index a99bbb1..8aa2bd9 100644 --- a/CUETools.CTDB.EACPlugin/Options.cs +++ b/CUETools.CTDB.EACPlugin/Options.cs @@ -8,12 +8,21 @@ using System.Windows.Forms; using CUETools.CTDB.EACPlugin.Properties; using CUETools.CTDB; using Microsoft.Win32; +using System.Runtime.Serialization.Formatters.Binary; namespace AudioDataPlugIn { + public enum CTDBCoversSearch + { + Large, + Small, + None + } + public partial class Options : Form { private static CTDBMetadataSearch? metadataSearch = null; + private static CTDBCoversSearch? coversSearch = null; private static string optionsKey = @"SOFTWARE\CUETools\EACPugin"; public static CTDBMetadataSearch MetadataSearch { @@ -26,12 +35,10 @@ namespace AudioDataPlugIn using (var key = Registry.CurrentUser.OpenSubKey(optionsKey, false)) { var val = key.GetValue("MetadataSearch") as string; - if (val == "Default") metadataSearch = CTDBMetadataSearch.Default; - if (val == "Fast") metadataSearch = CTDBMetadataSearch.Fast; - if (val == "Extensive") metadataSearch = CTDBMetadataSearch.Extensive; + metadataSearch = (CTDBMetadataSearch)Enum.Parse(typeof(CTDBMetadataSearch), val); } } - catch (Exception ex) + catch (Exception) { } } @@ -50,6 +57,68 @@ namespace AudioDataPlugIn } } + public static CTDBCoversSearch CoversSearch + { + get + { + if (!coversSearch.HasValue) + { + try + { + using (var key = Registry.CurrentUser.OpenSubKey(optionsKey, false)) + { + var val = key.GetValue("CoversSearch") as string; + coversSearch = (CTDBCoversSearch)Enum.Parse(typeof(CTDBCoversSearch), val); + } + } + catch (Exception) + { + } + } + + return coversSearch ?? CTDBCoversSearch.Small; + } + + set + { + using (var key = Registry.CurrentUser.CreateSubKey(optionsKey)) + { + key.SetValue("CoversSearch", value.ToString()); + } + + coversSearch = value; + } + } + + public static Size MetadataWindowSize + { + get + { + try + { + using (var key = Registry.CurrentUser.OpenSubKey(optionsKey, false)) + { + var val = key.GetValue("MetadataWindowSize") as string; + return (Size)TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(val); + } + } + catch (Exception) + { + } + + return new Size(); + } + + set + { + using (var key = Registry.CurrentUser.CreateSubKey(optionsKey)) + { + var val = TypeDescriptor.GetConverter(value.GetType()).ConvertToInvariantString(value); + key.SetValue("MetadataWindowSize", val); + } + } + } + public Options() { this.InitializeComponent(); @@ -66,6 +135,9 @@ namespace AudioDataPlugIn this.radioButtonMBExtensive.Checked = MetadataSearch == CTDBMetadataSearch.Extensive; this.radioButtonMBDefault.Checked = MetadataSearch == CTDBMetadataSearch.Default; this.radioButtonMBFast.Checked = MetadataSearch == CTDBMetadataSearch.Fast; + this.radioButtonCoversLarge.Checked = CoversSearch == CTDBCoversSearch.Large; + this.radioButtonCoversSmall.Checked = CoversSearch == CTDBCoversSearch.Small; + this.radioButtonCoversNone.Checked = CoversSearch == CTDBCoversSearch.None; } private void button2_Click(object sender, EventArgs e) @@ -74,6 +146,9 @@ namespace AudioDataPlugIn : this.radioButtonMBDefault.Checked ? CTDBMetadataSearch.Default : this.radioButtonMBFast.Checked ? CTDBMetadataSearch.Fast : CTDBMetadataSearch.None; - } + Options.CoversSearch = this.radioButtonCoversLarge.Checked ? CTDBCoversSearch.Large + : this.radioButtonCoversSmall.Checked ? CTDBCoversSearch.Small + : CTDBCoversSearch.None; + } } } diff --git a/CUETools.CTDB/CTDBResponse.cs b/CUETools.CTDB/CTDBResponse.cs index 9757430..d64026c 100644 --- a/CUETools.CTDB/CTDBResponse.cs +++ b/CUETools.CTDB/CTDBResponse.cs @@ -7,8 +7,33 @@ namespace CUETools.CTDB [XmlRoot(ElementName = "ctdb", Namespace = "http://db.cuetools.net/ns/mmd-1.0#")] public class CTDBResponse { + [XmlIgnore] + public bool ParityNeeded + { + get + { + return this.status == "parity needed"; + } + } + + [XmlAttribute] + public string status { get; set; } + + [XmlAttribute] + public string updateurl { get; set; } + + [XmlAttribute] + public string updatemsg { get; set; } + + [XmlAttribute] + public string message { get; set; } + + [XmlAttribute] + public int npar { get; set; } + [XmlElement] public CTDBResponseEntry[] entry; + [XmlElement] public CTDBResponseMeta[] metadata; } diff --git a/CUETools.CTDB/CTDBSubmitResponse.cs b/CUETools.CTDB/CTDBSubmitResponse.cs index c92b145..e62d966 100644 --- a/CUETools.CTDB/CTDBSubmitResponse.cs +++ b/CUETools.CTDB/CTDBSubmitResponse.cs @@ -19,6 +19,12 @@ namespace CUETools.CTDB [XmlAttribute] public string status { get; set; } + [XmlAttribute] + public string updateurl { get; set; } + + [XmlAttribute] + public string updatemsg { get; set; } + [XmlAttribute] public string message { get; set; } diff --git a/CUETools.CTDB/CUETools.CTDB.csproj b/CUETools.CTDB/CUETools.CTDB.csproj index 5cd33eb..a7a22f7 100644 --- a/CUETools.CTDB/CUETools.CTDB.csproj +++ b/CUETools.CTDB/CUETools.CTDB.csproj @@ -60,7 +60,6 @@ - diff --git a/CUETools.CTDB/CUEToolsDB.cs b/CUETools.CTDB/CUEToolsDB.cs index 1b5ad8d..be0fdce 100644 --- a/CUETools.CTDB/CUEToolsDB.cs +++ b/CUETools.CTDB/CUEToolsDB.cs @@ -87,6 +87,7 @@ namespace CUETools.CTDB { this.QueryExceptionStatus = WebExceptionStatus.ProtocolError; this.QueryResponseStatus = resp.StatusCode; + this.QueryExceptionMessage = resp.StatusDescription; if (this.QueryResponseStatus == HttpStatusCode.OK) { XmlSerializer serializer = new XmlSerializer(typeof(CTDBResponse)); @@ -117,8 +118,11 @@ namespace CUETools.CTDB { this.QueryExceptionStatus = ex.Status; this.QueryExceptionMessage = ex.Message; - if (this.QueryExceptionStatus == WebExceptionStatus.ProtocolError) - this.QueryResponseStatus = (ex.Response as HttpWebResponse).StatusCode; + if (this.QueryExceptionStatus == WebExceptionStatus.ProtocolError) + { + this.QueryResponseStatus = (ex.Response as HttpWebResponse).StatusCode; + this.QueryExceptionMessage = (ex.Response as HttpWebResponse).StatusDescription; + } } catch (Exception ex) { @@ -131,6 +135,50 @@ namespace CUETools.CTDB } } + public bool FetchFile(string url, Stream output) + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "GET"; + req.Proxy = proxy; + req.UserAgent = this.userAgent; + req.Timeout = connectTimeout; + req.ReadWriteTimeout = socketTimeout; + req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; + + currentReq = req; + try + { + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + { + if (resp.StatusCode != HttpStatusCode.OK) + return false; + using (Stream responseStream = resp.GetResponseStream()) + { + var buf = new byte[4096]; + int pos = 0; + do + { + if (uploadHelper.onProgress != null) + uploadHelper.onProgress(url, new UploadProgressEventArgs(req.RequestUri.AbsoluteUri, ((double)pos) / resp.ContentLength)); + int len = responseStream.Read(buf, 0, buf.Length); + if (len <= 0) break; + output.Write(buf, 0, len); + pos += len; + } while (true); + return true; + } + } + } + catch (Exception) + { + } + finally + { + currentReq = null; + } + return false; + } + public ushort[,] FetchDB(DBEntry entry, int npar, ushort[,] syn) { string url = entry.hasParity[0] == '/' ? urlbase + entry.hasParity : entry.hasParity; @@ -230,12 +278,12 @@ namespace CUETools.CTDB return uuidInfo; } - public string Submit(int confidence, int quality, string artist, string title, string barcode) + public CTDBResponse Submit(int confidence, int quality, string artist, string title, string barcode) { if (this.QueryExceptionStatus != WebExceptionStatus.Success && (this.QueryExceptionStatus != WebExceptionStatus.ProtocolError || this.QueryResponseStatus != HttpStatusCode.NotFound)) - return this.DBStatus; - CTDBSubmitResponse resp = null; + return null; + CTDBResponse resp = null; subResult = ""; var confirms = this.MatchingEntries; if (confirms.Count > 0) @@ -248,16 +296,16 @@ namespace CUETools.CTDB resp = DoSubmit(confidence, quality, artist, title, barcode, true, confirm, Math.Min(AccurateRipVerify.maxNpar, resp.npar)); subResult = subResult + (subResult == "" ? "" : ", ") + resp.message; } - return subResult; + return resp; } resp = DoSubmit(confidence, quality, artist, title, barcode, false, null, AccurateRipVerify.maxNpar); if (resp.ParityNeeded) resp = DoSubmit(confidence, quality, artist, title, barcode, true, null, Math.Min(AccurateRipVerify.maxNpar, resp.npar)); subResult = resp.message; - return subResult; + return resp; } - protected CTDBSubmitResponse DoSubmit(int confidence, int quality, string artist, string title, string barcode, bool upload, DBEntry confirm, int npar) + protected CTDBResponse DoSubmit(int confidence, int quality, string artist, string title, string barcode, bool upload, DBEntry confirm, int npar) { var files = new List(); long maxId = 0; @@ -330,23 +378,23 @@ namespace CUETools.CTDB { using (Stream s = resp.GetResponseStream()) { - var serializer = new XmlSerializer(typeof(CTDBSubmitResponse)); - return serializer.Deserialize(s) as CTDBSubmitResponse; + var serializer = new XmlSerializer(typeof(CTDBResponse)); + return serializer.Deserialize(s) as CTDBResponse; } } else { - return new CTDBSubmitResponse() { status = "database access error", message = resp.StatusCode.ToString() }; + return new CTDBResponse() { status = "database access error", message = resp.StatusCode.ToString() }; } } } catch (WebException ex) { - return new CTDBSubmitResponse() { status = "database access error", message = ex.Message ?? ex.Status.ToString() }; + return new CTDBResponse() { status = "database access error", message = ex.Message ?? ex.Status.ToString() }; } catch (Exception ex) { - return new CTDBSubmitResponse() { status = "database access error", message = ex.Message }; + return new CTDBResponse() { status = "database access error", message = ex.Message }; } finally { @@ -462,7 +510,7 @@ namespace CUETools.CTDB { return QueryExceptionStatus == WebExceptionStatus.Success ? null : QueryExceptionStatus != WebExceptionStatus.ProtocolError ? ("database access error: " + (QueryExceptionMessage ?? QueryExceptionStatus.ToString())) : - QueryResponseStatus != HttpStatusCode.NotFound ? "database access error: " + QueryResponseStatus.ToString() : + QueryResponseStatus != HttpStatusCode.NotFound ? "database access error: " + (QueryExceptionMessage ?? QueryResponseStatus.ToString()) : "disk not present in database"; } }