~kelemeng/banshee/bug743928

« back to all changes in this revision

Viewing changes to src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2011-05-14 22:25:36 UTC
  • mfrom: (6.3.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20110514222536-u1x7ikxdqkmfvyuz
Tags: 2.1.0-1ubuntu1
* [2396c18] Merge from Debian Unstable, remaining changes:
  + Enable SoundMenu and Disable NotificationArea by default
  + Disable boo and karma extensions
  + Enable and recommnd u1ms and soundmenu extensions
  + Move desktop file for Meego UI to /usr/share/une/applications
  + Change the url for the Amazon store redirector
  + Create the U1MS widget earlier and bump libu1 requirement
* [9d7c600] Drop upstreamed u1ms-initialize-earlier patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
776
776
            "SELECT TrackID FROM CoreTracks WHERE PrimarySourceId IN (?) AND Uri = ? LIMIT 1"
777
777
        );
778
778
 
 
779
        private static string get_track_by_metadata_hash =
 
780
            "SELECT {0} FROM {1} WHERE {2} AND PrimarySourceId IN (?) AND MetadataHash = ? LIMIT 1";
 
781
 
 
782
        private static HyenaSqliteCommand get_track_count_by_metadata_hash = new HyenaSqliteCommand (
 
783
            "SELECT COUNT('x') FROM CoreTracks WHERE PrimarySourceId IN (?) AND MetadataHash = ?"
 
784
        );
 
785
 
779
786
        public static int GetTrackIdForUri (SafeUri uri, int [] primary_sources)
780
787
        {
781
788
            return ServiceManager.DbConnection.Query<int> (get_track_id_by_uri,
788
795
                primary_sources, absoluteUri);
789
796
        }
790
797
 
 
798
        private static IDataReader FindTrackByMetadataHash (string metadata_hash, int [] primary_sources)
 
799
        {
 
800
            var command = new HyenaSqliteCommand (String.Format (
 
801
                get_track_by_metadata_hash,
 
802
                provider.Select, provider.From, provider.Where));
 
803
            return ServiceManager.DbConnection.Query (command,
 
804
                primary_sources, metadata_hash);
 
805
        }
 
806
 
791
807
        public static bool ContainsUri (SafeUri uri, int [] primary_sources)
792
808
        {
793
809
            return GetTrackIdForUri (uri, primary_sources) > 0;
794
810
        }
795
811
 
 
812
        internal static DatabaseTrackInfo GetTrackForMetadataHash (string metadata_hash, int [] primary_sources)
 
813
        {
 
814
            using (IDataReader reader = FindTrackByMetadataHash (metadata_hash, primary_sources)) {
 
815
                if (reader.Read ()) {
 
816
                    return provider.Load (reader);
 
817
                }
 
818
                return null;
 
819
            }
 
820
        }
 
821
 
 
822
        internal static int MetadataHashCount (string metadata_hash, int [] primary_sources)
 
823
        {
 
824
            return ServiceManager.DbConnection.Query<int> (get_track_count_by_metadata_hash,
 
825
                primary_sources, metadata_hash);
 
826
        }
 
827
 
796
828
        public static void UpdateMetadataHash (string albumTitle, string artistName, string condition)
797
829
        {
798
830
            // Keep this field set/order in sync with MetadataHash in TrackInfo.cs