Beispiel #1
0
        private void BuildSyncLists()
        {
            // This smart playlist is the list of items we want on the device - nothing more, nothing less
            sync_src             = new SmartPlaylistSource("sync_list", library);
            sync_src.IsTemporary = true;
            sync_src.Save();
            sync_src.AddCondition(library.AttributesCondition);
            sync_src.AddCondition(library.SyncCondition);

            // This is the same as the previous list with the items that are already on the device removed
            to_add             = new SmartPlaylistSource("to_add", library);
            to_add.IsTemporary = true;
            to_add.Save();
            to_add.ConditionTree = UserQueryParser.Parse(String.Format("smartplaylistid:{0}", sync_src.DbId),
                                                         Banshee.Query.BansheeQuery.FieldSet);
            to_add.DatabaseTrackModel.AddCondition(String.Format(
                                                       "MetadataHash NOT IN (SELECT MetadataHash FROM CoreTracks WHERE PrimarySourceId = {0})", sync.Dap.DbId
                                                       ));

            // Any items on the device that aren't in the sync lists need to be removed
            to_remove             = new SmartPlaylistSource("to_remove", sync.Dap);
            to_remove.IsTemporary = true;
            to_remove.Save();
            to_remove.AddCondition(library.AttributesCondition);
            to_remove.AddCondition(String.Format(
                                       @"MetadataHash NOT IN (SELECT MetadataHash FROM CoreTracks, CoreSmartPlaylistEntries
                    WHERE CoreSmartPlaylistEntries.SmartPlaylistID = {0} AND
                        CoreTracks.TrackID = CoreSmartPlaylistEntries.TrackID)",
                                       sync_src.DbId
                                       ));
        }
Beispiel #2
0
        private void PrimarySourceInitialize()
        {
            // Scope the tracks to this primary source
            DatabaseTrackModel.AddCondition(String.Format("CoreTracks.PrimarySourceID = {0}", DbId));

            primary_sources[DbId] = this;

            // If there was a crash, tracks can be left behind, for example in DaapSource.
            // Temporary playlists are cleaned up by the PlaylistSource.LoadAll call below
            if (IsTemporary && SavedCount > 0)
            {
                PurgeTracks();
            }

            // Load our playlists and smart playlists
            foreach (PlaylistSource pl in PlaylistSource.LoadAll(this))
            {
                AddChildSource(pl);
            }

            int sp_count = 0;

            foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll(this))
            {
                AddChildSource(pl);
                sp_count++;
            }

            // Create default smart playlists if we haven't done it ever before, and if the
            // user has zero smart playlists.
            if (!HaveCreatedSmartPlaylists)
            {
                if (sp_count == 0)
                {
                    foreach (SmartPlaylistDefinition def in DefaultSmartPlaylists)
                    {
                        SmartPlaylistSource pl = def.ToSmartPlaylistSource(this);
                        pl.Save();
                        AddChildSource(pl);
                        pl.RefreshAndReload();
                        sp_count++;
                    }
                }

                // Only save it if we already had some smart playlists, or we actually created some (eg not
                // if we didn't have any and the list of default ones is empty atm).
                if (sp_count > 0)
                {
                    HaveCreatedSmartPlaylists = true;
                }
            }

            expanded_schema = new SchemaEntry <bool> (
                String.Format("sources.{0}", ParentConfigurationId), "expanded", true, "Is source expanded", "Is source expanded"
                );
        }
Beispiel #3
0
        protected override void OnResponse(ResponseType response)
        {
            //int w = -1, h = -1;
            //dialog.GetSize (out w, out h);
            //Console.WriteLine ("w = {0}, h = {1}", w, h);

            QueryNode node = builder.QueryNode;
            if (node == null) {
                //Console.WriteLine ("Editor query is null");
            } else {
                //Console.WriteLine ("Editor query is: {0}", node.ToXml (BansheeQuery.FieldSet, true));
            }

            if (response == ResponseType.Ok) {
                string name = PlaylistName;
                QueryNode condition_tree = Condition;
                QueryLimit limit = Limit;
                QueryOrder order = Order;
                IntegerQueryValue limit_value = LimitValue;

                ThreadAssist.Spawn (delegate {
                    //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number);
                    if (playlist == null) {
                        playlist = new SmartPlaylistSource (name, primary_source);

                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder = order;
                        playlist.Limit = limit;
                        playlist.LimitValue = limit_value;

                        playlist.Save ();
                        primary_source.AddChildSource (playlist);
                        playlist.RefreshAndReload ();
                        //SmartPlaylistCore.Instance.StartTimer (playlist);
                    } else {
                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder = order;
                        playlist.LimitValue = limit_value;
                        playlist.Limit = limit;

                        playlist.Name = name;
                        playlist.Save ();
                        playlist.RefreshAndReload ();

                        /*if (playlist.TimeDependent)
                            SmartPlaylistCore.Instance.StartTimer (playlist);
                        else
                            SmartPlaylistCore.Instance.StopTimer ();*/

                        //playlist.ListenToPlaylists ();
                        //SmartPlaylistCore.Instance.SortPlaylists ();
                    }
                });
            }

            currently_editing = null;
        }
        private void BuildSyncLists ()
        {
            // This smart playlist is the list of items we want on the device - nothing more, nothing less
            sync_src = new SmartPlaylistSource ("sync_list", library);
            sync_src.IsTemporary = true;
            sync_src.Save ();
            sync_src.AddCondition (library.AttributesCondition);
            sync_src.AddCondition (library.SyncCondition);

            // This is the same as the previous list with the items that are already on the device removed
            to_add = new SmartPlaylistSource ("to_add", library);
            to_add.IsTemporary = true;
            to_add.Save ();
            to_add.ConditionTree = UserQueryParser.Parse (String.Format ("smartplaylistid:{0}", sync_src.DbId),
                Banshee.Query.BansheeQuery.FieldSet);
            to_add.DatabaseTrackModel.AddCondition (String.Format (
                "MetadataHash NOT IN (SELECT MetadataHash FROM CoreTracks WHERE PrimarySourceId = {0})", sync.Dap.DbId
            ));

            // Any items on the device that aren't in the sync lists need to be removed
            to_remove = new SmartPlaylistSource ("to_remove", sync.Dap);
            to_remove.IsTemporary = true;
            to_remove.Save ();
            to_remove.AddCondition (library.AttributesCondition);
            to_remove.AddCondition (String.Format (
                @"MetadataHash NOT IN (SELECT MetadataHash FROM CoreTracks, CoreSmartPlaylistEntries
                    WHERE CoreSmartPlaylistEntries.SmartPlaylistID = {0} AND
                        CoreTracks.TrackID = CoreSmartPlaylistEntries.TrackID)",
                sync_src.DbId
            ));
        }