public void Index()
        {
            lock (this) {
                DisposeModels();

                foreach (Source source in ServiceManager.SourceManager.Sources)
                {
                    LibrarySource library = source as LibrarySource;
                    if (library != null && library.Indexable)
                    {
                        model_caches.Add(CachedList <DatabaseTrackInfo> .CreateFromSourceModel(
                                             (DatabaseTrackListModel)library.TrackModel));
                    }
                }
            }

            OnIndexingFinished();
        }
        public override void GetChunks(int chunk_size)
        {
            CachedList <DatabaseTrackInfo> list;
            DatabaseTrackListModel         track_model = null;

            // mark as critical region to prevent consecutive calls from mucking things up
            lock (payload_lock) {
                long timestamp;

                lock (timestamp_lock) {
                    if (UseBuffer)
                    {
                        buffer = new Dictionary <int, IDictionary <string, object> []> ();
                    }
                    timestamp        = DateTime.Now.Ticks;
                    CurrentTimestamp = timestamp;
                }

                switch ((LibraryType)Id)
                {
                case LibraryType.Music:
                    track_model = (DatabaseTrackListModel)ServiceManager.SourceManager.MusicLibrary.TrackModel;
                    break;

                case LibraryType.Video:
                    track_model = (DatabaseTrackListModel)ServiceManager.SourceManager.VideoLibrary.TrackModel;
                    break;
                }

                if (track_model == null)
                {
                    IDictionary <string, object> [] empty = {};     // d-bus no like nulls
                    OnChunkReady(ObjectPath, empty, timestamp, 1, 0);
                    return;
                }

                chunk_size = chunk_size < 1 ? 100 : chunk_size;         // default chunk_size

                list = CachedList <DatabaseTrackInfo> .CreateFromSourceModel(track_model);

                int total = track_model.UnfilteredCount;

                // deliver data asynchronously via signal in chunks of chunk_size
                // this should make things look like they are happening quickly over our tube
                int sequence_num = 1;

                for (int i = 0; i < total; i += chunk_size)
                {
                    int dict_size = (total - i) < chunk_size ? (total - i) : chunk_size;
                    IDictionary <string, object> [] dict = new Dictionary <string, object> [dict_size];

                    for (int j = 0; j < dict.Length; j++)
                    {
                        int index = j + i;
                        dict[j] = list[index].GenerateExportable();
                        dict[j].Add("TrackId", list[index].TrackId);
                    }

                    if (UseBuffer)
                    {
                        buffer.Add(sequence_num, dict);
                    }

                    //System.Threading.Thread.Sleep (2500); // FIXME simulate slowness
                    OnChunkReady(ObjectPath, dict, timestamp, sequence_num++, total);
                }

                list.Dispose();
            }
        }