~ubuntu-branches/ubuntu/quantal/banshee/quantal

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2012-01-23 23:16:49 UTC
  • mfrom: (6.3.22 experimental)
  • Revision ID: package-import@ubuntu.com-20120123231649-safm1f8eycltcgsf
Tags: 2.3.4.ds-1ubuntu1
* Merge from Debian Experimental, remaining changes:
  + Enable and recommend SoundMenu and Disable NotificationArea by default
  + Disable boo and karma extensions
  + Enable and suggest u1ms
  + Move desktop file for Meego UI to /usr/share/une/applications
  + Change the url for the Amazon store redirector
  + [08dea2c] Revert "Fix invalid cast causing ftbfs with libgpod"
* [b617fe0] Convert Ubuntu-specific patches to gbp-pq patches
* Also fixes Launchpad bugs:
  - Fixes race condition while starting (LP: #766303)

Show diffs side-by-side

added added

removed removed

Lines of Context:
770
770
            return copy_success;
771
771
        }
772
772
 
773
 
        private static HyenaSqliteCommand get_uri_id_cmd = new HyenaSqliteCommand ("SELECT TrackID FROM CoreTracks WHERE Uri = ? LIMIT 1");
774
 
        public static int GetTrackIdForUri (string uri)
775
 
        {
776
 
            return ServiceManager.DbConnection.Query<int> (get_uri_id_cmd, new SafeUri (uri).AbsoluteUri);
777
 
        }
778
 
 
779
 
        private static HyenaSqliteCommand get_track_id_by_uri = new HyenaSqliteCommand (
780
 
            "SELECT TrackID FROM CoreTracks WHERE PrimarySourceId IN (?) AND Uri = ? LIMIT 1"
781
 
        );
 
773
        private static string get_track_id_by_uri =
 
774
            "SELECT TrackID FROM CoreTracks WHERE {0} {1} = ? LIMIT 1";
 
775
 
 
776
        private static HyenaSqliteCommand get_track_id_by_uri_primarysources = new HyenaSqliteCommand (String.Format (
 
777
            get_track_id_by_uri, "PrimarySourceId IN (?) AND", BansheeQuery.UriField.Column
 
778
        ));
 
779
 
 
780
        private static HyenaSqliteCommand get_track_id_by_uri_plain = new HyenaSqliteCommand (String.Format (
 
781
            get_track_id_by_uri, string.Empty, BansheeQuery.UriField.Column
 
782
        ));
782
783
 
783
784
        private static string get_track_by_metadata_hash =
784
785
            "SELECT {0} FROM {1} WHERE {2} AND PrimarySourceId IN (?) AND MetadataHash = ? LIMIT 1";
787
788
            "SELECT COUNT('x') FROM CoreTracks WHERE PrimarySourceId IN (?) AND MetadataHash = ?"
788
789
        );
789
790
 
 
791
        public static int GetTrackIdForUri (string uri)
 
792
        {
 
793
            return GetTrackIdForUri (new SafeUri (uri));
 
794
        }
 
795
 
790
796
        public static int GetTrackIdForUri (SafeUri uri, params int [] primary_sources)
791
797
        {
792
 
            return ServiceManager.DbConnection.Query<int> (get_track_id_by_uri,
793
 
                primary_sources, uri.AbsoluteUri);
 
798
            return GetTrackIdForUri (uri.AbsoluteUri, primary_sources);
794
799
        }
795
800
 
796
 
        public static int GetTrackIdForUri (string absoluteUri, int [] primary_sources)
 
801
        public static int GetTrackIdForUri (string absoluteUri, params int [] primary_sources)
797
802
        {
798
 
            return ServiceManager.DbConnection.Query<int> (get_track_id_by_uri,
799
 
                primary_sources, absoluteUri);
 
803
            if (primary_sources == null || primary_sources.Length == 0) {
 
804
                return ServiceManager.DbConnection.Query<int> (get_track_id_by_uri_plain, absoluteUri);
 
805
            }
 
806
            return ServiceManager.DbConnection.Query<int> (
 
807
                get_track_id_by_uri_primarysources, primary_sources, absoluteUri
 
808
            );
800
809
        }
801
810
 
802
811
        private static IDataReader FindTrackByMetadataHash (string metadata_hash, int [] primary_sources)